$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
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "stratagus.h"
#include "video.h"
#include "sound.h"
#include "sound_server.h"
#include "unittype.h"
#include "player.h"
#include "unit.h"
#include "interface.h"
#include "cursor.h"
#include "ui.h"
#include "menus.h"
#include "script.h"
#include "tileset.h"
#include "minimap.h"
#include "network.h"
#include "font.h"
#include "results.h"
#include "iolib.h"
#include "commands.h"
#include "ai.h"
#include "widgets.h"
#include "replay.h"
interface.cpp - The interface. | |
#define | SCROLL_UP 15 |
Scrolling area (<= 15 y). | |
#define | SCROLL_DOWN (Video.Height - 16) |
Scrolling area (>= VideoHeight - 16 y). | |
#define | SCROLL_LEFT 15 |
Scrolling area (<= 15 y). | |
#define | SCROLL_RIGHT (Video.Width - 16) |
Scrolling area (>= VideoWidth - 16 x). | |
static int | SavedMapPositionX [3] |
static int | SavedMapPositionY [3] |
Saved map position X. | |
static char | Input [80] |
Saved map position Y. | |
static int | InputIndex |
line input for messages/long commands | |
static char | InputStatusLine [99] |
current index into input | |
const char | DefaultGroupKeys [] = "0123456789`" |
Last input status line. | |
const char * | UiGroupKeys = DefaultGroupKeys |
Default group keys. | |
bool | GameRunning |
Up to 11 keys, last unselect. Default for qwerty. | |
bool | GamePaused |
Current running state. | |
bool | GameObserve |
Current pause state. | |
char | SkipGameCycle |
Observe mode. | |
char | BigMapMode |
Skip the next game cycle. | |
enum _iface_state_ | InterfaceState |
Show only the map. | |
bool | GodMode |
Current interface state. | |
enum _key_state_ | KeyState |
Invincibility cheat. | |
int | DoubleClickDelay = 300 |
Time to detect double clicks. | |
int | HoldClickDelay = 1000 |
Time to detect double clicks. | |
static enum { InitialMouseState, ClickedMouseState } | MouseState |
Time to detect hold clicks. | |
static int | MouseX |
Current state of mouse. | |
static int | MouseY |
Last mouse X position. | |
static unsigned | LastMouseButton |
Last mouse Y position. | |
static unsigned | StartMouseTicks |
last mouse button handled | |
static unsigned | LastMouseTicks |
Ticks of first click. | |
static int | HoldKeyDelay = 250 |
static int | HoldKeyAdditionalDelay = 50 |
Time to detect hold key. | |
static unsigned | LastIKey |
Time to detect additional hold key. | |
static unsigned | LastIKeyChar |
last key handled | |
static unsigned | LastKeyTicks |
last keychar handled | |
static unsigned | DoubleKey |
Ticks of last key. | |
static void | ShowInput () |
current key state | |
static void | UiBeginInput () |
static void | UiUnselectAll () |
static void | UiCenterOnGroup (unsigned group, GroupSelectionMode mode=SELECTABLE_BY_RECTANGLE_ONLY) |
static void | UiSelectGroup (unsigned group, GroupSelectionMode mode=SELECTABLE_BY_RECTANGLE_ONLY) |
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. | |
void | UiToggleBigMap () |
Toggle big map. | |
static void | UiIncreaseGameSpeed () |
static void | UiDecreaseGameSpeed () |
static void | UiSetDefaultGameSpeed () |
static void | UiCenterOnSelected () |
static void | UiSaveMapPosition (unsigned position) |
static void | UiRecallMapPosition (unsigned position) |
static void | UiToggleTerrain () |
static void | UiFindIdleWorker () |
static void | UiToggleGrabMouse () |
static void | UiTrackUnit () |
bool | HandleCommandKey (int key) |
Call the lua function HandleCommandKey. | |
static bool | CommandKey (int key) |
int | HandleCheats (const std::string &input) |
Handle cheats. | |
static int | InputKey (int key) |
static void | Screenshot () |
int | HandleKeyModifiersDown (unsigned key, unsigned) |
Update KeyModifiers if a key is pressed. | |
int | HandleKeyModifiersUp (unsigned key, unsigned) |
Update KeyModifiers if a key is released. | |
static bool | IsKeyPad (unsigned key, unsigned *kp) |
void | HandleKeyDown (unsigned key, unsigned keychar) |
Called if a key is pressed. | |
void | HandleKeyUp (unsigned key, unsigned keychar) |
Called when a key is released. | |
void | HandleKeyRepeat (unsigned, unsigned keychar) |
Called when a key is repeated. | |
int | HandleMouseScrollArea (int x, int y) |
Handle the mouse in scroll area. | |
void | HandleCursorMove (int *x, int *y) |
Keep coordinates in window and update cursor position. | |
void | HandleMouseMove (int x, int y) |
Called if the mouse is moved. | |
void | HandleButtonDown (unsigned button) |
Called if any mouse button is pressed down. | |
void | HandleButtonUp (unsigned button) |
Called if any mouse button is released up. | |
void | InputMouseButtonPress (const EventCallback *callbacks, unsigned ticks, unsigned button) |
Ticks of last mouse event. | |
void | InputMouseButtonRelease (const EventCallback *callbacks, unsigned ticks, unsigned button) |
void | InputMouseMove (const EventCallback *callbacks, unsigned ticks, int x, int y) |
void | InputMouseExit (const EventCallback *callbacks, unsigned) |
void | InputMouseTimeout (const EventCallback *callbacks, unsigned ticks) |
void | InputKeyButtonPress (const EventCallback *callbacks, unsigned ticks, unsigned ikey, unsigned ikeychar) |
last key pressed | |
void | InputKeyButtonRelease (const EventCallback *callbacks, unsigned ticks, unsigned ikey, unsigned ikeychar) |
void | InputKeyTimeout (const EventCallback *callbacks, unsigned ticks) |
int | GetDoubleClickDelay () |
Get double click delay. | |
void | SetDoubleClickDelay (int delay) |
Set double click delay. | |
int | GetHoldClickDelay () |
Get hold click delay. | |
void | SetHoldClickDelay (int delay) |
Set hold click delay. |
#define SCROLL_DOWN (Video.Height - 16) |
Scrolling area (>= VideoHeight - 16 y).
#define SCROLL_LEFT 15 |
Scrolling area (<= 15 y).
#define SCROLL_RIGHT (Video.Width - 16) |
Scrolling area (>= VideoWidth - 16 x).
#define SCROLL_UP 15 |
Scrolling area (<= 15 y).
anonymous enum |
static bool CommandKey | ( | int | key | ) | [static] |
Handle keys in command mode.
key | Key scancode. |
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 | ) |
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. |
void HandleMouseMove | ( | int | x, | |
int | y | |||
) |
Called if the mouse is moved.
Handle movement of the cursor.
x | screen pixel X position. | |
y | screen pixel Y position. |
int HandleMouseScrollArea | ( | int | x, | |
int | y | |||
) |
Handle the mouse in scroll area.
Handle the mouse in scroll area
x | Screen X position. | |
y | Screen Y position. |
static int InputKey | ( | int | key | ) | [static] |
Handle keys in input mode.
key | Key scancode. |
void InputKeyButtonPress | ( | const EventCallback * | callbacks, | |
unsigned | ticks, | |||
unsigned | ikey, | |||
unsigned | ikeychar | |||
) |
last key pressed
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 | |||
) |
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 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
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
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)
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
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 each frame to handle mouse timeouts.
callbacks | Callback structure for events. | |
ticks | Denotes time-stamp of video-system |
static bool IsKeyPad | ( | unsigned | key, | |
unsigned * | kp | |||
) | [static] |
Check if a key is from the keypad and convert to ascii
static void Screenshot | ( | ) | [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 |
static void ShowInput | ( | ) | [static] |
current key state
Show input.
static void UiAddGroupToSelection | ( | unsigned | group | ) | [static] |
Add group to current selection.
group | Group number to add. |
static void UiAddToGroup | ( | unsigned | group | ) | [static] |
Add to group. The current selected units are added to the group.
group | Group number to be expanded. |
static void UiBeginInput | ( | ) | [static] |
Begin input.
static void UiCenterOnGroup | ( | unsigned | group, | |
GroupSelectionMode | mode = SELECTABLE_BY_RECTANGLE_ONLY | |||
) | [static] |
Center on group.
group | Group number to center on. |
static void UiCenterOnSelected | ( | ) | [static] |
Center on the selected units.
static void UiDecreaseGameSpeed | ( | ) | [static] |
Decrease game speed.
static void UiDefineGroup | ( | unsigned | group | ) | [static] |
Define a group. The current selected units become a new group.
group | Group number to create. |
static void UiFindIdleWorker | ( | ) | [static] |
Find the next idle worker, select it, and center on it
static void UiIncreaseGameSpeed | ( | ) | [static] |
Increase game speed.
static void UiRecallMapPosition | ( | unsigned | position | ) | [static] |
Recall map position.
position | Map position slot. |
static void UiSaveMapPosition | ( | unsigned | position | ) | [static] |
Save current map position.
position | Map position slot. |
static void UiSelectGroup | ( | unsigned | group, | |
GroupSelectionMode | mode = SELECTABLE_BY_RECTANGLE_ONLY | |||
) | [static] |
Select group.
group | Group number to select. |
static void UiSetDefaultGameSpeed | ( | ) | [static] |
Set default game speed.
void UiToggleBigMap | ( | ) |
static void UiToggleGrabMouse | ( | ) | [static] |
Toggle grab mouse on/off.
static void UiToggleMusic | ( | ) | [static] |
Toggle music on / off.
void UiTogglePause | ( | ) |
Toggle pause mode.
Toggle pause on / off.
static void UiToggleSound | ( | ) | [static] |
Toggle sound on / off.
static void UiToggleTerrain | ( | ) | [static] |
Toggle terrain display on/off.
static void UiTrackUnit | ( | ) | [static] |
Track unit, the viewport follows the unit.
static void UiUnselectAll | ( | ) | [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 DefaultGroupKeys[] = "0123456789`" |
Last input status line.
right button attacks
int DoubleClickDelay = 300 |
Time to detect double clicks.
unsigned DoubleKey [static] |
Ticks of last key.
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.
int HoldKeyAdditionalDelay = 50 [static] |
Time to detect hold key.
int HoldKeyDelay = 250 [static] |
char Input[80] [static] |
Saved map position Y.
int InputIndex [static] |
line input for messages/long commands
char InputStatusLine[99] [static] |
current index into input
Show only the map.
current interface state
enum _key_state_ KeyState |
Invincibility cheat.
current key state
unsigned LastIKey [static] |
Time to detect additional hold key.
unsigned LastIKeyChar [static] |
last key handled
unsigned LastKeyTicks [static] |
last keychar handled
unsigned LastMouseButton [static] |
Last mouse Y position.
unsigned LastMouseTicks [static] |
Ticks of first click.
enum { ... } MouseState [static] |
Time to detect hold clicks.
int MouseX [static] |
Current state of mouse.
int MouseY [static] |
Last mouse X position.
int SavedMapPositionX[3] [static] |
int SavedMapPositionY[3] [static] |
Saved map position X.
char SkipGameCycle |
Observe mode.
Flag telling not to advance to the next game cycle.
unsigned StartMouseTicks [static] |
last mouse button handled
const char* UiGroupKeys = DefaultGroupKeys |
Default group keys.