____                _       __
    / __ )____  _____   | |     / /___ ___________
   / __  / __ \/ ___/   | | /| / / __ `/ ___/ ___/
  / /_/ / /_/ (__  )    | |/ |/ / /_/ / /  (__  )
 /_____/\____/____/     |__/|__/\__,_/_/  /____/

       A futuristic real-time strategy game.
          This file is part of Bos Wars.
(C) Copyright 2001-2007 by the Bos Wars and Stratagus Project. Distributed under the "GNU General Public License"

ui.cpp File Reference

The user interface globals. More...

#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 "ui.h"
#include "menus.h"
#include "iolib.h"
#include "unit.h"
#include "title.h"

Go to the source code of this file.

Functions

void InitUserInterface (void)
 < Initialize the ui
static void SaveViewports (CFile *file, const CUserInterface *ui)
void SaveUserInterface (CFile *file)
 Clean up the ui module.
void CleanUserInterface (void)
 Register ccl features.
CViewportGetViewport (int x, int y)
 Cycle through all available viewport modes.
static void FinishViewportModeConfiguration (CViewport new_vps[], int num_vps)
static void ClipViewport (CViewport *vp, int ClipX, int ClipY)
static void SetViewportModeSingle (void)
static void SetViewportModeSplitHoriz (void)
static void SetViewportModeSplitHoriz3 (void)
static void SetViewportModeSplitVert (void)
static void SetViewportModeQuad (void)
void SetViewportMode (ViewportModeType new_mode)
 Use the mouse to scroll the map.
void CycleViewportMode (int step)
 Select viewport mode.
bool GetMouseScroll (void)
 Enable/disable scrolling with the mouse.
void SetMouseScroll (bool enabled)
 Check if keyboard scrolling is enabled.
bool GetKeyScroll ()
 Enable/disable scrolling with the keyboard.
void SetKeyScroll (bool enabled)
 Check if mouse grabbing is enabled.
bool GetGrabMouse (void)
 Enable/disable grabbing the mouse.
void SetGrabMouse (bool enabled)
 Check if scrolling stops when leaving the window.
bool GetLeaveStops (void)
 Enable/disable leaving the window stops scrolling.
void SetLeaveStops (bool enabled)

Variables

bool RightButtonAttacks
 right button attacks
CUserInterface UI
 The user interface.


Detailed Description

The user interface globals.

Definition in file ui.cpp.


Function Documentation

void CleanUserInterface ( void   ) 

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.

Definition at line 397 of file ui.cpp.

References Assert, CMapArea::EndX, CViewport::EndX, CMapArea::EndY, CViewport::EndY, CMap::Info, Map, CUserInterface::MapArea, CMapInfo::MapHeight, CMapInfo::MapWidth, TileSizeX, TileSizeY, CViewport::X, and CViewport::Y.

Referenced by SetViewportModeQuad(), SetViewportModeSingle(), SetViewportModeSplitHoriz(), SetViewportModeSplitHoriz3(), and SetViewportModeSplitVert().

void CycleViewportMode ( int  step  ) 

Select viewport mode.

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).

Definition at line 608 of file ui.cpp.

References NUM_VIEWPORT_MODES, SetViewportMode(), and CUserInterface::ViewportMode.

Referenced by CommandKey(), and EditorCallbackKeyDown().

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.

Definition at line 330 of file ui.cpp.

References CursorX, CursorY, CViewport::EndX, CViewport::EndY, GetViewport(), CViewport::MapX, CViewport::MapY, CUserInterface::MouseViewport, CUserInterface::NumViewports, CViewport::OffsetX, CViewport::OffsetY, CUserInterface::SelectedViewport, CViewport::Set(), TileSizeX, TileSizeY, CUserInterface::Viewports, CViewport::X, and CViewport::Y.

Referenced by SetViewportModeQuad(), SetViewportModeSingle(), SetViewportModeSplitHoriz(), SetViewportModeSplitHoriz3(), and SetViewportModeSplitVert().

bool GetGrabMouse ( void   ) 

Enable/disable grabbing the mouse.

Check if mouse grabbing is enabled

Definition at line 661 of file ui.cpp.

References SdlGetGrabMouse().

Referenced by tolua_stratagus_GetGrabMouse00().

bool GetKeyScroll ( void   ) 

Enable/disable scrolling with the keyboard.

Check if keyboard scrolling is enabled

Definition at line 643 of file ui.cpp.

References CUserInterface::KeyScroll.

Referenced by tolua_stratagus_GetKeyScroll00().

bool GetLeaveStops ( void   ) 

Enable/disable leaving the window stops scrolling.

Check if scrolling stops when leaving the window

Definition at line 679 of file ui.cpp.

References LeaveStops.

Referenced by tolua_stratagus_GetLeaveStops00().

bool GetMouseScroll ( void   ) 

Enable/disable scrolling with the mouse.

Check if mouse scrolling is enabled

Definition at line 625 of file ui.cpp.

References CUserInterface::MouseScroll.

Referenced by tolua_stratagus_GetMouseScroll00().

CViewport* GetViewport ( int  x,
int  y 
)

Cycle through all available viewport modes.

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.

Definition at line 307 of file ui.cpp.

References CUserInterface::NumViewports, CUserInterface::Viewports, CViewport::X, and CViewport::Y.

Referenced by EditorCallbackButtonDown(), EditorCallbackMouse(), FinishViewportModeConfiguration(), and HandleMouseOn().

void InitUserInterface ( void   ) 

void SaveUserInterface ( CFile file  ) 

Clean up the ui module.

Save the user interface module.

Parameters:
file Save file handle

Definition at line 225 of file ui.cpp.

References SaveViewports().

Referenced by SaveGame().

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

Save the viewports.

Parameters:
file Save file handle
ui User interface to save

Definition at line 206 of file ui.cpp.

References CViewport::MapX, CViewport::MapY, CUserInterface::NumViewports, CFile::printf(), CViewport::Unit, UnitNumber, CUserInterface::ViewportMode, and CUserInterface::Viewports.

Referenced by SaveUserInterface().

void SetGrabMouse ( bool  enabled  ) 

Check if scrolling stops when leaving the window.

Enable/disable grabbing the mouse

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

Definition at line 671 of file ui.cpp.

References ToggleGrabMouse().

Referenced by tolua_stratagus_SetGrabMouse00().

void SetKeyScroll ( bool  enabled  ) 

Check if mouse grabbing is enabled.

Enable/disable scrolling with the keyboard

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

Definition at line 653 of file ui.cpp.

References CUserInterface::KeyScroll.

Referenced by tolua_stratagus_SetKeyScroll00().

void SetLeaveStops ( bool  enabled  ) 

Enable/disable leaving the window stops scrolling

Parameters:
enabled True to stop scrolling, false to disable

Definition at line 689 of file ui.cpp.

References LeaveStops.

Referenced by tolua_stratagus_SetLeaveStops00().

void SetMouseScroll ( bool  enabled  ) 

Check if keyboard scrolling is enabled.

Enable/disable scrolling with the mouse

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

Definition at line 635 of file ui.cpp.

References CUserInterface::MouseScroll.

Referenced by tolua_stratagus_SetMouseScroll00().

void SetViewportMode ( ViewportModeType  new_mode  ) 

Use the mouse to scroll the map.

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

Parameters:
new_mode New mode's number.

Definition at line 576 of file ui.cpp.

References DebugPrint, SetViewportModeQuad(), SetViewportModeSingle(), SetViewportModeSplitHoriz(), SetViewportModeSplitHoriz3(), SetViewportModeSplitVert(), VIEWPORT_QUAD, VIEWPORT_SINGLE, VIEWPORT_SPLIT_HORIZ, VIEWPORT_SPLIT_HORIZ3, VIEWPORT_SPLIT_VERT, and CUserInterface::ViewportMode.

Referenced by CycleViewportMode(), InitUserInterface(), and UiToggleBigMap().

static void SetViewportModeQuad ( void   )  [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)).

Definition at line 540 of file ui.cpp.

References ClipViewport(), DebugPrint, CViewport::EndX, CMapArea::EndX, CViewport::EndY, CMapArea::EndY, FinishViewportModeConfiguration(), CUserInterface::MapArea, MAX_NUM_VIEWPORTS, CMapArea::X, CViewport::X, CMapArea::Y, and CViewport::Y.

Referenced by SetViewportMode().

static void SetViewportModeSingle ( void   )  [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)).

Definition at line 425 of file ui.cpp.

References ClipViewport(), DebugPrint, CMapArea::EndX, CMapArea::EndY, FinishViewportModeConfiguration(), CUserInterface::MapArea, MAX_NUM_VIEWPORTS, CMapArea::X, CViewport::X, CMapArea::Y, and CViewport::Y.

Referenced by SetViewportMode().

static void SetViewportModeSplitHoriz ( void   )  [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)).

Definition at line 448 of file ui.cpp.

References ClipViewport(), DebugPrint, CMapArea::EndX, CViewport::EndY, CMapArea::EndY, FinishViewportModeConfiguration(), CUserInterface::MapArea, MAX_NUM_VIEWPORTS, CMapArea::X, CViewport::X, CMapArea::Y, and CViewport::Y.

Referenced by SetViewportMode().

static void SetViewportModeSplitHoriz3 ( void   )  [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)).

Definition at line 477 of file ui.cpp.

References ClipViewport(), DebugPrint, CViewport::EndX, CMapArea::EndX, CViewport::EndY, CMapArea::EndY, FinishViewportModeConfiguration(), CUserInterface::MapArea, MAX_NUM_VIEWPORTS, CMapArea::X, CViewport::X, CMapArea::Y, and CViewport::Y.

Referenced by SetViewportMode().

static void SetViewportModeSplitVert ( void   )  [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)).

Definition at line 511 of file ui.cpp.

References ClipViewport(), DebugPrint, CViewport::EndX, CMapArea::EndX, CMapArea::EndY, FinishViewportModeConfiguration(), CUserInterface::MapArea, MAX_NUM_VIEWPORTS, CMapArea::X, CViewport::X, CMapArea::Y, and CViewport::Y.

Referenced by SetViewportMode().


Variable Documentation

right button attacks

Definition at line 55 of file ui.cpp.

Referenced by CclRightButtonAttacks(), CclRightButtonMoves(), and DoRightButton().

The user interface.

The user interface configuration

Definition at line 61 of file ui.cpp.

Referenced by MessagesDisplay::AddMessage(), CalculateStereo(), CalculateVisibleIcons(), CancelBuildingMode(), CclCenterMap(), CclDefineViewports(), CclSetMinimapTerrain(), CclSetMouseScrollSpeedControl(), CclSetMouseScrollSpeedDefault(), CenterOnMessage(), CMap::Clean(), CreateGame(), CButtonPanel::DoClicked(), CButtonPanel::DoKey(), DoScrollArea(), DoSelectionButtons(), CButtonPanel::Draw(), CViewport::DrawBorder(), DrawBuildingCursor(), DrawCosts(), CMinimap::DrawCursor(), DrawCursor(), DrawEditorPanel(), DrawInfoPanelMultipleSelected(), DrawInfoPanelNoneSelected(), DrawInfoPanelSingleSelected(), DrawMapArea(), DrawMapCursor(), DrawMenuButtonArea(), MessagesDisplay::DrawMessages(), DrawPatchIcons(), DrawPieMenu(), DrawPlayers(), DrawPopup(), DrawStartLocations(), DrawTimer(), DrawTrainingUnits(), DrawTransportingUnits(), CIcon::DrawUnitIcon(), DrawUnitIcons(), DrawUnitInfo(), DrawUnitOn(), DrawUnitStats(), DrawVisibleRectangleCursor(), EditorActionRemoveUnit(), EditorCallbackButtonDown(), EditorCallbackButtonUp(), EditorCallbackKeyDown(), EditorCallbackMouse(), EditorMainLoop(), EditorUpdateDisplay(), GameMainLoop(), GetPieUnderCursor(), HandleActionTrain(), HandleKeyDown(), HandleMouseExit(), HandleMouseOn(), HandleMouseScrollArea(), HandlePieMenuMouseSelection(), InitSoundClient(), InitVideoSdl(), InputKey(), CUnit::IsVisibleOnScreen(), LoadModules(), MenuLoop(), MouseScrollMap(), CPlayer::Notify(), PatchEditorCallbackMouse(), PlayMissileSound(), PreMenuSetup(), ReloadOpenGL(), CVideo::ResizeScreen(), RestrictCursorToMinimap(), RestrictCursorToViewport(), MenuScreen::run(), SdlDoEvent(), SelectedUnitChanged(), SelectionChanged(), SelectUnitsByType(), SelectUnitsInRectangle(), SendCommand(), CViewport::Set(), ShowInput(), ShowPatchInfo(), ShowUnitInfo(), MenuScreen::stop(), ToggleUnitsByType(), tolua_get_UI(), tolua_set_UI(), UiCenterOnGroup(), UiCenterOnSelected(), UiDecreaseGameSpeed(), UiFindIdleWorker(), UIHandleButtonDown(), UIHandleButtonUp(), UIHandleMouseMove(), UiIncreaseGameSpeed(), UiRecallMapPosition(), UiSaveMapPosition(), UISelectStateButtonDown(), UiToggleBigMap(), UiToggleGrabMouse(), UiToggleMusic(), UiTogglePause(), UiToggleSound(), UiToggleTerrain(), UiTrackUnit(), UpdateButtonPanelMultipleUnits(), UpdateButtonPanelSingleUnit(), UpdateDisplay(), MessagesDisplay::UpdateMessages(), UpdateStatusLineForButton(), ViewPointDistance(), and ViewPointDistanceToUnit().


Generated on Sat Feb 21 00:28:21 2009 for Bos Wars by  doxygen 1.5.6