$treeview $search $mathjax
Stratagus  2.2.6
$projectbrief
$projectbrief
$searchbox
-->
         _________ __                 __
        /   _____//  |_____________ _/  |______     ____  __ __  ______
        \_____  \\   __\_  __ \__  \\   __\__  \   / ___\|  |  \/  ___/
        /        \|  |  |  | \// __ \|  |  / __ \_/ /_/  >  |  /\___ \
       /_______  /|__|  |__|  (____  /__| (____  /\___  /|____//____  >
               \/                  \/          \//_____/            \/
    ______________________                           ______________________
                          T H E   W A R   B E G I N S
           Stratagus - A free fantasy real time strategy game engine

src/ui/ui.cpp File Reference

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "stratagus.h"
#include "video.h"
#include "font.h"
#include "interface.h"
#include "map.h"
#include "tileset.h"
#include "ui.h"
#include "menus.h"
#include "iolib.h"
#include "unit.h"
#include "title.h"

ui.cpp - The user interface globals.

bool RightButtonAttacks
static ViewportModeType NewViewportMode = VIEWPORT_SINGLE
 right button attacks
bool FancyBuildings
 Up to 11 keys used for group selection.
CUserInterface UI
 Mirror buildings 1 yes, 0 now.
void InitUserInterface ()
 Mirror buildings 1 yes, 0 now.
static void SaveViewports (CFile &file, const CUserInterface &ui)
void SaveUserInterface (CFile *file)
 Save the ui state.
void CleanUserInterface ()
 Clean up the ui module.
CViewportGetViewport (int x, int y)
 Get viewport for screen pixel position.
static void FinishViewportModeConfiguration (CViewport new_vps[], int num_vps)
static void ClipViewport (CViewport &vp, int ClipX, int ClipY)
static void SetViewportModeSingle ()
static void SetViewportModeSplitHoriz ()
static void SetViewportModeSplitHoriz3 ()
static void SetViewportModeSplitVert ()
static void SetViewportModeQuad ()
void SetViewportMode (ViewportModeType new_mode)
 Select viewport mode.
void CycleViewportMode (int step)
 Cycle through all available viewport modes.
void CheckViewportMode ()
void UpdateViewports ()
bool GetMouseScroll ()
 Check if mouse scrolling is enabled.
void SetMouseScroll (bool enabled)
 Enable/disable scrolling with the mouse.
bool GetKeyScroll ()
 Check if keyboard scrolling is enabled.
void SetKeyScroll (bool enabled)
 Enable/disable scrolling with the keyboard.
bool GetGrabMouse ()
 Check if mouse grabbing is enabled.
void SetGrabMouse (bool enabled)
 Enable/disable grabbing the mouse.
bool GetLeaveStops ()
 Check if scrolling stops when leaving the window.
void SetLeaveStops (bool enabled)
 Enable/disable leaving the window stops scrolling.

Function Documentation

void CheckViewportMode (  ) 

void CleanUserInterface (  ) 

Clean up the ui module.

Clean up the user interface module.

static void ClipViewport ( CViewport vp,
int  ClipX,
int  ClipY 
) [static]

Takes a viewport which is supposed to have its CViewport::[XY] correctly filled-in and computes CViewport::End[XY] attributes according to clipping information passed in other two arguments.

Parameters:
vp The viewport.
ClipX Maximum x-coordinate of the viewport's right side as dictated by current UI's geometry and ViewportMode.
ClipY Maximum y-coordinate of the viewport's bottom side as dictated by current UI's geometry and ViewportMode.
Note:
It is supposed that values passed in Clip[XY] will never be greater than UI::MapArea::End[XY]. However, they can be smaller according to the place the viewport vp takes in context of current ViewportMode.

void CycleViewportMode ( int  step  ) 

Cycle through all available viewport modes.

Cycles through predefined viewport modes (geometry configurations) in order defined by the ViewportMode enumerated type.

Parameters:
step The size of step used for cycling. Values that make sense are mostly 1 (next viewport mode) and -1 (previous viewport mode).

static void FinishViewportModeConfiguration ( CViewport  new_vps[],
int  num_vps 
) [static]

Takes an array of new Viewports which are supposed to have their pixel geometry (CViewport::[XY] and CViewport::End[XY]) already computed. Using this information as well as old viewport's parameters fills in new viewports' CViewport::Map* parameters. Then it replaces the old viewports with the new ones and finishes the set-up of the new mode.

Parameters:
new_vps The array of the new viewports
num_vps The number of elements in the new_vps[] array.

bool GetGrabMouse (  ) 

Check if mouse grabbing is enabled.

Check if mouse grabbing is enabled

bool GetKeyScroll (  ) 

Check if keyboard scrolling is enabled.

Check if keyboard scrolling is enabled

bool GetLeaveStops (  ) 

Check if scrolling stops when leaving the window.

Check if scrolling stops when leaving the window

bool GetMouseScroll (  ) 

Check if mouse scrolling is enabled.

Check if mouse scrolling is enabled

CViewport* GetViewport ( int  x,
int  y 
)

Get viewport for screen pixel position.

Takes coordinates of a pixel in stratagus's window and computes the map viewport which contains this pixel.

Parameters:
x x pixel coordinate with origin at UL corner of screen
y y pixel coordinate with origin at UL corner of screen
Returns:
viewport pointer or NULL if this pixel is not inside any of the viewports.
Note:
This functions only works with rectangular viewports, when we support shaped map window, this must be rewritten.

void InitUserInterface (  ) 

Mirror buildings 1 yes, 0 now.

Initialize the user interface.

void SaveUserInterface ( CFile file  ) 

Save the ui state.

Save the user interface module.

Parameters:
file Save file handle

static void SaveViewports ( CFile file,
const CUserInterface ui 
) [static]

Save the viewports.

Parameters:
file Save file handle
ui User interface to save

void SetGrabMouse ( bool  enabled  ) 

Enable/disable grabbing the mouse.

Enable/disable grabbing the mouse

Parameters:
enabled True to enable mouse grabbing, false to disable

void SetKeyScroll ( bool  enabled  ) 

Enable/disable scrolling with the keyboard.

Enable/disable scrolling with the keyboard

Parameters:
enabled True to enable keyboard scrolling, false to disable

void SetLeaveStops ( bool  enabled  ) 

Enable/disable leaving the window stops scrolling.

Enable/disable leaving the window stops scrolling

Parameters:
enabled True to stop scrolling, false to disable

void SetMouseScroll ( bool  enabled  ) 

Enable/disable scrolling with the mouse.

Enable/disable scrolling with the mouse

Parameters:
enabled True to enable mouse scrolling, false to disable

void SetViewportMode ( ViewportModeType  new_mode  ) 

Select viewport mode.

Sets up (calls geometry setup routines for) a new viewport mode.

Parameters:
new_mode New mode's number.

static void SetViewportModeQuad (  )  [static]

Compute viewport parameters for 4-way split viewport mode. This mode splits the UI::MapArea vertically *and* horizontally to 4 (approximately) equal parts.

The parameters include viewport's width and height expressed in pixels, its position with respect to Stratagus's window origin, and the corresponding map parameters expressed in map tiles with origin at map origin (map tile (0,0)).

static void SetViewportModeSingle (  )  [static]

Compute viewport parameters for single viewport mode.

The parameters include viewport's width and height expressed in pixels, its position with respect to Stratagus's window origin, and the corresponding map parameters expressed in map tiles with origin at map origin (map tile (0,0)).

static void SetViewportModeSplitHoriz (  )  [static]

Compute viewport parameters for horizontally split viewport mode. This mode splits the UI::MapArea with a horizontal line to 2 (approximately) equal parts.

The parameters include viewport's width and height expressed in pixels, its position with respect to Stratagus's window origin, and the corresponding map parameters expressed in map tiles with origin at map origin (map tile (0,0)).

static void SetViewportModeSplitHoriz3 (  )  [static]

Compute viewport parameters for horizontal 3-way split viewport mode. This mode splits the UI::MapArea with a horizontal line to 2 (approximately) equal parts, then splits the bottom part vertically to another 2 parts.

The parameters include viewport's width and height expressed in pixels, its position with respect to Stratagus's window origin, and the corresponding map parameters expressed in map tiles with origin at map origin (map tile (0,0)).

static void SetViewportModeSplitVert (  )  [static]

Compute viewport parameters for vertically split viewport mode. This mode splits the UI::MapArea with a vertical line to 2 (approximately) equal parts.

The parameters include viewport's width and height expressed in pixels, its position with respect to Stratagus's window origin, and the corresponding map parameters expressed in map tiles with origin at map origin (map tile (0,0)).

void UpdateViewports (  ) 


Variable Documentation

Up to 11 keys used for group selection.

ViewportModeType NewViewportMode = VIEWPORT_SINGLE [static]

right button attacks

Mirror buildings 1 yes, 0 now.

Current Selected Buttons.

The user interface configuration

(C) Copyright 1998-2011 by The Stratagus Project under the GNU General Public License.
All trademarks and copyrights on this page are owned by their respective owners.