_________ __ __ / _____// |_____________ _/ |______ ____ __ __ ______ \_____ \\ __\_ __ \__ \\ __\__ \ / ___\| | \/ ___/ / \| | | | \// __ \| | / __ \_/ /_/ > | /\___ \ /_______ /|__| |__| (____ /__| (____ /\___ /|____//____ > \/ \/ \//_____/ \/ ______________________ ______________________ T H E W A R B E G I N S Stratagus - A free fantasy real time strategy game engine
#include "stratagus.h"
#include "interface.h"
#include "ai.h"
#include "commands.h"
#include "cursor.h"
#include "font.h"
#include "iolib.h"
#include "network.h"
#include "player.h"
#include "replay.h"
#include "sound.h"
#include "sound_server.h"
#include "translate.h"
#include "ui.h"
#include "unit.h"
#include "unit_find.h"
#include "unittype.h"
#include "video.h"
#include "widgets.h"
interface.cpp - The interface. | |
int | ScrollMarginTop = 15 |
int | ScrollMarginBottom = 16 |
int | ScrollMarginLeft = 15 |
int | ScrollMarginRight = 16 |
const char | Cursor [] = "~!_" |
static Vec2i | SavedMapPosition [3] |
Input cursor. More... | |
static char | Input [80] |
Saved map position. More... | |
static int | InputIndex |
line input for messages/long commands More... | |
static char | InputStatusLine [99] |
current index into input More... | |
constexpr int | MaxInputHistorySize = 16 |
Last input status line. More... | |
static char | InputHistory [MaxInputHistorySize *sizeof(Input)] = { '\0' } |
Max history of inputs. More... | |
static int | InputHistoryIdx = 0 |
History of inputs. More... | |
static int | InputHistoryPos = 0 |
Next history idx. More... | |
static int | InputHistorySize = 0 |
Current position in history. More... | |
const char | DefaultGroupKeys [] = "0123456789`" |
History fill size. More... | |
std::string | UiGroupKeys = DefaultGroupKeys |
Default group keys. More... | |
bool | GameRunning |
Up to 11 keys, last unselect. Default for qwerty. More... | |
bool | GamePaused |
Current running state. More... | |
bool | GameObserve |
Current pause state. More... | |
bool | GameEstablishing |
Observe mode. More... | |
char | SkipGameCycle |
Game establishing mode. More... | |
char | BigMapMode |
Skip the next game cycle. More... | |
enum _iface_state_ | InterfaceState |
Show only the map. More... | |
bool | GodMode |
Current interface state. More... | |
enum _key_state_ | KeyState |
Invincibility cheat. More... | |
CUnit * | LastIdleWorker |
current key state More... | |
int | DoubleClickDelay = 300 |
Time to detect double clicks. More... | |
int | HoldClickDelay = 1000 |
Time to detect double clicks. More... | |
static enum { ... } | MouseState |
Time to detect hold clicks. More... | |
static PixelPos | LastMousePos |
Current state of mouse. More... | |
static unsigned | LastMouseButton |
Last mouse position. More... | |
static unsigned | StartMouseTicks |
last mouse button handled More... | |
static unsigned | LastMouseTicks |
Ticks of first click. More... | |
static const int | HoldKeyDelay = 250 |
static const int | HoldKeyAdditionalDelay = 50 |
Time to detect hold key. More... | |
static unsigned | LastIKey |
Time to detect additional hold key. More... | |
static unsigned | LastIKeyChar |
last key handled More... | |
static unsigned | LastKeyTicks |
last keychar handled More... | |
static unsigned | DoubleKey |
Ticks of last key. More... | |
static void | moveInputContent (int targetPos, int srcPos) |
Last called idle worker. More... | |
static void | removeCursorFromInput () |
static void | addCursorToInput () |
static void | ShowInput () |
static void | UiBeginInput () |
static void | UiUnselectAll () |
static void | UiCenterOnGroup (unsigned group, GroupSelectionMode mode=SELECTABLE_BY_RECTANGLE_ONLY) |
static void | UiSelectGroup (unsigned group, GroupSelectionMode mode=SELECT_ALL) |
static void | UiAddGroupToSelection (unsigned group) |
static void | UiDefineGroup (unsigned group) |
static void | UiAddToGroup (unsigned group) |
static void | UiToggleSound () |
static void | UiToggleMusic () |
void | UiTogglePause () |
Toggle pause mode. More... | |
void | UiToggleBigMap () |
Toggle big map. More... | |
static void | UiIncreaseGameSpeed () |
static void | UiDecreaseGameSpeed () |
static void | UiSetDefaultGameSpeed () |
static void | UiCenterOnSelected () |
static void | UiSaveMapPosition (unsigned position) |
static void | UiRecallMapPosition (unsigned position) |
void | UiToggleTerrain () |
Toggle terrain display on/off. More... | |
void | UiFindIdleWorker () |
Find the next idle worker. More... | |
static void | UiToggleGrabMouse () |
void | UiTrackUnit () |
Track unit, the viewport follows the unit. More... | |
bool | HandleCommandKey (int key) |
Call the lua function HandleCommandKey. More... | |
static void | CommandKey_Group (int group) |
static void | CommandKey_MapPosition (int index) |
static bool | CommandKey (int key) |
int | HandleCheats (const std::string &input) |
Handle cheats. More... | |
static void | Replace2TildeByTilde (char *s) |
static void | ReplaceTildeBy2Tilde (char *s) |
static void | InputKey (int key) |
static void | Screenshot () |
int | HandleKeyModifiersDown (unsigned key, unsigned) |
Update KeyModifiers if a key is pressed. More... | |
int | HandleKeyModifiersUp (unsigned key, unsigned) |
Update KeyModifiers if a key is released. More... | |
static bool | IsKeyPad (unsigned key, unsigned *kp) |
void | HandleKeyDown (unsigned key, unsigned keychar) |
Called if a key is pressed. More... | |
void | HandleKeyUp (unsigned key, unsigned keychar) |
Called when a key is released. More... | |
void | HandleKeyRepeat (unsigned, unsigned keychar) |
Called when a key is repeated. More... | |
bool | HandleMouseScrollArea (const PixelPos &mousePos) |
Handle the mouse in scroll area. More... | |
void | HandleCursorMove (int *x, int *y) |
Keep coordinates in window and update cursor position. More... | |
void | HandleMouseMove (const PixelPos &screenPos) |
Called if the mouse is moved. More... | |
void | HandleButtonDown (unsigned button) |
Called if any mouse button is pressed down. More... | |
void | HandleButtonUp (unsigned button) |
Called if any mouse button is released up. More... | |
void | InputMouseButtonPress (const EventCallback &callbacks, unsigned ticks, unsigned button) |
Ticks of last mouse event. More... | |
void | InputMouseButtonRelease (const EventCallback &callbacks, unsigned ticks, unsigned button) |
Called if any mouse button is released up. More... | |
void | InputMouseMove (const EventCallback &callbacks, unsigned ticks, int x, int y) |
Called if the mouse is moved. More... | |
void | InputMouseExit (const EventCallback &callbacks, unsigned) |
Called if the mouse exits the game window (when supported by videomode) More... | |
void | InputMouseTimeout (const EventCallback &callbacks, unsigned ticks) |
Called to look for mouse timeouts. More... | |
void | InputKeyButtonPress (const EventCallback &callbacks, unsigned ticks, unsigned ikey, unsigned ikeychar) |
last key pressed More... | |
void | InputKeyButtonRelease (const EventCallback &callbacks, unsigned ticks, unsigned ikey, unsigned ikeychar) |
Called if any key button is released up. More... | |
void | InputKeyTimeout (const EventCallback &callbacks, unsigned ticks) |
Called to look for key timeouts. More... | |
int | GetDoubleClickDelay () |
Get double click delay. More... | |
void | SetDoubleClickDelay (int delay) |
Set double click delay. More... | |
int | GetHoldClickDelay () |
Get hold click delay. More... | |
void | SetHoldClickDelay (int delay) |
Set hold click delay. More... | |
void | SetScrollMargins (unsigned int top, unsigned int right, unsigned int bottom, unsigned int left) |
Scroll margins on screen. More... | |
anonymous enum |
|
static |
|
static |
Handle keys in command mode.
key | Key scancode. |
|
static |
|
static |
int GetDoubleClickDelay | ( | ) |
Get double click delay.
Get double click delay
int GetHoldClickDelay | ( | ) |
Get hold click delay.
Get hold click delay
void HandleButtonDown | ( | unsigned | button | ) |
Called if any mouse button is pressed down.
Called if mouse button pressed down.
button | Mouse button number (0 left, 1 middle, 2 right) |
void HandleButtonUp | ( | unsigned | button | ) |
Called if any mouse button is released up.
Called if mouse button released.
FIXME: the mouse handling should be complete rewritten
FIXME: this is needed for double click, long click,...
button | Mouse button number (0 left, 1 middle, 2 right) |
int HandleCheats | ( | const std::string & | input | ) |
Handle cheats.
Handle cheats
bool HandleCommandKey | ( | int | key | ) |
Call the lua function HandleCommandKey.
Call the lua function HandleCommandKey
void HandleCursorMove | ( | int * | x, |
int * | y | ||
) |
Keep coordinates in window and update cursor position.
Keep coordinates in window and update cursor position
x | screen pixel X position. |
y | screen pixel Y position. |
void HandleKeyDown | ( | unsigned | key, |
unsigned | keychar | ||
) |
Called if a key is pressed.
Handle key down.
key | Key scancode. |
keychar | Character code. |
int HandleKeyModifiersDown | ( | unsigned | key, |
unsigned | |||
) |
Update KeyModifiers if a key is pressed.
Update KeyModifiers if a key is pressed.
key | Key scancode. |
keychar | Character code. |
int HandleKeyModifiersUp | ( | unsigned | key, |
unsigned | |||
) |
Update KeyModifiers if a key is released.
Update KeyModifiers if a key is released.
key | Key scancode. |
keychar | Character code. |
void HandleKeyRepeat | ( | unsigned | , |
unsigned | keychar | ||
) |
Called when a key is repeated.
Handle key up.
key | Key scancode. |
keychar | Character code. |
void HandleKeyUp | ( | unsigned | key, |
unsigned | keychar | ||
) |
Called when a key is released.
Handle key up.
key | Key scancode. |
keychar | Character code. |
Called if the mouse is moved.
Handle movement of the cursor.
screePos | screen pixel position. |
bool HandleMouseScrollArea | ( | const PixelPos & | mousePos | ) |
Handle the mouse in scroll area.
Handle the mouse in scroll area
mousePos | Screen position. |
|
static |
Handle keys in input mode.
key | Key scancode. |
void InputKeyButtonPress | ( | const EventCallback & | callbacks, |
unsigned | ticks, | ||
unsigned | ikey, | ||
unsigned | ikeychar | ||
) |
last key pressed
Called if any key button is pressed down.
Handle keyboard key press.
callbacks | Callback structure for events. |
ticks | Denotes time-stamp of video-system |
ikey | Key scancode. |
ikeychar | Character code. |
void InputKeyButtonRelease | ( | const EventCallback & | callbacks, |
unsigned | ticks, | ||
unsigned | ikey, | ||
unsigned | ikeychar | ||
) |
Called if any key button is released up.
Handle keyboard key release.
callbacks | Callback structure for events. |
ticks | Denotes time-stamp of video-system |
ikey | Key scancode. |
ikeychar | Character code. |
void InputKeyTimeout | ( | const EventCallback & | callbacks, |
unsigned | ticks | ||
) |
Called to look for key timeouts.
Called each frame to handle keyboard timeouts.
callbacks | Callback structure for events. |
ticks | Denotes time-stamp of video-system |
void InputMouseButtonPress | ( | const EventCallback & | callbacks, |
unsigned | ticks, | ||
unsigned | button | ||
) |
Ticks of last mouse event.
Called if any mouse button is pressed down.
Called if any mouse button is pressed down
Handles event conversion to double click, dragging, hold.
FIXME: dragging is not supported.
callbacks | Callback structure for events. |
ticks | Denotes time-stamp of video-system |
button | Mouse button pressed. |
void InputMouseButtonRelease | ( | const EventCallback & | callbacks, |
unsigned | ticks, | ||
unsigned | button | ||
) |
Called if any mouse button is released up.
Called if any mouse button is released up
callbacks | Callback structure for events. |
ticks | Denotes time-stamp of video-system |
button | Mouse button released. |
void InputMouseExit | ( | const EventCallback & | callbacks, |
unsigned | |||
) |
Called if the mouse exits the game window (when supported by videomode)
Called if the mouse exits the game window (when supported by videomode)
callbacks | Callback structure for events. |
ticks | Denotes time-stamp of video-system |
void InputMouseMove | ( | const EventCallback & | callbacks, |
unsigned | ticks, | ||
int | x, | ||
int | y | ||
) |
Called if the mouse is moved.
Called if the mouse is moved
callbacks | Callback structure for events. |
ticks | Denotes time-stamp of video-system |
x | X movement |
y | Y movement |
void InputMouseTimeout | ( | const EventCallback & | callbacks, |
unsigned | ticks | ||
) |
Called to look for mouse timeouts.
Called each frame to handle mouse timeouts.
callbacks | Callback structure for events. |
ticks | Denotes time-stamp of video-system |
|
static |
Check if a key is from the keypad and convert to ascii
|
static |
Last called idle worker.
|
static |
|
static |
|
static |
|
static |
Save a screenshot.
void SetDoubleClickDelay | ( | int | delay | ) |
Set double click delay.
Set double click delay
delay | Double click delay |
void SetHoldClickDelay | ( | int | delay | ) |
Set hold click delay.
Set hold click delay
delay | Hold click delay |
void SetScrollMargins | ( | unsigned int | top, |
unsigned int | right, | ||
unsigned int | bottom, | ||
unsigned int | left | ||
) |
Scroll margins on screen.
Configure margins (in pixels) on screen where map scrolling starts.
|
static |
Show input.
|
static |
Add group to current selection.
group | Group number to add. |
|
static |
Add to group. The current selected units are added to the group.
group | Group number to be expanded. |
|
static |
Begin input.
|
static |
Center on group.
group | Group number to center on. |
|
static |
Center on the selected units.
|
static |
Decrease game speed.
|
static |
Define a group. The current selected units become a new group.
group | Group number to create. |
void UiFindIdleWorker | ( | ) |
Find the next idle worker.
Find the next idle worker, select it, and center on it
|
static |
Increase game speed.
|
static |
Recall map position.
position | Map position slot. |
|
static |
Save current map position.
position | Map position slot. |
|
static |
Select group.
group | Group number to select. |
|
static |
Set default game speed.
void UiToggleBigMap | ( | ) |
|
static |
Toggle grab mouse on/off.
|
static |
Toggle music on / off.
void UiTogglePause | ( | ) |
Toggle pause mode.
Toggle pause on / off.
|
static |
Toggle sound on / off.
void UiToggleTerrain | ( | ) |
Toggle terrain display on/off.
Toggle terrain display on/off.
void UiTrackUnit | ( | ) |
Track unit, the viewport follows the unit.
Track unit, the viewport follows the unit.
|
static |
Unselect all currently selected units.
char BigMapMode |
Skip the next game cycle.
Whether the map is the only thing displayed or not.
const char Cursor[] = "~!_" |
const char DefaultGroupKeys[] = "0123456789`" |
History fill size.
right button attacks
int DoubleClickDelay = 300 |
Time to detect double clicks.
|
static |
Ticks of last key.
bool GameEstablishing |
Observe mode.
Flag telling if the game is in establishing mode.
bool GameObserve |
Current pause state.
Flag telling if the game is in observe mode.
bool GamePaused |
Current running state.
Flag telling if the game is paused.
bool GameRunning |
Up to 11 keys, last unselect. Default for qwerty.
Flag telling if the game is running.
bool GodMode |
Current interface state.
Invincibility cheat.
int HoldClickDelay = 1000 |
Time to detect double clicks.
Time to detect hold clicks.
|
static |
Time to detect hold key.
|
static |
|
static |
Saved map position.
|
static |
Max history of inputs.
|
static |
History of inputs.
|
static |
Next history idx.
|
static |
Current position in history.
|
static |
line input for messages/long commands
|
static |
current index into input
enum _iface_state_ InterfaceState |
Show only the map.
current interface state
enum _key_state_ KeyState |
Invincibility cheat.
current key state
CUnit* LastIdleWorker |
current key state
|
static |
Time to detect additional hold key.
|
static |
last key handled
|
static |
last keychar handled
|
static |
Last mouse position.
|
static |
Current state of mouse.
|
static |
Ticks of first click.
|
constexpr |
Last input status line.
enum { ... } MouseState |
Time to detect hold clicks.
|
static |
Input cursor.
int ScrollMarginBottom = 16 |
int ScrollMarginLeft = 15 |
int ScrollMarginRight = 16 |
int ScrollMarginTop = 15 |
char SkipGameCycle |
Game establishing mode.
Flag telling not to advance to the next game cycle.
|
static |
last mouse button handled
std::string UiGroupKeys = DefaultGroupKeys |
Default group keys.