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

ui.cpp File Reference
#include "stratagus.h"
#include "ui.h"
#include "font.h"
#include "interface.h"
#include "iolib.h"
#include "map.h"
#include "menus.h"
#include "title.h"
#include "ui/contenttype.h"
#include "ui/popup.h"
#include "unit.h"
#include "video.h"
#include <stdarg.h>

ui.cpp - The user interface globals.

bool RightButtonAttacks
 
static ViewportModeType NewViewportMode = VIEWPORT_SINGLE
 right button attacks More...
 
bool FancyBuildings
 Up to 11 keys used for group selection. More...
 
CUserInterface UI
 Mirror buildings 1 yes, 0 now. More...
 
void ShowLoadProgress (const char *fmt,...)
 
bool IsDemoMode ()
 Check if Demo/Attract mode is in progress. More...
 
CPopupPopupByIdent (const std::string &ident)
 return popup by ident string More...
 
void InitUserInterface ()
 Mirror buildings 1 yes, 0 now. More...
 
static void SaveViewports (CFile &file, const CUserInterface &ui)
 
void SaveUserInterface (CFile &file)
 Save the ui state. More...
 
void CleanUserInterface ()
 Clean up the ui module. More...
 
void FreeButtonStyles ()
 
CViewportGetViewport (const PixelPos &screenPos)
 Get viewport for screen pixel position. More...
 
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. More...
 
void SetNewViewportMode (ViewportModeType new_mode)
 
void CycleViewportMode (int step)
 Cycle through all available viewport modes. More...
 
void CheckViewportMode ()
 
bool GetMouseScroll ()
 Check if mouse scrolling is enabled. More...
 
void SetMouseScroll (bool enabled)
 Enable/disable scrolling with the mouse. More...
 
bool GetKeyScroll ()
 Check if keyboard scrolling is enabled. More...
 
void SetKeyScroll (bool enabled)
 Enable/disable scrolling with the keyboard. More...
 
bool GetGrabMouse ()
 Check if mouse grabbing is enabled. More...
 
void SetGrabMouse (bool enabled)
 Enable/disable grabbing the mouse. More...
 
bool GetLeaveStops ()
 Check if scrolling stops when leaving the window. More...
 
void SetLeaveStops (bool enabled)
 Enable/disable leaving the window stops scrolling. More...
 

Function Documentation

◆ CheckViewportMode()

void CheckViewportMode ( )

◆ CleanUserInterface()

void CleanUserInterface ( )

Clean up the ui module.

Clean up the user interface module.

◆ ClipViewport()

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
vpThe viewport.
ClipXMaximum x-coordinate of the viewport's right side as dictated by current UI's geometry and ViewportMode.
ClipYMaximum 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.

◆ CycleViewportMode()

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
stepThe size of step used for cycling. Values that make sense are mostly 1 (next viewport mode) and -1 (previous viewport mode).

◆ FinishViewportModeConfiguration()

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_vpsThe array of the new viewports
num_vpsThe number of elements in the new_vps[] array.

◆ FreeButtonStyles()

void FreeButtonStyles ( )

◆ GetGrabMouse()

bool GetGrabMouse ( )

Check if mouse grabbing is enabled.

Check if mouse grabbing is enabled

◆ GetKeyScroll()

bool GetKeyScroll ( )

Check if keyboard scrolling is enabled.

Check if keyboard scrolling is enabled

◆ GetLeaveStops()

bool GetLeaveStops ( )

Check if scrolling stops when leaving the window.

Check if scrolling stops when leaving the window

◆ GetMouseScroll()

bool GetMouseScroll ( )

Check if mouse scrolling is enabled.

Check if mouse scrolling is enabled

◆ GetViewport()

CViewport* GetViewport ( const PixelPos screenPos)

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

◆ InitUserInterface()

void InitUserInterface ( )

Mirror buildings 1 yes, 0 now.

Initialize the user interface.

Align UI map area if at least one of the map dimensions fits completely into it.

◆ IsDemoMode()

bool IsDemoMode ( )

Check if Demo/Attract mode is in progress.

Check if the game is running in Demo mode.

Returns
True if the game is in demo mode, false otherwise

◆ PopupByIdent()

CPopup* PopupByIdent ( const std::string &  ident)

return popup by ident string

Get popup class pointer by string identifier.

Parameters
identPopup identifier.
Returns
popup class pointer.

◆ SaveUserInterface()

void SaveUserInterface ( CFile file)

Save the ui state.

Save the user interface module.

Parameters
fileSave file handle

◆ SaveViewports()

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

Save the viewports.

Parameters
fileSave file handle
uiUser interface to save

◆ SetGrabMouse()

void SetGrabMouse ( bool  enabled)

Enable/disable grabbing the mouse.

Enable/disable grabbing the mouse

Parameters
enabledTrue to enable mouse grabbing, false to disable

◆ SetKeyScroll()

void SetKeyScroll ( bool  enabled)

Enable/disable scrolling with the keyboard.

Enable/disable scrolling with the keyboard

Parameters
enabledTrue to enable keyboard scrolling, false to disable

◆ SetLeaveStops()

void SetLeaveStops ( bool  enabled)

Enable/disable leaving the window stops scrolling.

Enable/disable leaving the window stops scrolling

Parameters
enabledTrue to stop scrolling, false to disable

◆ SetMouseScroll()

void SetMouseScroll ( bool  enabled)

Enable/disable scrolling with the mouse.

Enable/disable scrolling with the mouse

Parameters
enabledTrue to enable mouse scrolling, false to disable

◆ SetNewViewportMode()

void SetNewViewportMode ( ViewportModeType  new_mode)

Sets up a new viewport mode.

Parameters
new_modeNew mode's number.

◆ SetViewportMode()

void SetViewportMode ( ViewportModeType  new_mode)

Select viewport mode.

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

Parameters
new_modeNew mode's number.

◆ SetViewportModeQuad()

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

◆ SetViewportModeSingle()

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

◆ SetViewportModeSplitHoriz()

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

◆ SetViewportModeSplitHoriz3()

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

◆ SetViewportModeSplitVert()

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

◆ ShowLoadProgress()

void ShowLoadProgress ( const char *  fmt,
  ... 
)

Show load progress.

Parameters
fmtprintf format string.

Variable Documentation

◆ FancyBuildings

bool FancyBuildings

Up to 11 keys used for group selection.

◆ NewViewportMode

ViewportModeType NewViewportMode = VIEWPORT_SINGLE
static

right button attacks

◆ RightButtonAttacks

bool RightButtonAttacks

◆ UI

Mirror buildings 1 yes, 0 now.

Current Selected Buttons.

The user interface configuration

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