$treeview $search $mathjax
Stratagus  2.2.7
$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/editor/editloop.cpp File Reference

#include <deque>
#include "stratagus.h"
#include "editor.h"
#include "commands.h"
#include "font.h"
#include "game.h"
#include "guichan.h"
#include "interface.h"
#include "iocompat.h"
#include "iolib.h"
#include "map.h"
#include "menus.h"
#include "minimap.h"
#include "network.h"
#include "replay.h"
#include "script.h"
#include "settings.h"
#include "sound.h"
#include "sound_server.h"
#include "tileset.h"
#include "translate.h"
#include "ui.h"
#include "unit_find.h"
#include "unittype.h"
#include "video.h"
#include "widgets.h"

Classes

struct  EditorAction
class  EditorUnitSliderListener
class  EditorSliderListener

editloop.cpp - The editor main loop.

#define UNIT_ICON_X   (IconWidth + 7)
#define UNIT_ICON_Y   (0)
#define TILE_ICON_X   (IconWidth * 2 + 16)
#define TILE_ICON_Y   (2)
#define START_ICON_X   (IconWidth * 3 + 16)
#define START_ICON_Y   (2)
enum  _mode_buttons_ { SelectButton = 201, UnitButton, TileButton, StartButton }
enum  EditorActionType { EditorActionTypePlaceUnit, EditorActionTypeRemoveUnit }
static int IconWidth
static int IconHeight
 Icon width in panels.
static int ButtonPanelWidth
 Icon height in panels.
static int ButtonPanelHeight
static char TileToolRandom
static char TileToolDecoration
 Tile tool draws random.
static int TileCursorSize
 Tile tool draws with decorations.
static bool UnitPlacedThisPress = false
 Tile cursor size 1x1 2x2 ... 4x4.
static bool UpdateMinimap = false
 Only allow one unit per press.
static int MirrorEdit = 0
 Update units on the minimap.
static int VisibleUnitIcons
 Mirror editing enabled.
static int VisibleTileIcons
 Number of icons that are visible at a time.
static std::deque< EditorActionEditorUndoActions
static std::deque< EditorActionEditorRedoActions
gcn::GuiGui
static gcn::ContainereditorContainer
static gcn::SlidereditorUnitSlider
static gcn::SlidereditorSlider
static EditorUnitSliderListenereditorUnitSliderListener
static EditorSliderListenereditorSliderListener
void DoScrollArea (int state, bool fast)
 Editor callbacks.
void DrawGuichanWidgets ()
void CleanGame ()
static void EditorUndoAction ()
static void EditorRedoAction ()
static void EditorAddUndoAction (EditorAction action)
static int GetTileNumber (int basic, int random, int filler)
void EditTile (const Vec2i &pos, int tile)
static void EditTilesInternal (const Vec2i &pos, int tile, int size)
void EditTiles (const Vec2i &pos, int tile, int size)
static void EditorActionPlaceUnit (const Vec2i &pos, const CUnitType &type, CPlayer *player)
static void EditorPlaceUnit (const Vec2i &pos, CUnitType &type, CPlayer *player)
static void EditorActionRemoveUnit (CUnit &unit)
static void EditorRemoveUnit (CUnit &unit)
static int CalculateVisibleIcons (bool tiles=false)
static void CalculateMaxIconSize ()
static void RecalculateShownUnits ()
static void DrawPlayers ()
static void DrawUnitIcons ()
static void DrawTileIcon (unsigned tilenum, unsigned x, unsigned y, unsigned flags)
static void DrawTileIcons ()
static void DrawEditorPanel_SelectIcon ()
static void DrawEditorPanel_UnitsIcon ()
static void DrawEditorPanel_StartIcon ()
static void DrawEditorPanel ()
static void DrawMapCursor ()
static void DrawStartLocations ()
static void DrawEditorInfo ()
static void ShowUnitInfo (const CUnit &unit)
void EditorUpdateDisplay ()
 Update editor display.
static void EditorCallbackButtonUp (unsigned button)
static void EditorCallbackButtonDown (unsigned button)
static void EditorCallbackKeyDown (unsigned key, unsigned keychar)
static void EditorCallbackKeyUp (unsigned key, unsigned keychar)
static void EditorCallbackKeyRepeated (unsigned key, unsigned)
static void EditorCallbackMouse (const PixelPos &pos)
static void EditorCallbackExit ()
static void CreateTileIcons ()
static void CleanTileIcons ()
int EditorSaveMap (const std::string &file)
 Save a map from editor.
void EditorMainLoop ()
 Editor main event loop.
void StartEditor (const char *filename)
 Start the editor.

Define Documentation

#define START_ICON_X   (IconWidth * 3 + 16)

#define START_ICON_Y   (2)

#define TILE_ICON_X   (IconWidth * 2 + 16)

#define TILE_ICON_Y   (2)

#define UNIT_ICON_X   (IconWidth + 7)

#define UNIT_ICON_Y   (0)


Enumeration Type Documentation

Enumerator:
SelectButton 
UnitButton  Select mode button.
TileButton  Unit mode button.
StartButton  Tile mode button.

Enumerator:
EditorActionTypePlaceUnit 
EditorActionTypeRemoveUnit 


Function Documentation

static void CalculateMaxIconSize (  )  [static]

Calculate the max height and the max width of icons, and assign them to IconHeight and IconWidth

static int CalculateVisibleIcons ( bool  tiles = false  )  [static]

Calculate the number of icons that can be displayed

Returns:
Number of icons that can be displayed.

void CleanGame (  ) 

Cleanup game.

Call each module to clean up. Contrary to CleanModules, maps can be restarted without reloading all lua files.

static void CleanTileIcons (  )  [static]

Clean up the tile icons

static void CreateTileIcons (  )  [static]

Create the tile icons

void DoScrollArea ( int  state,
bool  fast 
)

Editor callbacks.

Handle scrolling area.

Parameters:
state Scroll direction/state.
fast Flag scroll faster.
Todo:
Support dynamic acceleration of scroll speed.
Todo:
If the scroll key is longer pressed the area is scrolled faster.

static void DrawEditorInfo (  )  [static]

Draw editor info.

If cursor is on map or minimap show information about the current tile.

static void DrawEditorPanel (  )  [static]

Draw the editor panels.

static void DrawEditorPanel_SelectIcon (  )  [static]

static void DrawEditorPanel_StartIcon (  )  [static]

static void DrawEditorPanel_UnitsIcon (  )  [static]

void DrawGuichanWidgets (  ) 

static void DrawMapCursor (  )  [static]

Draw special cursor on map.

Todo:
support for bigger cursors (2x2, 3x3 ...)

static void DrawPlayers (  )  [static]

Draw a table with the players

static void DrawStartLocations (  )  [static]

Draw the start locations of all active players on the map

static void DrawTileIcon ( unsigned  tilenum,
unsigned  x,
unsigned  y,
unsigned  flags 
) [static]

Draw a tile icon

Parameters:
tilenum Tile number to display
x X display position
y Y display position
flags State of the icon (IconActive,IconClicked,...)

static void DrawTileIcons (  )  [static]

Draw tile icons.

Todo:
for the start the solid tiles are hardcoded If we have more solid tiles, than they fit into the panel, we need some new ideas.

static void DrawUnitIcons (  )  [static]

Draw unit icons.

static void EditorActionPlaceUnit ( const Vec2i pos,
const CUnitType type,
CPlayer player 
) [static]

Place unit.

Parameters:
pos map tile coordinate.
type Unit type to edit.
player Player owning the unit.
Todo:
FIXME: Check if the player has already a start-point.
Bug:
This function does not support mirror editing!

static void EditorActionRemoveUnit ( CUnit unit  )  [static]

Remove a unit

static void EditorAddUndoAction ( EditorAction  action  )  [static]

static void EditorCallbackButtonDown ( unsigned  button  )  [static]

Called if mouse button pressed down.

Parameters:
button Mouse button number (0 left, 1 middle, 2 right)

static void EditorCallbackButtonUp ( unsigned  button  )  [static]

Callback for input.

static void EditorCallbackExit (  )  [static]

Callback for exit.

static void EditorCallbackKeyDown ( unsigned  key,
unsigned  keychar 
) [static]

Handle key down.

Parameters:
key Key scancode.
keychar Character code.

static void EditorCallbackKeyRepeated ( unsigned  key,
unsigned   
) [static]

Callback for input.

static void EditorCallbackKeyUp ( unsigned  key,
unsigned  keychar 
) [static]

Handle key up.

Parameters:
key Key scancode.
keychar Character code.

static void EditorCallbackMouse ( const PixelPos pos  )  [static]

Callback for input movement of the cursor.

Parameters:
x Screen X position.
y Screen Y position.

void EditorMainLoop (  ) 

Editor main event loop.

Editor main event loop.

static void EditorPlaceUnit ( const Vec2i pos,
CUnitType type,
CPlayer player 
) [static]

Edit unit.

Parameters:
pos map tile coordinate.
type Unit type to edit.
player Player owning the unit.

static void EditorRedoAction (  )  [static]

static void EditorRemoveUnit ( CUnit unit  )  [static]

Remove a unit

int EditorSaveMap ( const std::string &  file  ) 

Save a map from editor.

Save a map from editor.

Parameters:
file Save the level to this file.
Returns:
0 for success, -1 for error
Todo:
FIXME: Check if the map is valid, contains no failures. At least two players, one human slot, every player a startpoint ...

static void EditorUndoAction (  )  [static]

void EditorUpdateDisplay (  ) 

Update editor display.

Update editor display.

void EditTile ( const Vec2i pos,
int  tile 
)

Edit tile.

Parameters:
pos map tile coordinate.
tile Tile type to edit.

void EditTiles ( const Vec2i pos,
int  tile,
int  size 
)

Edit tiles

Parameters:
pos map tile coordinate.
tile Tile type to edit.
size Size of rectangle

static void EditTilesInternal ( const Vec2i pos,
int  tile,
int  size 
) [static]

Edit tiles (internal, used by EditTiles()).

Parameters:
pos map tile coordinate.
tile Tile type to edit.
size Size of rectangle
Bug:
This function does not support mirror editing!

static int GetTileNumber ( int  basic,
int  random,
int  filler 
) [static]

Get tile number.

Parameters:
basic Basic tile number
random Return random tile
filler Get a decorated tile.
Returns:
Tile number used in pud.
Todo:
FIXME: Solid tiles are here still hardcoded.

static void RecalculateShownUnits (  )  [static]

Recalculate the shown units.

static void ShowUnitInfo ( const CUnit unit  )  [static]

Show info about unit.

Parameters:
unit Unit pointer.

void StartEditor ( const char *  filename  ) 

Start the editor.

Start the editor

Parameters:
filename Map to load, NULL to create a new map


Variable Documentation

int ButtonPanelHeight [static]

int ButtonPanelWidth [static]

Icon height in panels.

std::deque<EditorAction> EditorRedoActions [static]

std::deque<EditorAction> EditorUndoActions [static]

int IconHeight [static]

Icon width in panels.

int IconWidth [static]

int MirrorEdit = 0 [static]

Update units on the minimap.

int TileCursorSize [static]

Tile tool draws with decorations.

char TileToolDecoration [static]

Tile tool draws random.

char TileToolRandom [static]

bool UnitPlacedThisPress = false [static]

Tile cursor size 1x1 2x2 ... 4x4.

bool UpdateMinimap = false [static]

Only allow one unit per press.

int VisibleTileIcons [static]

Number of icons that are visible at a time.

int VisibleUnitIcons [static]

Mirror editing enabled.

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