Rewrote UI buttons, added diplomacy button
This commit is contained in:
parent
871081f59f
commit
26ac55a673
12 changed files with 775 additions and 450 deletions
|
@ -901,24 +901,26 @@ global void EditorUpdateDisplay(void)
|
|||
//
|
||||
// Menu button
|
||||
//
|
||||
if (TheUI.MenuButton.Graphic) {
|
||||
VideoDrawSub(TheUI.MenuButton.Graphic, 0, 0,
|
||||
TheUI.MenuButton.Graphic->Width, TheUI.MenuButton.Graphic->Height,
|
||||
TheUI.MenuButtonX, TheUI.MenuButtonY);
|
||||
if (TheUI.MenuButtonGraphic.Graphic) {
|
||||
VideoDrawSub(TheUI.MenuButtonGraphic.Graphic, 0, 0,
|
||||
TheUI.MenuButtonGraphic.Graphic->Width,
|
||||
TheUI.MenuButtonGraphic.Graphic->Height,
|
||||
TheUI.MenuButtonGraphicX, TheUI.MenuButtonGraphicY);
|
||||
}
|
||||
DrawMenuButton(MBUTTON_MAIN,
|
||||
(ButtonUnderCursor == 0 ? MenuButtonActive : 0)|
|
||||
DrawMenuButton(TheUI.MenuButton.Button,
|
||||
(ButtonAreaUnderCursor == ButtonAreaMenu
|
||||
&& ButtonUnderCursor == 0 ? MenuButtonActive : 0) |
|
||||
(GameMenuButtonClicked ? MenuButtonClicked : 0),
|
||||
128, 19,
|
||||
TheUI.MenuButtonX+24,TheUI.MenuButtonY+2,
|
||||
GameFont,"Menu (~<F10~>)",NULL,NULL);
|
||||
TheUI.MenuButton.Width, TheUI.MenuButton.Height,
|
||||
TheUI.MenuButton.X,TheUI.MenuButton.Y,
|
||||
GameFont,TheUI.MenuButton.Text,NULL,NULL);
|
||||
|
||||
//
|
||||
// Minimap border
|
||||
//
|
||||
if (TheUI.Minimap.Graphic) {
|
||||
VideoDrawSub(TheUI.Minimap.Graphic, 0, 0, TheUI.Minimap.Graphic->Width,
|
||||
TheUI.Minimap.Graphic->Height, TheUI.MinimapX, TheUI.MinimapY);
|
||||
TheUI.Minimap.Graphic->Height, TheUI.MinimapX, TheUI.MinimapY);
|
||||
}
|
||||
//
|
||||
// Minimap
|
||||
|
@ -1713,18 +1715,17 @@ local void EditorCallbackMouse(int x, int y)
|
|||
SetStatusLine("Tile mode");
|
||||
return;
|
||||
}
|
||||
for (i = 0; i < (int)(sizeof(TheUI.Buttons)/sizeof(*TheUI.Buttons)); ++i) {
|
||||
if (x < TheUI.Buttons[i].X
|
||||
|| x > TheUI.Buttons[i].X + TheUI.Buttons[i].Width
|
||||
|| y < TheUI.Buttons[i].Y
|
||||
|| y > TheUI.Buttons[i].Y + TheUI.Buttons[i].Height) {
|
||||
continue;
|
||||
if( TheUI.MenuButton.X!=-1 ) {
|
||||
if( x>=TheUI.MenuButton.X
|
||||
&& x<=TheUI.MenuButton.X+TheUI.MenuButton.Width
|
||||
&& y>TheUI.MenuButton.Y
|
||||
&& y<=TheUI.MenuButton.Y+TheUI.MenuButton.Height ) {
|
||||
ButtonAreaUnderCursor=ButtonAreaMenu;
|
||||
ButtonUnderCursor=ButtonUnderMenu;
|
||||
CursorOn=CursorOnButton;
|
||||
MustRedraw|=RedrawMenuButton;
|
||||
return;
|
||||
}
|
||||
DebugLevel3("On button %d\n" _C_ i);
|
||||
ButtonUnderCursor = i;
|
||||
CursorOn = CursorOnButton;
|
||||
ClearStatusLine();
|
||||
return;
|
||||
}
|
||||
|
||||
//
|
||||
|
|
|
@ -85,6 +85,21 @@ struct _button_action_ {
|
|||
char* UnitMask; /// for which units is it available
|
||||
};
|
||||
|
||||
/// Button area under cursor
|
||||
enum _button_area_ {
|
||||
ButtonAreaInfo, /// Info panel button
|
||||
ButtonAreaTraining, /// Training button
|
||||
ButtonAreaButton, /// Button panel button
|
||||
ButtonAreaMenu, /// Menu button
|
||||
};
|
||||
|
||||
/// Menu button under cursor
|
||||
enum _menu_button_under_ {
|
||||
ButtonUnderMenu, /// Menu button
|
||||
ButtonUnderNetworkMenu, /// Network menu button
|
||||
ButtonUnderNetworkDiplomacy, /// Diplomacy button
|
||||
};
|
||||
|
||||
/// current interface state
|
||||
enum _iface_state_ {
|
||||
IfaceStateNormal, /// Normal Game state
|
||||
|
@ -232,10 +247,14 @@ extern enum _scroll_state_ MouseScrollState;
|
|||
extern enum _key_state_ KeyState;
|
||||
/// pointer to unit under the cursor
|
||||
extern Unit* UnitUnderCursor;
|
||||
/// button area under the cursor
|
||||
extern int ButtonAreaUnderCursor;
|
||||
/// button number under the cursor
|
||||
extern int ButtonUnderCursor;
|
||||
/// button 0 (Game Menu) was clicked down
|
||||
/// menu button was clicked down
|
||||
extern char GameMenuButtonClicked;
|
||||
/// diplomacy button was clicked down
|
||||
extern char GameDiplomacyButtonClicked;
|
||||
/// Mouse leaves windows stops scroll
|
||||
extern char LeaveStops;
|
||||
/// current CursorOn field
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
//
|
||||
/**@name menus.h - The menu headerfile. */
|
||||
//
|
||||
// (c) Copyright 1999-2003 by Andreas Arens
|
||||
// (c) Copyright 1999-2003 by Andreas Arens and Jimmy Salmon
|
||||
//
|
||||
// FreeCraft is free software; you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published
|
||||
|
@ -60,6 +60,7 @@ typedef int MenuButtonId;
|
|||
/// FIXME: FILL IN THIS TABLE!!!!
|
||||
|
||||
#define MBUTTON_MAIN 4 /// FIXME: write docu
|
||||
#define MBUTTON_NETWORK 7
|
||||
#define MBUTTON_GM_HALF 10
|
||||
#define MBUTTON_132 13
|
||||
#define MBUTTON_GM_FULL 16
|
||||
|
@ -329,6 +330,9 @@ extern _MenuFuncHash MenuFuncHash;
|
|||
-- Functions
|
||||
----------------------------------------------------------------------------*/
|
||||
|
||||
/// Menu button style to char*
|
||||
extern char *MenuButtonStyle(int style);
|
||||
|
||||
/// Initialize the hash tables for the menus
|
||||
extern void InitMenuFuncHash(void);
|
||||
|
||||
|
|
|
@ -229,10 +229,22 @@ typedef struct _ui_ {
|
|||
// Map* attributes of Viewport are unused here:
|
||||
Viewport MapArea; /// geometry of the whole map area
|
||||
|
||||
// The menu button
|
||||
GraphicConfig MenuButton; /// menu button background
|
||||
int MenuButtonX; /// menu button screen X position
|
||||
int MenuButtonY; /// menu button screen Y position
|
||||
// The menu button graphic
|
||||
GraphicConfig MenuButtonGraphic; /// menu button background
|
||||
int MenuButtonGraphicX; /// menu button screen X position
|
||||
int MenuButtonGraphicY; /// menu button screen Y position
|
||||
|
||||
/// Menu buttons
|
||||
struct {
|
||||
int X; /// button screen X position
|
||||
int Y; /// button screen Y position
|
||||
char* Text; /// button caption
|
||||
int Width; /// button width
|
||||
int Height; /// button height
|
||||
int Button; /// button style
|
||||
} MenuButton,
|
||||
NetworkMenuButton,
|
||||
NetworkDiplomacyButton;
|
||||
|
||||
// The minimap
|
||||
GraphicConfig Minimap; /// minimap panel background
|
||||
|
@ -245,10 +257,12 @@ typedef struct _ui_ {
|
|||
int StatusLineX; /// status line screeen X position
|
||||
int StatusLineY; /// status line screeen Y position
|
||||
|
||||
/// all buttons (1 Menu, 9 Group, 9 Command)
|
||||
Button Buttons[MaxButtons];
|
||||
/// used for displaying unit training queues
|
||||
Button Buttons2[6];
|
||||
Button* InfoButtons; /// Info buttons
|
||||
int NumInfoButtons; /// Number of info buttons
|
||||
Button* TrainingButtons; /// Training buttons
|
||||
int NumTrainingButtons; /// Number of training buttons
|
||||
Button* ButtonButtons; /// Button panel buttons
|
||||
int NumButtonButtons; /// Number of button panel buttons
|
||||
|
||||
// Offsets for 640x480 center used by menus
|
||||
int Offset640X; /// Offset for 640x480 X position
|
||||
|
|
|
@ -98,11 +98,11 @@ local void MoveMapViewPointUp(int step)
|
|||
{
|
||||
Viewport* vp;
|
||||
|
||||
vp = TheUI.SelectedViewport;
|
||||
if (vp->MapY > step) {
|
||||
vp->MapY -= step;
|
||||
vp=TheUI.SelectedViewport;
|
||||
if( vp->MapY>step ) {
|
||||
vp->MapY-=step;
|
||||
} else {
|
||||
vp->MapY = 0;
|
||||
vp->MapY=0;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -115,11 +115,11 @@ local void MoveMapViewPointLeft(int step)
|
|||
{
|
||||
Viewport* vp;
|
||||
|
||||
vp = TheUI.SelectedViewport;
|
||||
if (vp->MapX > step) {
|
||||
vp->MapX -= step;
|
||||
vp=TheUI.SelectedViewport;
|
||||
if( vp->MapX>step ) {
|
||||
vp->MapX-=step;
|
||||
} else {
|
||||
vp->MapX = 0;
|
||||
vp->MapX=0;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -132,12 +132,12 @@ local void MoveMapViewPointDown(int step)
|
|||
{
|
||||
Viewport* vp;
|
||||
|
||||
vp = TheUI.SelectedViewport;
|
||||
if (TheMap.Height > vp->MapHeight
|
||||
&& vp->MapY < TheMap.Height - vp->MapHeight - step) {
|
||||
vp->MapY += step;
|
||||
vp=TheUI.SelectedViewport;
|
||||
if( TheMap.Height>vp->MapHeight
|
||||
&& vp->MapY<TheMap.Height-vp->MapHeight-step ) {
|
||||
vp->MapY+=step;
|
||||
} else {
|
||||
vp->MapY = TheMap.Height - vp->MapHeight;
|
||||
vp->MapY=TheMap.Height-vp->MapHeight;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -150,12 +150,12 @@ local void MoveMapViewPointRight(int step)
|
|||
{
|
||||
Viewport* vp;
|
||||
|
||||
vp = TheUI.SelectedViewport;
|
||||
if (TheMap.Width > vp->MapWidth
|
||||
&& vp->MapX < TheMap.Width - vp->MapWidth - step) {
|
||||
vp->MapX += step;
|
||||
vp=TheUI.SelectedViewport;
|
||||
if( TheMap.Width>vp->MapWidth
|
||||
&& vp->MapX<TheMap.Width-vp->MapWidth-step) {
|
||||
vp->MapX+=step;
|
||||
} else {
|
||||
vp->MapX = TheMap.Width - vp->MapWidth;
|
||||
vp->MapX=TheMap.Width-vp->MapWidth;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -178,14 +178,14 @@ global void DoScrollArea(enum _scroll_state_ state, int fast)
|
|||
int stepx;
|
||||
int stepy;
|
||||
|
||||
if (fast) {
|
||||
stepx = TheUI.SelectedViewport->MapWidth / 2;
|
||||
stepy = TheUI.SelectedViewport->MapHeight / 2;
|
||||
if( fast ) {
|
||||
stepx=TheUI.SelectedViewport->MapWidth/2;
|
||||
stepy=TheUI.SelectedViewport->MapHeight/2;
|
||||
} else { // dynamic: let these variables increase upto fast..
|
||||
stepx = stepy = 1;
|
||||
stepx=stepy=1;
|
||||
}
|
||||
|
||||
switch (state) {
|
||||
switch( state ) {
|
||||
case ScrollUp:
|
||||
MoveMapViewPointUp(stepy);
|
||||
break;
|
||||
|
@ -217,9 +217,9 @@ global void DoScrollArea(enum _scroll_state_ state, int fast)
|
|||
default:
|
||||
return; // skip marking map
|
||||
}
|
||||
HandleMouseMove(CursorX, CursorY); // This recalulates some values
|
||||
HandleMouseMove(CursorX,CursorY); // This recalulates some values
|
||||
MarkDrawEntireMap();
|
||||
MustRedraw |= RedrawMinimap | RedrawCursors;
|
||||
MustRedraw|=RedrawMinimap|RedrawCursors;
|
||||
}
|
||||
|
||||
#ifdef DEBUG // {
|
||||
|
@ -232,13 +232,13 @@ global void DoScrollArea(enum _scroll_state_ state, int fast)
|
|||
*/
|
||||
global void DebugTestDisplay(void)
|
||||
{
|
||||
static int a = 0;
|
||||
static int a=0;
|
||||
extern void DebugTestDisplayLines(void);
|
||||
|
||||
if (a) {
|
||||
if( a ) {
|
||||
return;
|
||||
}
|
||||
a = 1;
|
||||
a=1;
|
||||
|
||||
//Enable one function-call as type of test to show one time
|
||||
DebugTestDisplayLines();
|
||||
|
@ -246,7 +246,7 @@ global void DebugTestDisplay(void)
|
|||
//DebugTestDisplayColorCube();
|
||||
|
||||
// put it all on screen (when it is not already there ;)
|
||||
InvalidateArea(0, 0, VideoWidth, VideoHeight);
|
||||
InvalidateArea(0,0,VideoWidth,VideoHeight);
|
||||
}
|
||||
|
||||
#endif // } DEBUG
|
||||
|
@ -260,17 +260,42 @@ global void DebugTestDisplay(void)
|
|||
*/
|
||||
local void DrawMenuButtonArea(void)
|
||||
{
|
||||
VideoDrawSub(TheUI.MenuButton.Graphic,0,0
|
||||
,TheUI.MenuButton.Graphic->Width
|
||||
,TheUI.MenuButton.Graphic->Height
|
||||
,TheUI.MenuButtonX,TheUI.MenuButtonY);
|
||||
|
||||
DrawMenuButton(MBUTTON_MAIN,
|
||||
(ButtonUnderCursor == 0 ? MenuButtonActive : 0)|
|
||||
(GameMenuButtonClicked ? MenuButtonClicked : 0),
|
||||
128, 19,
|
||||
TheUI.MenuButtonX+24,TheUI.MenuButtonY+2,
|
||||
GameFont,"Menu (~<F10~>)",NULL,NULL);
|
||||
if (TheUI.MenuButtonGraphic.Graphic) {
|
||||
VideoDrawSub(TheUI.MenuButtonGraphic.Graphic,0,0,
|
||||
TheUI.MenuButtonGraphic.Graphic->Width,
|
||||
TheUI.MenuButtonGraphic.Graphic->Height,
|
||||
TheUI.MenuButtonGraphicX, TheUI.MenuButtonGraphicY);
|
||||
}
|
||||
if( NetworkFildes==-1 ) {
|
||||
if( TheUI.MenuButton.X!=-1 ) {
|
||||
DrawMenuButton(TheUI.MenuButton.Button,
|
||||
(ButtonAreaUnderCursor==ButtonAreaMenu
|
||||
&& ButtonUnderCursor==ButtonUnderMenu ? MenuButtonActive : 0) |
|
||||
(GameMenuButtonClicked ? MenuButtonClicked : 0),
|
||||
TheUI.MenuButton.Width, TheUI.MenuButton.Height,
|
||||
TheUI.MenuButton.X,TheUI.MenuButton.Y,
|
||||
GameFont,TheUI.MenuButton.Text,NULL,NULL);
|
||||
}
|
||||
} else {
|
||||
if( TheUI.NetworkMenuButton.X!=-1 ) {
|
||||
DrawMenuButton(TheUI.NetworkMenuButton.Button,
|
||||
(ButtonAreaUnderCursor==ButtonAreaMenu
|
||||
&& ButtonUnderCursor==ButtonUnderNetworkMenu ? MenuButtonActive : 0) |
|
||||
(GameMenuButtonClicked ? MenuButtonClicked : 0),
|
||||
TheUI.NetworkMenuButton.Width, TheUI.NetworkMenuButton.Height,
|
||||
TheUI.NetworkMenuButton.X,TheUI.NetworkMenuButton.Y,
|
||||
GameFont,TheUI.NetworkMenuButton.Text,NULL,NULL);
|
||||
}
|
||||
if( TheUI.NetworkDiplomacyButton.X!=-1 ) {
|
||||
DrawMenuButton(TheUI.NetworkDiplomacyButton.Button,
|
||||
(ButtonAreaUnderCursor==ButtonAreaMenu
|
||||
&& ButtonUnderCursor==ButtonUnderNetworkDiplomacy ? MenuButtonActive : 0) |
|
||||
(GameDiplomacyButtonClicked ? MenuButtonClicked : 0),
|
||||
TheUI.NetworkDiplomacyButton.Width, TheUI.NetworkDiplomacyButton.Height,
|
||||
TheUI.NetworkDiplomacyButton.X,TheUI.NetworkDiplomacyButton.Y,
|
||||
GameFont,TheUI.NetworkDiplomacyButton.Text,NULL,NULL);
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef DRAW_DEBUG
|
||||
//
|
||||
|
@ -342,13 +367,13 @@ local void DrawMapViewport(Viewport* vp)
|
|||
// overlapping and draw only that what has changed..
|
||||
// Every to-be-drawn item added to this mechanism, can be handed by this
|
||||
// call.
|
||||
if (InterfaceState == IfaceStateNormal) {
|
||||
if( InterfaceState==IfaceStateNormal ) {
|
||||
// DecorationRefreshDisplay();
|
||||
DecorationUpdateDisplay();
|
||||
}
|
||||
|
||||
#else
|
||||
if (InterfaceState == IfaceStateNormal) {
|
||||
if( InterfaceState==IfaceStateNormal ) {
|
||||
#ifdef NEW_MAPDRAW
|
||||
MapUpdateFogOfWar(vp->MapX, vp->MapY);
|
||||
#else
|
||||
|
@ -366,27 +391,27 @@ local void DrawMapViewport(Viewport* vp)
|
|||
//
|
||||
// An unit is tracked, center viewport on this unit.
|
||||
//
|
||||
if (vp->Unit) {
|
||||
if (vp->Unit->Destroyed ||
|
||||
vp->Unit->Orders[0].Action == UnitActionDie) {
|
||||
vp->Unit = NoUnitP;
|
||||
if( vp->Unit ) {
|
||||
if( vp->Unit->Destroyed ||
|
||||
vp->Unit->Orders[0].Action==UnitActionDie ) {
|
||||
vp->Unit=NoUnitP;
|
||||
} else {
|
||||
ViewportCenterViewpoint(vp, vp->Unit->X, vp->Unit->Y);
|
||||
ViewportCenterViewpoint(vp,vp->Unit->X,vp->Unit->Y);
|
||||
}
|
||||
}
|
||||
|
||||
SetClipping(vp->X, vp->Y, vp->EndX, vp->EndY);
|
||||
SetClipping(vp->X,vp->Y,vp->EndX,vp->EndY);
|
||||
|
||||
DrawMapBackgroundInViewport(vp, vp->MapX, vp->MapY);
|
||||
nunits = FindAndSortUnits(vp,table);
|
||||
nmissiles = FindAndSortMissiles(vp, missiletable);
|
||||
|
||||
i = 0;
|
||||
j = 0;
|
||||
CurrentViewport = vp;
|
||||
while( i < nunits && j < nmissiles ) {
|
||||
DrawMapBackgroundInViewport(vp,vp->MapX,vp->MapY);
|
||||
nunits=FindAndSortUnits(vp,table);
|
||||
nmissiles=FindAndSortMissiles(vp,missiletable);
|
||||
|
||||
i=0;
|
||||
j=0;
|
||||
CurrentViewport=vp;
|
||||
while( i<nunits && j<nmissiles ) {
|
||||
if( table[i]->Type->DrawLevel <= missiletable[j]->Type->DrawLevel ) {
|
||||
if ( UnitVisibleInViewport(vp, table[i]) ) {
|
||||
if( UnitVisibleInViewport(vp,table[i]) ) {
|
||||
if( table[i]->Type->Building ) {
|
||||
DrawBuilding(table[i]);
|
||||
} else {
|
||||
|
@ -413,7 +438,7 @@ local void DrawMapViewport(Viewport* vp)
|
|||
j++;
|
||||
}
|
||||
}
|
||||
for( ; i < nunits; i++ ) {
|
||||
for( ; i<nunits; ++i ) {
|
||||
if ( UnitVisibleInViewport(vp, table[i]) ) {
|
||||
if( table[i]->Type->Building ) {
|
||||
DrawBuilding(table[i]);
|
||||
|
@ -422,7 +447,7 @@ local void DrawMapViewport(Viewport* vp)
|
|||
}
|
||||
}
|
||||
}
|
||||
for( ; j < nmissiles; j++ ) {
|
||||
for( ; j<nmissiles; ++j ) {
|
||||
x = missiletable[j]->X - vp->MapX * TileSizeX + vp->X;
|
||||
y = missiletable[j]->Y - vp->MapY * TileSizeY + vp->Y;
|
||||
// FIXME: I should copy SourcePlayer for second level missiles.
|
||||
|
@ -447,9 +472,9 @@ local void DrawMapViewport(Viewport* vp)
|
|||
// Resources over map!
|
||||
// FIXME: trick17! must find a better solution
|
||||
// FIXME: must take resource end into account
|
||||
if (TheUI.MapArea.X<=TheUI.ResourceX && TheUI.MapArea.EndX>=TheUI.ResourceX
|
||||
if( TheUI.MapArea.X<=TheUI.ResourceX && TheUI.MapArea.EndX>=TheUI.ResourceX
|
||||
&& TheUI.MapArea.Y<=TheUI.ResourceY
|
||||
&& TheUI.MapArea.EndY>=TheUI.ResourceY) {
|
||||
&& TheUI.MapArea.EndY>=TheUI.ResourceY ) {
|
||||
MustRedraw|=RedrawResources;
|
||||
}
|
||||
#endif
|
||||
|
@ -467,26 +492,26 @@ global void DrawMapArea(void)
|
|||
const Viewport* evp;
|
||||
|
||||
// Draw all map viewports
|
||||
evp = TheUI.Viewports + TheUI.NumViewports;
|
||||
for (vp = TheUI.Viewports; vp < evp; vp++) {
|
||||
evp=TheUI.Viewports+TheUI.NumViewports;
|
||||
for( vp=TheUI.Viewports; vp<evp; ++vp) {
|
||||
DrawMapViewport(vp);
|
||||
}
|
||||
|
||||
// if we a single viewport, no need to denote the "selected" one
|
||||
if (TheUI.NumViewports == 1) {
|
||||
if( TheUI.NumViewports==1 ) {
|
||||
return;
|
||||
}
|
||||
|
||||
//
|
||||
// Separate the viewports and mark the active viewport.
|
||||
//
|
||||
for (vp = TheUI.Viewports; vp < evp; vp++) {
|
||||
for( vp=TheUI.Viewports; vp<evp; ++vp ) {
|
||||
enum _sys_colors_ color;
|
||||
|
||||
if (vp == TheUI.SelectedViewport) {
|
||||
color = ColorOrange;
|
||||
if( vp==TheUI.SelectedViewport ) {
|
||||
color=ColorOrange;
|
||||
} else {
|
||||
color = ColorBlack;
|
||||
color=ColorBlack;
|
||||
}
|
||||
|
||||
// -
|
||||
|
@ -550,7 +575,7 @@ global void UpdateDisplay(void)
|
|||
DrawMinimap(TheUI.SelectedViewport->MapX, TheUI.SelectedViewport->MapY);
|
||||
DrawMinimapCursor(TheUI.SelectedViewport->MapX,
|
||||
TheUI.SelectedViewport->MapY);
|
||||
} else if (MustRedraw&RedrawMinimapCursor) {
|
||||
} else if( MustRedraw&RedrawMinimapCursor ) {
|
||||
HideMinimapCursor();
|
||||
DrawMinimapCursor(TheUI.SelectedViewport->MapX,
|
||||
TheUI.SelectedViewport->MapY);
|
||||
|
@ -611,10 +636,29 @@ global void UpdateDisplay(void)
|
|||
}
|
||||
}
|
||||
if(MustRedraw&RedrawMenuButton ) {
|
||||
InvalidateAreaAndCheckCursor(
|
||||
TheUI.MenuButtonX,TheUI.MenuButtonY
|
||||
,TheUI.MenuButton.Graphic->Width
|
||||
,TheUI.MenuButton.Graphic->Height);
|
||||
if( NetworkFildes==-1 ) {
|
||||
if( TheUI.MenuButton.X!=-1 ) {
|
||||
InvalidateAreaAndCheckCursor(
|
||||
TheUI.MenuButton.X,TheUI.MenuButton.Y,
|
||||
TheUI.MenuButton.Width,
|
||||
TheUI.MenuButton.Height);
|
||||
}
|
||||
} else {
|
||||
if( TheUI.NetworkMenuButton.X!=-1 ) {
|
||||
InvalidateAreaAndCheckCursor(
|
||||
TheUI.NetworkMenuButton.X,
|
||||
TheUI.NetworkMenuButton.Y,
|
||||
TheUI.NetworkMenuButton.Width,
|
||||
TheUI.NetworkMenuButton.Height);
|
||||
}
|
||||
if( TheUI.NetworkDiplomacyButton.X!=-1 ) {
|
||||
InvalidateAreaAndCheckCursor(
|
||||
TheUI.NetworkDiplomacyButton.X,
|
||||
TheUI.NetworkDiplomacyButton.Y,
|
||||
TheUI.NetworkDiplomacyButton.Width,
|
||||
TheUI.NetworkDiplomacyButton.Height);
|
||||
}
|
||||
}
|
||||
}
|
||||
if( MustRedraw&RedrawMinimapBorder ) {
|
||||
InvalidateAreaAndCheckCursor(
|
||||
|
@ -720,14 +764,14 @@ global void GameMainLoop(void)
|
|||
|
||||
while( GameRunning ) {
|
||||
#if defined(DEBUG) && defined(HIERARCHIC_PATHFINDER)
|
||||
if (setjmp (MainLoopJmpBuf)) {
|
||||
if( setjmp(MainLoopJmpBuf) ) {
|
||||
GamePaused = 1;
|
||||
}
|
||||
#endif
|
||||
//
|
||||
// Game logic part
|
||||
//
|
||||
if (!GamePaused && NetworkInSync && !SkipGameCycle) {
|
||||
if( !GamePaused && NetworkInSync && !SkipGameCycle ) {
|
||||
SinglePlayerReplayEachCycle();
|
||||
if( !++GameCycle ) {
|
||||
// FIXME: tests with game cycle counter now fails :(
|
||||
|
|
|
@ -388,13 +388,14 @@ global void DrawButtonPanel(void)
|
|||
// FIXME: this is unneeded DrawUnitIcon does it self
|
||||
PlayerPixels(ThisPlayer); // could only select own units.
|
||||
|
||||
for( i=0; i<9; ++i ) {
|
||||
for( i=0; i<TheUI.NumButtonButtons; ++i ) {
|
||||
if( buttons[i].Pos!=-1 ) {
|
||||
int j;
|
||||
int action;
|
||||
|
||||
// cursor is on that button
|
||||
if( ButtonUnderCursor==i+10 ) {
|
||||
if( ButtonAreaUnderCursor==ButtonAreaButton
|
||||
&& ButtonUnderCursor==i ) {
|
||||
v=IconActive;
|
||||
if( MouseButtons&LeftButton ) {
|
||||
v=IconClicked;
|
||||
|
@ -493,12 +494,13 @@ global void DrawButtonPanel(void)
|
|||
}
|
||||
|
||||
DrawUnitIcon(ThisPlayer,buttons[i].Icon.Icon
|
||||
,v,TheUI.Buttons[i+10].X,TheUI.Buttons[i+10].Y);
|
||||
,v,TheUI.ButtonButtons[i].X,TheUI.ButtonButtons[i].Y);
|
||||
|
||||
//
|
||||
// Update status line for this button
|
||||
//
|
||||
if( ButtonUnderCursor==i+10 && KeyState!=KeyStateInput ) {
|
||||
if( ButtonAreaUnderCursor==ButtonAreaButton
|
||||
&& ButtonUnderCursor==i && KeyState!=KeyStateInput ) {
|
||||
SetStatusLine(buttons[i].Hint);
|
||||
// FIXME: Draw costs
|
||||
v=buttons[i].Value;
|
||||
|
@ -539,7 +541,7 @@ global void DrawButtonPanel(void)
|
|||
if( ShowCommandKey ) {
|
||||
Button* b;
|
||||
|
||||
b=&TheUI.Buttons[i+10];
|
||||
b=&TheUI.ButtonButtons[i];
|
||||
if( CurrentButtons[i].Key==27 ) {
|
||||
strcpy(buf,"ESC");
|
||||
VideoDrawText(b->X+4+b->Width-VideoTextLength(GameFont,buf),
|
||||
|
|
|
@ -188,10 +188,10 @@ global void DrawUnitInfo(const Unit* unit)
|
|||
//
|
||||
// Draw icon in upper left corner
|
||||
//
|
||||
x=TheUI.Buttons[1].X;
|
||||
y=TheUI.Buttons[1].Y;
|
||||
x=TheUI.InfoButtons[0].X;
|
||||
y=TheUI.InfoButtons[0].Y;
|
||||
DrawUnitIcon(unit->Player,type->Icon.Icon
|
||||
,(ButtonUnderCursor==1)
|
||||
,(ButtonAreaUnderCursor==ButtonAreaInfo && ButtonUnderCursor==0)
|
||||
? (IconActive|(MouseButtons&LeftButton)) : 0
|
||||
,x,y);
|
||||
UiDrawLifeBar(unit,x,y);
|
||||
|
@ -313,12 +313,12 @@ global void DrawUnitInfo(const Unit* unit)
|
|||
} else {
|
||||
VideoDrawTextCentered(x+114,y+8+29,GameFont,"Training...");
|
||||
|
||||
for( i = 0; i < unit->Data.Train.Count; i++ ) {
|
||||
for( i=0; i<unit->Data.Train.Count; ++i ) {
|
||||
DrawUnitIcon(unit->Player
|
||||
,unit->Data.Train.What[i]->Icon.Icon
|
||||
,(ButtonUnderCursor==i+4)
|
||||
,(ButtonAreaUnderCursor==ButtonAreaTraining && ButtonUnderCursor==i)
|
||||
? (IconActive|(MouseButtons&LeftButton)) : 0
|
||||
,TheUI.Buttons2[i].X,TheUI.Buttons2[i].Y);
|
||||
,TheUI.TrainingButtons[i].X,TheUI.TrainingButtons[i].Y);
|
||||
}
|
||||
|
||||
UiDrawCompleted(
|
||||
|
@ -431,16 +431,16 @@ global void DrawUnitInfo(const Unit* unit)
|
|||
if( unit->OnBoard[i]!=NoUnitP ) {
|
||||
DrawUnitIcon(unit->Player
|
||||
,unit->OnBoard[i]->Type->Icon.Icon
|
||||
,(ButtonUnderCursor==i+4)
|
||||
,(ButtonAreaUnderCursor==ButtonAreaInfo && ButtonUnderCursor==i+3)
|
||||
? (IconActive|(MouseButtons&LeftButton)) : 0
|
||||
,TheUI.Buttons[i+4].X,TheUI.Buttons[i+4].Y);
|
||||
,TheUI.InfoButtons[i+3].X,TheUI.InfoButtons[i+3].Y);
|
||||
UiDrawLifeBar(unit->OnBoard[i]
|
||||
,TheUI.Buttons[i+4].X,TheUI.Buttons[i+4].Y);
|
||||
,TheUI.InfoButtons[i+3].X,TheUI.InfoButtons[i+3].Y);
|
||||
if( unit->OnBoard[i]->Type->CanCastSpell ) {
|
||||
UiDrawManaBar(unit->OnBoard[i]
|
||||
,TheUI.Buttons[i+4].X,TheUI.Buttons[i+4].Y);
|
||||
,TheUI.InfoButtons[i+3].X,TheUI.InfoButtons[i+3].Y);
|
||||
}
|
||||
if( ButtonUnderCursor==i+4 ) {
|
||||
if( ButtonAreaUnderCursor==ButtonAreaInfo && ButtonUnderCursor==i+3 ) {
|
||||
if( unit->OnBoard[i]->Name ) {
|
||||
char buf[128];
|
||||
|
||||
|
@ -1125,13 +1125,14 @@ global void DrawInfoPanel(void)
|
|||
for( i=0; i<NumSelected; ++i ) {
|
||||
DrawUnitIcon(ThisPlayer
|
||||
,Selected[i]->Type->Icon.Icon
|
||||
,(ButtonUnderCursor==i+1)
|
||||
,(ButtonAreaUnderCursor==ButtonAreaInfo && ButtonUnderCursor==i)
|
||||
? (IconActive|(MouseButtons&LeftButton)) : 0
|
||||
,TheUI.Buttons[i+1].X,TheUI.Buttons[i+1].Y);
|
||||
,TheUI.InfoButtons[i].X,TheUI.InfoButtons[i].Y);
|
||||
UiDrawLifeBar(Selected[i]
|
||||
,TheUI.Buttons[i+1].X,TheUI.Buttons[i+1].Y);
|
||||
,TheUI.InfoButtons[i].X,TheUI.InfoButtons[i].Y);
|
||||
|
||||
if( ButtonUnderCursor==1+i ) {
|
||||
if( ButtonAreaUnderCursor==ButtonAreaInfo
|
||||
&& ButtonUnderCursor==i ) {
|
||||
if( Selected[i]->Name ) {
|
||||
char buf[128];
|
||||
|
||||
|
@ -1163,7 +1164,7 @@ global void DrawInfoPanel(void)
|
|||
}
|
||||
DrawInfoPanelBackground(i);
|
||||
DrawUnitInfo(Selected[0]);
|
||||
if( ButtonUnderCursor==1 ) {
|
||||
if( ButtonAreaUnderCursor==ButtonAreaInfo && ButtonUnderCursor==0 ) {
|
||||
if( Selected[0]->Name ) {
|
||||
char buf[128];
|
||||
|
||||
|
|
|
@ -157,46 +157,6 @@ local char *MenuHotKeyToStr(int key, char *buf)
|
|||
return buf;
|
||||
}
|
||||
|
||||
local char *MenuButtonStyle(int style)
|
||||
{
|
||||
switch (style) {
|
||||
case MBUTTON_MAIN:
|
||||
return "main";
|
||||
case MBUTTON_GM_HALF:
|
||||
return "gm-half";
|
||||
case MBUTTON_132:
|
||||
return "132";
|
||||
case MBUTTON_GM_FULL:
|
||||
return "gm-full";
|
||||
case MBUTTON_GEM_ROUND:
|
||||
return "gem-round";
|
||||
case MBUTTON_GEM_SQUARE:
|
||||
return "gem-square";
|
||||
case MBUTTON_UP_ARROW:
|
||||
return "up-arrow";
|
||||
case MBUTTON_DOWN_ARROW:
|
||||
return "down-arrow";
|
||||
case MBUTTON_LEFT_ARROW:
|
||||
return "left-arrow";
|
||||
case MBUTTON_RIGHT_ARROW:
|
||||
return "right-arrow";
|
||||
case MBUTTON_S_KNOB:
|
||||
return "s-knob";
|
||||
case MBUTTON_S_VCONT:
|
||||
return "s-vcont";
|
||||
case MBUTTON_S_HCONT:
|
||||
return "s-hcont";
|
||||
case MBUTTON_PULLDOWN:
|
||||
return "pulldown";
|
||||
case MBUTTON_VTHIN:
|
||||
return "vthin";
|
||||
case MBUTTON_FOLDER:
|
||||
return "folder";
|
||||
}
|
||||
fprintf(stderr,"MenuButtonStyle not found: %d\n", style);
|
||||
return "";
|
||||
}
|
||||
|
||||
/**
|
||||
** Save state of units to file.
|
||||
**
|
||||
|
|
|
@ -104,6 +104,51 @@ local int MenuButtonCurSel = -1;
|
|||
-- Menu operation functions
|
||||
----------------------------------------------------------------------------*/
|
||||
|
||||
/**
|
||||
** Convert menu button style to a string for saving.
|
||||
*/
|
||||
global char *MenuButtonStyle(int style)
|
||||
{
|
||||
switch (style) {
|
||||
case MBUTTON_MAIN:
|
||||
return "main";
|
||||
case MBUTTON_NETWORK:
|
||||
return "network";
|
||||
case MBUTTON_GM_HALF:
|
||||
return "gm-half";
|
||||
case MBUTTON_132:
|
||||
return "132";
|
||||
case MBUTTON_GM_FULL:
|
||||
return "gm-full";
|
||||
case MBUTTON_GEM_ROUND:
|
||||
return "gem-round";
|
||||
case MBUTTON_GEM_SQUARE:
|
||||
return "gem-square";
|
||||
case MBUTTON_UP_ARROW:
|
||||
return "up-arrow";
|
||||
case MBUTTON_DOWN_ARROW:
|
||||
return "down-arrow";
|
||||
case MBUTTON_LEFT_ARROW:
|
||||
return "left-arrow";
|
||||
case MBUTTON_RIGHT_ARROW:
|
||||
return "right-arrow";
|
||||
case MBUTTON_S_KNOB:
|
||||
return "s-knob";
|
||||
case MBUTTON_S_VCONT:
|
||||
return "s-vcont";
|
||||
case MBUTTON_S_HCONT:
|
||||
return "s-hcont";
|
||||
case MBUTTON_PULLDOWN:
|
||||
return "pulldown";
|
||||
case MBUTTON_VTHIN:
|
||||
return "vthin";
|
||||
case MBUTTON_FOLDER:
|
||||
return "folder";
|
||||
}
|
||||
fprintf(stderr,"MenuButtonStyle not found: %d\n", style);
|
||||
return "";
|
||||
}
|
||||
|
||||
/**
|
||||
** Find a menu by ident.
|
||||
**
|
||||
|
|
286
src/ui/mouse.cpp
286
src/ui/mouse.cpp
|
@ -61,8 +61,10 @@ global enum _mouse_buttons_ MouseButtons;/// Current pressed mouse buttons
|
|||
global enum _key_modifiers_ KeyModifiers;/// Current keyboard modifiers
|
||||
|
||||
global Unit* UnitUnderCursor; /// Unit under cursor
|
||||
global int ButtonAreaUnderCursor=-1; /// Button area under cursor
|
||||
global int ButtonUnderCursor=-1; /// Button under cursor
|
||||
global char GameMenuButtonClicked; /// Game menu button (F10) was clicked
|
||||
global char GameMenuButtonClicked; /// Menu button was clicked
|
||||
global char GameDiplomacyButtonClicked; /// Diplomacy button was clicked
|
||||
global char LeaveStops; /// Mouse leaves windows stops scroll
|
||||
|
||||
global enum _cursor_on_ CursorOn=CursorOnUnknown; /// Cursor on field
|
||||
|
@ -84,53 +86,6 @@ global void CancelBuildingMode(void)
|
|||
UpdateButtonPanel();
|
||||
}
|
||||
|
||||
#ifdef FLAG_DEBUG // { ARI: Disabled by introducing flag debug!
|
||||
/**
|
||||
** Draw information about the map.
|
||||
**
|
||||
** @param x Screen X position.
|
||||
** @param y Screen Y position.
|
||||
*/
|
||||
local void DrawMouseCoordsOnMap(int x,int y)
|
||||
{
|
||||
char buf[128];
|
||||
unsigned flags;
|
||||
|
||||
x = Viewport2MapX(TheUI.ActiveViewport, x);
|
||||
y = Viewport2MapY(TheUI.ActiveViewport, y);
|
||||
if( x<0 || y<0 || x>=TheMap.Width || y>=TheMap.Height ) {
|
||||
DebugLevel0Fn("coords outside map %d,%d\n" _C_ x _C_ y);
|
||||
return;
|
||||
}
|
||||
VideoLockScreen();
|
||||
VideoDrawSub(TheUI.MenuButton.Graphic,0,0
|
||||
,TheUI.MenuButton.Graphic->Width
|
||||
,TheUI.MenuButton.Graphic->Height
|
||||
,TheUI.MenuButtonX,TheUI.MenuButtonY);
|
||||
flags=TheMap.Fields[x+y*TheMap.Width].Flags;
|
||||
// sprintf(buf,"%3d,%3d=%02X|%04X|%c%c%c%c%c%c%c%c%c",x,y
|
||||
sprintf(buf,"%3d,%3d=%02X|%04X|%c%c%c%c%c%c%c",x,y
|
||||
,TheMap.Fields[x+y*TheMap.Width].Value
|
||||
,flags
|
||||
//,TheMap.Fields[x+y*TheMap.Width].Tile
|
||||
,flags&MapFieldUnpassable ?'u':'-'
|
||||
,flags&MapFieldNoBuilding ?'n':'-'
|
||||
,flags&MapFieldForest ?'f':'-'
|
||||
,flags&MapFieldWaterAllowed ?'w':'-'
|
||||
,flags&MapFieldCoastAllowed ?'c':'-'
|
||||
,flags&MapFieldLandAllowed ?'l':'-'
|
||||
,flags&MapFieldHuman ?'h':'-'
|
||||
// ,flags&MapFieldExplored ?'e':'-'
|
||||
// ,flags&MapFieldVisible ?'v':'-'
|
||||
);
|
||||
VideoDrawText(TheUI.MenuButtonX+3,TheUI.MenuButtonY+3,GameFont,buf);
|
||||
VideoUnlockScreen();
|
||||
InvalidateArea(TheUI.MenuButtonX,TheUI.MenuButtonY
|
||||
,TheUI.MenuButton.Graphic->Width
|
||||
,TheUI.MenuButton.Graphic->Height);
|
||||
}
|
||||
#endif // } FLAG_DEBUG
|
||||
|
||||
/**
|
||||
** Called when right button is pressed
|
||||
**
|
||||
|
@ -463,38 +418,96 @@ local void HandleMouseOn(int x,int y)
|
|||
//
|
||||
// Handle buttons
|
||||
//
|
||||
for( i=0; i<(int)(sizeof(TheUI.Buttons)/sizeof(*TheUI.Buttons)); ++i ) {
|
||||
if( x<TheUI.Buttons[i].X
|
||||
|| x>TheUI.Buttons[i].X+TheUI.Buttons[i].Width
|
||||
|| y<TheUI.Buttons[i].Y
|
||||
|| y>TheUI.Buttons[i].Y+TheUI.Buttons[i].Height ) {
|
||||
continue;
|
||||
}
|
||||
DebugLevel3("On button %d\n" _C_ i);
|
||||
ButtonUnderCursor=i;
|
||||
CursorOn=CursorOnButton;
|
||||
if( i<10 ) {
|
||||
if (i == 0) { // Menu button
|
||||
if( NetworkFildes==-1 ) {
|
||||
if( TheUI.MenuButton.X!=-1 ) {
|
||||
if( x>=TheUI.MenuButton.X
|
||||
&& x<=TheUI.MenuButton.X+TheUI.MenuButton.Width
|
||||
&& y>TheUI.MenuButton.Y
|
||||
&& y<=TheUI.MenuButton.Y+TheUI.MenuButton.Height ) {
|
||||
ButtonAreaUnderCursor=ButtonAreaMenu;
|
||||
ButtonUnderCursor=ButtonUnderMenu;
|
||||
CursorOn=CursorOnButton;
|
||||
MustRedraw|=RedrawMenuButton;
|
||||
} else {
|
||||
MustRedraw|=RedrawInfoPanel;
|
||||
return;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if( TheUI.NetworkMenuButton.X!=-1 ) {
|
||||
if( x>=TheUI.NetworkMenuButton.X
|
||||
&& x<=TheUI.NetworkMenuButton.X+TheUI.NetworkMenuButton.Width
|
||||
&& y>TheUI.NetworkMenuButton.Y
|
||||
&& y<=TheUI.NetworkMenuButton.Y+TheUI.NetworkMenuButton.Height ) {
|
||||
ButtonAreaUnderCursor=ButtonAreaMenu;
|
||||
ButtonUnderCursor=ButtonUnderNetworkMenu;
|
||||
CursorOn=CursorOnButton;
|
||||
MustRedraw|=RedrawMenuButton;
|
||||
return;
|
||||
}
|
||||
}
|
||||
if( TheUI.NetworkDiplomacyButton.X!=-1 ) {
|
||||
if( x>=TheUI.NetworkDiplomacyButton.X
|
||||
&& x<=TheUI.NetworkDiplomacyButton.X+TheUI.NetworkDiplomacyButton.Width
|
||||
&& y>TheUI.NetworkDiplomacyButton.Y
|
||||
&& y<=TheUI.NetworkDiplomacyButton.Y+TheUI.NetworkDiplomacyButton.Height ) {
|
||||
ButtonAreaUnderCursor=ButtonAreaMenu;
|
||||
ButtonUnderCursor=ButtonUnderNetworkDiplomacy;
|
||||
CursorOn=CursorOnButton;
|
||||
MustRedraw|=RedrawMenuButton;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
for( i=0; i<TheUI.NumButtonButtons; ++i ) {
|
||||
if( x>=TheUI.ButtonButtons[i].X
|
||||
&& x<=TheUI.ButtonButtons[i].X+TheUI.ButtonButtons[i].Width+7
|
||||
&& y>TheUI.ButtonButtons[i].Y
|
||||
&& y<=TheUI.ButtonButtons[i].Y+TheUI.ButtonButtons[i].Height+7 ) {
|
||||
ButtonAreaUnderCursor=ButtonAreaButton;
|
||||
ButtonUnderCursor=i;
|
||||
CursorOn=CursorOnButton;
|
||||
MustRedraw|=RedrawButtonPanel;
|
||||
return;
|
||||
}
|
||||
}
|
||||
if( NumSelected==1 && Selected[0]->Type->Building
|
||||
&& Selected[0]->Orders[0].Action==UnitActionTrain
|
||||
&& Selected[0]->Data.Train.Count>1 ) {
|
||||
for( i=0; i<TheUI.NumTrainingButtons; ++i ) {
|
||||
if( x>=TheUI.TrainingButtons[i].X
|
||||
&& x<=TheUI.TrainingButtons[i].X+TheUI.TrainingButtons[i].Width+7
|
||||
&& y>TheUI.TrainingButtons[i].Y
|
||||
&& y<=TheUI.TrainingButtons[i].Y+TheUI.TrainingButtons[i].Height+7 ) {
|
||||
ButtonAreaUnderCursor=ButtonAreaTraining;
|
||||
ButtonUnderCursor=i;
|
||||
CursorOn=CursorOnButton;
|
||||
MustRedraw|=RedrawButtonPanel;
|
||||
return;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for( i=0; i<TheUI.NumInfoButtons; ++i ) {
|
||||
if( x>=TheUI.InfoButtons[i].X
|
||||
&& x<=TheUI.InfoButtons[i].X+TheUI.InfoButtons[i].Width+7
|
||||
&& y>TheUI.InfoButtons[i].Y
|
||||
&& y<=TheUI.InfoButtons[i].Y+TheUI.InfoButtons[i].Height+7 ) {
|
||||
ButtonAreaUnderCursor=ButtonAreaInfo;
|
||||
ButtonUnderCursor=i;
|
||||
CursorOn=CursorOnButton;
|
||||
MustRedraw|=RedrawButtonPanel;
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
MustRedraw|=RedrawButtonPanel;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if( ButtonUnderCursor!=-1 ) { // remove old display
|
||||
if( ButtonUnderCursor<10 ) {
|
||||
if (ButtonUnderCursor == 0) { // Menu button
|
||||
MustRedraw|=RedrawMenuButton;
|
||||
} else {
|
||||
MustRedraw|=RedrawInfoPanel;
|
||||
}
|
||||
if( ButtonAreaUnderCursor==ButtonAreaMenu ) {
|
||||
MustRedraw|=RedrawMenuButton;
|
||||
} else if( ButtonAreaUnderCursor==ButtonAreaInfo ) {
|
||||
MustRedraw|=RedrawInfoPanel;
|
||||
} else {
|
||||
MustRedraw|=RedrawButtonPanel;
|
||||
}
|
||||
ButtonAreaUnderCursor=-1;
|
||||
ButtonUnderCursor=-1;
|
||||
}
|
||||
|
||||
|
@ -694,7 +707,7 @@ global void UIHandleMouseMove(int x,int y)
|
|||
//
|
||||
// User may be draging with button pressed.
|
||||
//
|
||||
if( GameMenuButtonClicked ) {
|
||||
if( GameMenuButtonClicked || GameDiplomacyButtonClicked ) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -767,10 +780,6 @@ global void UIHandleMouseMove(int x,int y)
|
|||
GameCursor=TheUI.Glass.Cursor;
|
||||
}
|
||||
|
||||
#ifdef FLAG_DEBUG // ARI: Disabled by introducing flag debug!
|
||||
IfDebug( DrawMouseCoordsOnMap(x,y); );
|
||||
#endif
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1255,8 +1264,8 @@ local void UISelectStateButtonDown(unsigned button __attribute__((unused)))
|
|||
|
||||
if( CursorOn==CursorOnButton ) {
|
||||
// FIXME: other buttons?
|
||||
if( ButtonUnderCursor>9 ) {
|
||||
DoButtonButtonClicked(ButtonUnderCursor-10);
|
||||
if( ButtonAreaUnderCursor==ButtonAreaButton ) {
|
||||
DoButtonButtonClicked(ButtonUnderCursor);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -1451,75 +1460,82 @@ global void UIHandleButtonDown(unsigned button)
|
|||
//
|
||||
// clicked on info panel - selection shown
|
||||
//
|
||||
if( NumSelected>1 && ButtonUnderCursor && ButtonUnderCursor<10 ) {
|
||||
if( NumSelected>1 && ButtonAreaUnderCursor==ButtonAreaInfo ) {
|
||||
if( !GameObserve && !GamePaused ) {
|
||||
DoSelectionButtons(ButtonUnderCursor-1,button);
|
||||
DoSelectionButtons(ButtonUnderCursor,button);
|
||||
}
|
||||
} else if( (MouseButtons&LeftButton) ) {
|
||||
//
|
||||
// clicked on menu button
|
||||
//
|
||||
if( ButtonUnderCursor==0 && !GameMenuButtonClicked ) {
|
||||
PlayGameSound(GameSounds.Click.Sound,MaxSampleVolume);
|
||||
GameMenuButtonClicked = 1;
|
||||
MustRedraw|=RedrawMenuButton;
|
||||
if( ButtonAreaUnderCursor==ButtonAreaMenu ) {
|
||||
if( (ButtonUnderCursor==ButtonUnderMenu
|
||||
|| ButtonUnderCursor==ButtonUnderNetworkMenu)
|
||||
&& !GameMenuButtonClicked ) {
|
||||
PlayGameSound(GameSounds.Click.Sound,MaxSampleVolume);
|
||||
GameMenuButtonClicked=1;
|
||||
MustRedraw|=RedrawMenuButton;
|
||||
} else if( ButtonUnderCursor==ButtonUnderNetworkDiplomacy
|
||||
&& !GameDiplomacyButtonClicked ) {
|
||||
PlayGameSound(GameSounds.Click.Sound,MaxSampleVolume);
|
||||
GameDiplomacyButtonClicked=1;
|
||||
MustRedraw|=RedrawMenuButton;
|
||||
}
|
||||
//
|
||||
// clicked on info panel - single unit shown
|
||||
// clicked on info panel
|
||||
//
|
||||
} else if( ButtonUnderCursor==1 && NumSelected==1 ) {
|
||||
PlayGameSound(GameSounds.Click.Sound,MaxSampleVolume);
|
||||
ViewportCenterViewpoint(TheUI.SelectedViewport, Selected[0]->X,
|
||||
Selected[0]->Y);
|
||||
//
|
||||
// clicked on info panel - single unit shown
|
||||
// for transporter - training queues
|
||||
//
|
||||
} else if( ButtonUnderCursor>3 && ButtonUnderCursor<10 ) {
|
||||
if( NumSelected==1 && Selected[0]->Type->Transporter ) {
|
||||
if( !GameObserve && !GamePaused ) {
|
||||
if( Selected[0]->OnBoard[ButtonUnderCursor-4] ) {
|
||||
// FIXME: should check if valid here.
|
||||
SendCommandUnload(Selected[0]
|
||||
,Selected[0]->X,Selected[0]->Y
|
||||
,Selected[0]->OnBoard[ButtonUnderCursor-4]
|
||||
,!(KeyModifiers&ModifierShift));
|
||||
} else if( ButtonAreaUnderCursor==ButtonAreaInfo ) {
|
||||
//
|
||||
// clicked on single unit shown
|
||||
//
|
||||
if( ButtonUnderCursor==0 && NumSelected==1 ) {
|
||||
PlayGameSound(GameSounds.Click.Sound,MaxSampleVolume);
|
||||
ViewportCenterViewpoint(TheUI.SelectedViewport, Selected[0]->X,
|
||||
Selected[0]->Y);
|
||||
//
|
||||
// for transporter
|
||||
//
|
||||
} else if( ButtonUnderCursor>2 && ButtonUnderCursor<9 ) {
|
||||
if( NumSelected==1 && Selected[0]->Type->Transporter ) {
|
||||
if( !GameObserve && !GamePaused ) {
|
||||
if( Selected[0]->OnBoard[ButtonUnderCursor-3] ) {
|
||||
// FIXME: should check if valid here.
|
||||
SendCommandUnload(Selected[0],
|
||||
Selected[0]->X,Selected[0]->Y,
|
||||
Selected[0]->OnBoard[ButtonUnderCursor-3],
|
||||
!(KeyModifiers&ModifierShift));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if( NumSelected==1 && Selected[0]->Type->Building &&
|
||||
Selected[0]->Orders[0].Action==UnitActionTrain) {
|
||||
if( !GameObserve && !GamePaused ) {
|
||||
int slotid = ButtonUnderCursor-4;
|
||||
if ( Selected[0]->Data.Train.Count == 1 ) {
|
||||
// FIXME: ignore clicks that did not hit
|
||||
// FIXME: with only one unit being built, this
|
||||
// unit is displayed between two slots.
|
||||
slotid = 0;
|
||||
}
|
||||
if ( slotid < Selected[0]->Data.Train.Count ) {
|
||||
DebugLevel0Fn("Cancel slot %d %s\n" _C_
|
||||
slotid _C_
|
||||
Selected[0]->Data.Train.What[slotid]
|
||||
->Ident);
|
||||
SendCommandCancelTraining(Selected[0],
|
||||
slotid,
|
||||
Selected[0]->Data.Train.What[slotid]);
|
||||
}
|
||||
//
|
||||
// clicked on training button
|
||||
//
|
||||
} else if( ButtonAreaUnderCursor==ButtonAreaTraining ) {
|
||||
if( !GameObserve && !GamePaused ) {
|
||||
if( ButtonUnderCursor<Selected[0]->Data.Train.Count ) {
|
||||
DebugLevel0Fn("Cancel slot %d %s\n" _C_
|
||||
ButtonUnderCursor _C_
|
||||
Selected[0]->Data.Train.What[ButtonUnderCursor]->Ident);
|
||||
SendCommandCancelTraining(Selected[0],
|
||||
ButtonUnderCursor,
|
||||
Selected[0]->Data.Train.What[ButtonUnderCursor]);
|
||||
}
|
||||
}
|
||||
//
|
||||
// clicked on button panel
|
||||
//
|
||||
} else if( ButtonUnderCursor>9 ) {
|
||||
} else if( ButtonAreaUnderCursor==ButtonAreaButton ) {
|
||||
if( !GameObserve && !GamePaused ) {
|
||||
DoButtonButtonClicked(ButtonUnderCursor-10);
|
||||
DoButtonButtonClicked(ButtonUnderCursor);
|
||||
}
|
||||
}
|
||||
} else if( (MouseButtons&MiddleButton) ) {
|
||||
//
|
||||
// clicked on info panel - single unit shown
|
||||
//
|
||||
if( ButtonUnderCursor==1 && NumSelected==1 ) {
|
||||
if( ButtonAreaUnderCursor==ButtonAreaInfo
|
||||
&& ButtonUnderCursor==0 && NumSelected==1 ) {
|
||||
PlayGameSound(GameSounds.Click.Sound,MaxSampleVolume);
|
||||
if( TheUI.SelectedViewport->Unit == Selected[0] ) {
|
||||
TheUI.SelectedViewport->Unit = NULL;
|
||||
|
@ -1550,10 +1566,12 @@ global void UIHandleButtonUp(unsigned button)
|
|||
//
|
||||
// Menu (F10) button
|
||||
//
|
||||
if( (1<<button) == LeftButton && GameMenuButtonClicked == 1 ) {
|
||||
GameMenuButtonClicked = 0;
|
||||
if( (1<<button)==LeftButton && GameMenuButtonClicked ) {
|
||||
GameMenuButtonClicked=0;
|
||||
MustRedraw|=RedrawMenuButton;
|
||||
if( ButtonUnderCursor == 0 ) {
|
||||
if( ButtonAreaUnderCursor==ButtonAreaMenu
|
||||
&& (ButtonUnderCursor==ButtonUnderMenu
|
||||
|| ButtonUnderCursor==ButtonUnderNetworkMenu) ) {
|
||||
// FIXME: Not if, in input mode.
|
||||
if( NetworkFildes==-1 ) {
|
||||
GamePaused=1;
|
||||
|
@ -1564,6 +1582,20 @@ global void UIHandleButtonUp(unsigned button)
|
|||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Diplomacy button
|
||||
//
|
||||
if( (1<<button)==LeftButton && GameDiplomacyButtonClicked ) {
|
||||
GameDiplomacyButtonClicked=0;
|
||||
MustRedraw|=RedrawMenuButton;
|
||||
if( ButtonAreaUnderCursor==ButtonAreaMenu
|
||||
&& ButtonUnderCursor==ButtonUnderNetworkDiplomacy) {
|
||||
// FIXME: Not if, in input mode.
|
||||
ProcessMenu("menu-diplomacy",0);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// FIXME: should be completly rewritten
|
||||
// FIXME: must selecting! (lokh: what does this mean? is this done now?)
|
||||
|
||||
|
|
|
@ -529,6 +529,86 @@ local SCM CclSetGameCursor(SCM ident)
|
|||
return SCM_UNSPECIFIED;
|
||||
}
|
||||
|
||||
/**
|
||||
** Define a menu item
|
||||
**
|
||||
** FIXME: need some general data structure to make this parsing easier.
|
||||
**
|
||||
** @param value Button type.
|
||||
*/
|
||||
local MenuButtonId scm2buttonid(SCM value)
|
||||
{
|
||||
MenuButtonId id;
|
||||
|
||||
if ( gh_eq_p(value, gh_symbol2scm("main")) ) {
|
||||
id=MBUTTON_MAIN;
|
||||
} else if ( gh_eq_p(value, gh_symbol2scm("network")) ) {
|
||||
id=MBUTTON_NETWORK;
|
||||
} else if ( gh_eq_p(value, gh_symbol2scm("gm-half")) ) {
|
||||
id=MBUTTON_GM_HALF;
|
||||
} else if ( gh_eq_p(value, gh_symbol2scm("132")) ) {
|
||||
id=MBUTTON_132;
|
||||
} else if ( gh_eq_p(value, gh_symbol2scm("gm-full")) ) {
|
||||
id=MBUTTON_GM_FULL;
|
||||
} else if ( gh_eq_p(value, gh_symbol2scm("gem-round")) ) {
|
||||
id=MBUTTON_GEM_ROUND;
|
||||
} else if ( gh_eq_p(value, gh_symbol2scm("gem-square")) ) {
|
||||
id=MBUTTON_GEM_SQUARE;
|
||||
} else if ( gh_eq_p(value, gh_symbol2scm("up-arrow")) ) {
|
||||
id=MBUTTON_UP_ARROW;
|
||||
} else if ( gh_eq_p(value, gh_symbol2scm("down-arrow")) ) {
|
||||
id=MBUTTON_DOWN_ARROW;
|
||||
} else if ( gh_eq_p(value, gh_symbol2scm("left-arrow")) ) {
|
||||
id=MBUTTON_LEFT_ARROW;
|
||||
} else if ( gh_eq_p(value, gh_symbol2scm("right-arrow")) ) {
|
||||
id=MBUTTON_RIGHT_ARROW;
|
||||
} else if ( gh_eq_p(value, gh_symbol2scm("s-knob")) ) {
|
||||
id=MBUTTON_S_KNOB;
|
||||
} else if ( gh_eq_p(value, gh_symbol2scm("s-vcont")) ) {
|
||||
id=MBUTTON_S_VCONT;
|
||||
} else if ( gh_eq_p(value, gh_symbol2scm("s-hcont")) ) {
|
||||
id=MBUTTON_S_HCONT;
|
||||
} else if ( gh_eq_p(value, gh_symbol2scm("pulldown")) ) {
|
||||
id=MBUTTON_PULLDOWN;
|
||||
} else if ( gh_eq_p(value, gh_symbol2scm("vthin")) ) {
|
||||
id=MBUTTON_VTHIN;
|
||||
} else if ( gh_eq_p(value, gh_symbol2scm("folder")) ) {
|
||||
id=MBUTTON_FOLDER;
|
||||
} else if ( gh_eq_p(value, gh_symbol2scm("sc-gem-round")) ) {
|
||||
id=MBUTTON_SC_GEM_ROUND;
|
||||
} else if ( gh_eq_p(value, gh_symbol2scm("sc-gem-square")) ) {
|
||||
id=MBUTTON_SC_GEM_SQUARE;
|
||||
} else if ( gh_eq_p(value, gh_symbol2scm("sc-up-arrow")) ) {
|
||||
id=MBUTTON_SC_UP_ARROW;
|
||||
} else if ( gh_eq_p(value, gh_symbol2scm("sc-down-arrow")) ) {
|
||||
id=MBUTTON_SC_DOWN_ARROW;
|
||||
} else if ( gh_eq_p(value, gh_symbol2scm("sc-left-arrow")) ) {
|
||||
id=MBUTTON_SC_LEFT_ARROW;
|
||||
} else if ( gh_eq_p(value, gh_symbol2scm("sc-right-arrow")) ) {
|
||||
id=MBUTTON_SC_RIGHT_ARROW;
|
||||
} else if ( gh_eq_p(value, gh_symbol2scm("sc-s-knob")) ) {
|
||||
id=MBUTTON_SC_S_KNOB;
|
||||
} else if ( gh_eq_p(value, gh_symbol2scm("sc-s-vcont")) ) {
|
||||
id=MBUTTON_SC_S_VCONT;
|
||||
} else if ( gh_eq_p(value, gh_symbol2scm("sc-s-hcont")) ) {
|
||||
id=MBUTTON_SC_S_HCONT;
|
||||
} else if ( gh_eq_p(value, gh_symbol2scm("sc-pulldown")) ) {
|
||||
id=MBUTTON_SC_PULLDOWN;
|
||||
} else if ( gh_eq_p(value, gh_symbol2scm("sc-button-left")) ) {
|
||||
id=MBUTTON_SC_BUTTON_LEFT;
|
||||
} else if ( gh_eq_p(value, gh_symbol2scm("sc-button")) ) {
|
||||
id=MBUTTON_SC_BUTTON;
|
||||
} else if ( gh_eq_p(value, gh_symbol2scm("sc-button-right")) ) {
|
||||
id=MBUTTON_SC_BUTTON_RIGHT;
|
||||
} else {
|
||||
char *s1=gh_scm2newstr(value, NULL);
|
||||
fprintf(stderr, "Unsupported button %s\n", s1);
|
||||
free(s1);
|
||||
return 0;
|
||||
}
|
||||
return id;
|
||||
}
|
||||
|
||||
/**
|
||||
** Define the look+feel of the user interface.
|
||||
**
|
||||
|
@ -896,10 +976,10 @@ local SCM CclDefineUI(SCM list)
|
|||
temp=gh_cdr(temp);
|
||||
y=gh_scm2int(value);
|
||||
|
||||
free(ui->MenuButton.File);
|
||||
ui->MenuButton.File=str;
|
||||
ui->MenuButtonX=x;
|
||||
ui->MenuButtonY=y;
|
||||
free(ui->MenuButtonGraphic.File);
|
||||
ui->MenuButtonGraphic.File=str;
|
||||
ui->MenuButtonGraphicX=x;
|
||||
ui->MenuButtonGraphicY=y;
|
||||
|
||||
// Minimap
|
||||
temp=gh_car(list);
|
||||
|
@ -950,61 +1030,203 @@ local SCM CclDefineUI(SCM list)
|
|||
ui->StatusLineY=y;
|
||||
|
||||
// Buttons
|
||||
for( i=0; i<MaxButtons; ++i ) {
|
||||
temp=gh_car(list);
|
||||
value=gh_car(list);
|
||||
list=gh_cdr(list);
|
||||
if( gh_eq_p(value,gh_symbol2scm("menu-button")) ) {
|
||||
sublist=gh_car(list);
|
||||
list=gh_cdr(list);
|
||||
|
||||
if( !gh_list_p(temp) ) {
|
||||
fprintf(stderr,"list expected\n");
|
||||
return SCM_UNSPECIFIED;
|
||||
while( !gh_null_p(sublist) ) {
|
||||
value=gh_car(sublist);
|
||||
sublist=gh_cdr(sublist);
|
||||
if( gh_eq_p(value,gh_symbol2scm("pos")) ) {
|
||||
value=gh_car(sublist);
|
||||
sublist=gh_cdr(sublist);
|
||||
ui->MenuButton.X=gh_scm2int(gh_car(value));
|
||||
ui->MenuButton.Y=gh_scm2int(gh_car(gh_cdr(value)));
|
||||
} else if( gh_eq_p(value,gh_symbol2scm("size")) ) {
|
||||
value=gh_car(sublist);
|
||||
sublist=gh_cdr(sublist);
|
||||
ui->MenuButton.Width=gh_scm2int(gh_car(value));
|
||||
ui->MenuButton.Height=gh_scm2int(gh_car(gh_cdr(value)));
|
||||
} else if( gh_eq_p(value,gh_symbol2scm("caption")) ) {
|
||||
value=gh_car(sublist);
|
||||
sublist=gh_cdr(sublist);
|
||||
ui->MenuButton.Text=gh_scm2newstr(value,NULL);
|
||||
} else if( gh_eq_p(value,gh_symbol2scm("style")) ) {
|
||||
value=gh_car(sublist);
|
||||
sublist=gh_cdr(sublist);
|
||||
ui->MenuButton.Button=scm2buttonid(value);
|
||||
} else {
|
||||
errl("Unsupported tag",value);
|
||||
}
|
||||
}
|
||||
value=gh_car(temp);
|
||||
temp=gh_cdr(temp);
|
||||
x=gh_scm2int(value);
|
||||
ui->Buttons[i].X=x;
|
||||
|
||||
value=gh_car(temp);
|
||||
temp=gh_cdr(temp);
|
||||
y=gh_scm2int(value);
|
||||
ui->Buttons[i].Y=y;
|
||||
|
||||
value=gh_car(temp);
|
||||
temp=gh_cdr(temp);
|
||||
x=gh_scm2int(value);
|
||||
ui->Buttons[i].Width=x;
|
||||
|
||||
value=gh_car(temp);
|
||||
temp=gh_cdr(temp);
|
||||
y=gh_scm2int(value);
|
||||
ui->Buttons[i].Height=y;
|
||||
}
|
||||
for( i=0; i<6; ++i ) {
|
||||
temp=gh_car(list);
|
||||
value=gh_car(list);
|
||||
list=gh_cdr(list);
|
||||
if( gh_eq_p(value,gh_symbol2scm("network-menu-button")) ) {
|
||||
sublist=gh_car(list);
|
||||
list=gh_cdr(list);
|
||||
|
||||
if( !gh_list_p(temp) ) {
|
||||
fprintf(stderr,"list expected\n");
|
||||
return SCM_UNSPECIFIED;
|
||||
while( !gh_null_p(sublist) ) {
|
||||
value=gh_car(sublist);
|
||||
sublist=gh_cdr(sublist);
|
||||
if( gh_eq_p(value,gh_symbol2scm("pos")) ) {
|
||||
value=gh_car(sublist);
|
||||
sublist=gh_cdr(sublist);
|
||||
ui->NetworkMenuButton.X=gh_scm2int(gh_car(value));
|
||||
ui->NetworkMenuButton.Y=gh_scm2int(gh_car(gh_cdr(value)));
|
||||
} else if( gh_eq_p(value,gh_symbol2scm("size")) ) {
|
||||
value=gh_car(sublist);
|
||||
sublist=gh_cdr(sublist);
|
||||
ui->NetworkMenuButton.Width=gh_scm2int(gh_car(value));
|
||||
ui->NetworkMenuButton.Height=gh_scm2int(gh_car(gh_cdr(value)));
|
||||
} else if( gh_eq_p(value,gh_symbol2scm("caption")) ) {
|
||||
value=gh_car(sublist);
|
||||
sublist=gh_cdr(sublist);
|
||||
ui->NetworkMenuButton.Text=gh_scm2newstr(value,NULL);
|
||||
} else if( gh_eq_p(value,gh_symbol2scm("style")) ) {
|
||||
value=gh_car(sublist);
|
||||
sublist=gh_cdr(sublist);
|
||||
ui->NetworkMenuButton.Button=scm2buttonid(value);
|
||||
} else {
|
||||
errl("Unsupported tag",value);
|
||||
}
|
||||
}
|
||||
value=gh_car(temp);
|
||||
temp=gh_cdr(temp);
|
||||
x=gh_scm2int(value);
|
||||
ui->Buttons2[i].X=x;
|
||||
}
|
||||
value=gh_car(list);
|
||||
list=gh_cdr(list);
|
||||
if( gh_eq_p(value,gh_symbol2scm("network-diplomacy-button")) ) {
|
||||
sublist=gh_car(list);
|
||||
list=gh_cdr(list);
|
||||
while( !gh_null_p(sublist) ) {
|
||||
value=gh_car(sublist);
|
||||
sublist=gh_cdr(sublist);
|
||||
if( gh_eq_p(value,gh_symbol2scm("pos")) ) {
|
||||
value=gh_car(sublist);
|
||||
sublist=gh_cdr(sublist);
|
||||
ui->NetworkDiplomacyButton.X=gh_scm2int(gh_car(value));
|
||||
ui->NetworkDiplomacyButton.Y=gh_scm2int(gh_car(gh_cdr(value)));
|
||||
} else if( gh_eq_p(value,gh_symbol2scm("size")) ) {
|
||||
value=gh_car(sublist);
|
||||
sublist=gh_cdr(sublist);
|
||||
ui->NetworkDiplomacyButton.Width=gh_scm2int(gh_car(value));
|
||||
ui->NetworkDiplomacyButton.Height=gh_scm2int(gh_car(gh_cdr(value)));
|
||||
} else if( gh_eq_p(value,gh_symbol2scm("caption")) ) {
|
||||
value=gh_car(sublist);
|
||||
sublist=gh_cdr(sublist);
|
||||
ui->NetworkDiplomacyButton.Text=gh_scm2newstr(value,NULL);
|
||||
} else if( gh_eq_p(value,gh_symbol2scm("style")) ) {
|
||||
value=gh_car(sublist);
|
||||
sublist=gh_cdr(sublist);
|
||||
ui->NetworkDiplomacyButton.Button=scm2buttonid(value);
|
||||
} else {
|
||||
errl("Unsupported tag",value);
|
||||
}
|
||||
}
|
||||
}
|
||||
value=gh_car(list);
|
||||
list=gh_cdr(list);
|
||||
if( gh_eq_p(value,gh_symbol2scm("info-buttons")) ) {
|
||||
SCM slist;
|
||||
SCM sslist;
|
||||
Button* b;
|
||||
|
||||
value=gh_car(temp);
|
||||
temp=gh_cdr(temp);
|
||||
y=gh_scm2int(value);
|
||||
ui->Buttons2[i].Y=y;
|
||||
slist=gh_car(list);
|
||||
list=gh_cdr(list);
|
||||
while( !gh_null_p(slist) ) {
|
||||
sslist=gh_car(slist);
|
||||
slist=gh_cdr(slist);
|
||||
ui->NumInfoButtons++;
|
||||
ui->InfoButtons=realloc(ui->InfoButtons,
|
||||
ui->NumInfoButtons*sizeof(*ui->InfoButtons));
|
||||
b=&ui->InfoButtons[ui->NumInfoButtons-1];
|
||||
while( !gh_null_p(sslist) ) {
|
||||
value=gh_car(sslist);
|
||||
sslist=gh_cdr(sslist);
|
||||
if( gh_eq_p(value,gh_symbol2scm("pos")) ) {
|
||||
value=gh_car(sslist);
|
||||
sslist=gh_cdr(sslist);
|
||||
b->X=gh_scm2int(gh_car(value));
|
||||
b->Y=gh_scm2int(gh_car(gh_cdr(value)));
|
||||
} else if( gh_eq_p(value,gh_symbol2scm("size")) ) {
|
||||
value=gh_car(sslist);
|
||||
sslist=gh_cdr(sslist);
|
||||
b->Width=gh_scm2int(gh_car(value));
|
||||
b->Height=gh_scm2int(gh_car(gh_cdr(value)));
|
||||
} else {
|
||||
errl("Unsupported tag",value);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
value=gh_car(list);
|
||||
list=gh_cdr(list);
|
||||
if( gh_eq_p(value,gh_symbol2scm("training-buttons")) ) {
|
||||
SCM slist;
|
||||
SCM sslist;
|
||||
Button* b;
|
||||
|
||||
value=gh_car(temp);
|
||||
temp=gh_cdr(temp);
|
||||
x=gh_scm2int(value);
|
||||
ui->Buttons2[i].Width=x;
|
||||
slist=gh_car(list);
|
||||
list=gh_cdr(list);
|
||||
while( !gh_null_p(slist) ) {
|
||||
sslist=gh_car(slist);
|
||||
slist=gh_cdr(slist);
|
||||
ui->NumTrainingButtons++;
|
||||
ui->TrainingButtons=realloc(ui->TrainingButtons,
|
||||
ui->NumTrainingButtons*sizeof(*ui->TrainingButtons));
|
||||
b=&ui->TrainingButtons[ui->NumTrainingButtons-1];
|
||||
while( !gh_null_p(sslist) ) {
|
||||
value=gh_car(sslist);
|
||||
sslist=gh_cdr(sslist);
|
||||
if( gh_eq_p(value,gh_symbol2scm("pos")) ) {
|
||||
value=gh_car(sslist);
|
||||
sslist=gh_cdr(sslist);
|
||||
b->X=gh_scm2int(gh_car(value));
|
||||
b->Y=gh_scm2int(gh_car(gh_cdr(value)));
|
||||
} else if( gh_eq_p(value,gh_symbol2scm("size")) ) {
|
||||
value=gh_car(sslist);
|
||||
sslist=gh_cdr(sslist);
|
||||
b->Width=gh_scm2int(gh_car(value));
|
||||
b->Height=gh_scm2int(gh_car(gh_cdr(value)));
|
||||
} else {
|
||||
errl("Unsupported tag",value);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
value=gh_car(list);
|
||||
list=gh_cdr(list);
|
||||
if( gh_eq_p(value,gh_symbol2scm("button-buttons")) ) {
|
||||
SCM slist;
|
||||
SCM sslist;
|
||||
Button* b;
|
||||
|
||||
value=gh_car(temp);
|
||||
temp=gh_cdr(temp);
|
||||
y=gh_scm2int(value);
|
||||
ui->Buttons2[i].Height=y;
|
||||
slist=gh_car(list);
|
||||
list=gh_cdr(list);
|
||||
while( !gh_null_p(slist) ) {
|
||||
sslist=gh_car(slist);
|
||||
slist=gh_cdr(slist);
|
||||
ui->NumButtonButtons++;
|
||||
ui->ButtonButtons=realloc(ui->ButtonButtons,
|
||||
ui->NumButtonButtons*sizeof(*ui->ButtonButtons));
|
||||
b=&ui->ButtonButtons[ui->NumButtonButtons-1];
|
||||
while( !gh_null_p(sslist) ) {
|
||||
value=gh_car(sslist);
|
||||
sslist=gh_cdr(sslist);
|
||||
if( gh_eq_p(value,gh_symbol2scm("pos")) ) {
|
||||
value=gh_car(sslist);
|
||||
sslist=gh_cdr(sslist);
|
||||
b->X=gh_scm2int(gh_car(value));
|
||||
b->Y=gh_scm2int(gh_car(gh_cdr(value)));
|
||||
} else if( gh_eq_p(value,gh_symbol2scm("size")) ) {
|
||||
value=gh_car(sslist);
|
||||
sslist=gh_cdr(sslist);
|
||||
b->Width=gh_scm2int(gh_car(value));
|
||||
b->Height=gh_scm2int(gh_car(gh_cdr(value)));
|
||||
} else {
|
||||
errl("Unsupported tag",value);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
|
@ -1514,84 +1736,6 @@ local SCM CclDefineMenu(SCM list)
|
|||
return SCM_UNSPECIFIED;
|
||||
}
|
||||
|
||||
/**
|
||||
** Define a menu item
|
||||
**
|
||||
** FIXME: need some general data structure to make this parsing easier.
|
||||
**
|
||||
** @param value Button type.
|
||||
*/
|
||||
local MenuButtonId scm2buttonid(SCM value)
|
||||
{
|
||||
MenuButtonId id;
|
||||
|
||||
if ( gh_eq_p(value, gh_symbol2scm("main")) ) {
|
||||
id=MBUTTON_MAIN;
|
||||
} else if ( gh_eq_p(value, gh_symbol2scm("gm-half")) ) {
|
||||
id=MBUTTON_GM_HALF;
|
||||
} else if ( gh_eq_p(value, gh_symbol2scm("132")) ) {
|
||||
id=MBUTTON_132;
|
||||
} else if ( gh_eq_p(value, gh_symbol2scm("gm-full")) ) {
|
||||
id=MBUTTON_GM_FULL;
|
||||
} else if ( gh_eq_p(value, gh_symbol2scm("gem-round")) ) {
|
||||
id=MBUTTON_GEM_ROUND;
|
||||
} else if ( gh_eq_p(value, gh_symbol2scm("gem-square")) ) {
|
||||
id=MBUTTON_GEM_SQUARE;
|
||||
} else if ( gh_eq_p(value, gh_symbol2scm("up-arrow")) ) {
|
||||
id=MBUTTON_UP_ARROW;
|
||||
} else if ( gh_eq_p(value, gh_symbol2scm("down-arrow")) ) {
|
||||
id=MBUTTON_DOWN_ARROW;
|
||||
} else if ( gh_eq_p(value, gh_symbol2scm("left-arrow")) ) {
|
||||
id=MBUTTON_LEFT_ARROW;
|
||||
} else if ( gh_eq_p(value, gh_symbol2scm("right-arrow")) ) {
|
||||
id=MBUTTON_RIGHT_ARROW;
|
||||
} else if ( gh_eq_p(value, gh_symbol2scm("s-knob")) ) {
|
||||
id=MBUTTON_S_KNOB;
|
||||
} else if ( gh_eq_p(value, gh_symbol2scm("s-vcont")) ) {
|
||||
id=MBUTTON_S_VCONT;
|
||||
} else if ( gh_eq_p(value, gh_symbol2scm("s-hcont")) ) {
|
||||
id=MBUTTON_S_HCONT;
|
||||
} else if ( gh_eq_p(value, gh_symbol2scm("pulldown")) ) {
|
||||
id=MBUTTON_PULLDOWN;
|
||||
} else if ( gh_eq_p(value, gh_symbol2scm("vthin")) ) {
|
||||
id=MBUTTON_VTHIN;
|
||||
} else if ( gh_eq_p(value, gh_symbol2scm("folder")) ) {
|
||||
id=MBUTTON_FOLDER;
|
||||
} else if ( gh_eq_p(value, gh_symbol2scm("sc-gem-round")) ) {
|
||||
id=MBUTTON_SC_GEM_ROUND;
|
||||
} else if ( gh_eq_p(value, gh_symbol2scm("sc-gem-square")) ) {
|
||||
id=MBUTTON_SC_GEM_SQUARE;
|
||||
} else if ( gh_eq_p(value, gh_symbol2scm("sc-up-arrow")) ) {
|
||||
id=MBUTTON_SC_UP_ARROW;
|
||||
} else if ( gh_eq_p(value, gh_symbol2scm("sc-down-arrow")) ) {
|
||||
id=MBUTTON_SC_DOWN_ARROW;
|
||||
} else if ( gh_eq_p(value, gh_symbol2scm("sc-left-arrow")) ) {
|
||||
id=MBUTTON_SC_LEFT_ARROW;
|
||||
} else if ( gh_eq_p(value, gh_symbol2scm("sc-right-arrow")) ) {
|
||||
id=MBUTTON_SC_RIGHT_ARROW;
|
||||
} else if ( gh_eq_p(value, gh_symbol2scm("sc-s-knob")) ) {
|
||||
id=MBUTTON_SC_S_KNOB;
|
||||
} else if ( gh_eq_p(value, gh_symbol2scm("sc-s-vcont")) ) {
|
||||
id=MBUTTON_SC_S_VCONT;
|
||||
} else if ( gh_eq_p(value, gh_symbol2scm("sc-s-hcont")) ) {
|
||||
id=MBUTTON_SC_S_HCONT;
|
||||
} else if ( gh_eq_p(value, gh_symbol2scm("sc-pulldown")) ) {
|
||||
id=MBUTTON_SC_PULLDOWN;
|
||||
} else if ( gh_eq_p(value, gh_symbol2scm("sc-button-left")) ) {
|
||||
id=MBUTTON_SC_BUTTON_LEFT;
|
||||
} else if ( gh_eq_p(value, gh_symbol2scm("sc-button")) ) {
|
||||
id=MBUTTON_SC_BUTTON;
|
||||
} else if ( gh_eq_p(value, gh_symbol2scm("sc-button-right")) ) {
|
||||
id=MBUTTON_SC_BUTTON_RIGHT;
|
||||
} else {
|
||||
char *s1=gh_scm2newstr(value, NULL);
|
||||
fprintf(stderr, "Unsupported button %s\n", s1);
|
||||
free(s1);
|
||||
return 0;
|
||||
}
|
||||
return id;
|
||||
}
|
||||
|
||||
local int scm2hotkey(SCM value)
|
||||
{
|
||||
char *s;
|
||||
|
|
113
src/ui/ui.cpp
113
src/ui/ui.cpp
|
@ -40,6 +40,7 @@
|
|||
#include "interface.h"
|
||||
#include "map.h"
|
||||
#include "ui.h"
|
||||
#include "menus.h"
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
-- Variables
|
||||
|
@ -170,14 +171,16 @@ global void LoadUserInterface(void)
|
|||
if( TheUI.Filler[i].File ) {
|
||||
TheUI.Filler[i].Graphic=LoadGraphic(TheUI.Filler[i].File);
|
||||
#ifdef USE_OPENGL
|
||||
MakeTexture(TheUI.Filler[i].Graphic,TheUI.Filler[i].Graphic->Width,TheUI.Filler[i].Graphic->Height);
|
||||
MakeTexture(TheUI.Filler[i].Graphic,TheUI.Filler[i].Graphic->Width,
|
||||
TheUI.Filler[i].Graphic->Height);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
if( TheUI.Resource.File ) {
|
||||
TheUI.Resource.Graphic=LoadGraphic(TheUI.Resource.File);
|
||||
#ifdef USE_OPENGL
|
||||
MakeTexture(TheUI.Resource.Graphic,TheUI.Resource.Graphic->Width,TheUI.Resource.Graphic->Height);
|
||||
MakeTexture(TheUI.Resource.Graphic,TheUI.Resource.Graphic->Width,
|
||||
TheUI.Resource.Graphic->Height);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -187,7 +190,9 @@ global void LoadUserInterface(void)
|
|||
TheUI.Resources[i].Icon.Graphic
|
||||
=LoadGraphic(TheUI.Resources[i].Icon.File);
|
||||
#ifdef USE_OPENGL
|
||||
MakeTexture(TheUI.Resources[i].Icon.Graphic,TheUI.Resources[i].Icon.Graphic->Width,TheUI.Resources[i].Icon.Graphic->Height);
|
||||
MakeTexture(TheUI.Resources[i].Icon.Graphic,
|
||||
TheUI.Resources[i].Icon.Graphic->Width,
|
||||
TheUI.Resources[i].Icon.Graphic->Height);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
@ -196,45 +201,57 @@ global void LoadUserInterface(void)
|
|||
if( TheUI.Resources[FoodCost].Icon.File ) {
|
||||
TheUI.Resources[FoodCost].Icon.Graphic=LoadGraphic(TheUI.Resources[FoodCost].Icon.File);
|
||||
#ifdef USE_OPENGL
|
||||
MakeTexture(TheUI.Resources[FoodCost].Icon.Graphic,TheUI.Resources[FoodCost].Icon.Graphic->Width,TheUI.Resources[FoodCost].Icon.Graphic->Height);
|
||||
MakeTexture(TheUI.Resources[FoodCost].Icon.Graphic,
|
||||
TheUI.Resources[FoodCost].Icon.Graphic->Width,
|
||||
TheUI.Resources[FoodCost].Icon.Graphic->Height);
|
||||
#endif
|
||||
}
|
||||
// FIXME: reuse same graphics?
|
||||
if( TheUI.Resources[ScoreCost].Icon.File ) {
|
||||
TheUI.Resources[ScoreCost].Icon.Graphic=LoadGraphic(TheUI.Resources[ScoreCost].Icon.File);
|
||||
#ifdef USE_OPENGL
|
||||
MakeTexture(TheUI.Resources[ScoreCost].Icon.Graphic,TheUI.Resources[ScoreCost].Icon.Graphic->Width,TheUI.Resources[ScoreCost].Icon.Graphic->Height);
|
||||
MakeTexture(TheUI.Resources[ScoreCost].Icon.Graphic,
|
||||
TheUI.Resources[ScoreCost].Icon.Graphic->Width,
|
||||
TheUI.Resources[ScoreCost].Icon.Graphic->Height);
|
||||
#endif
|
||||
}
|
||||
|
||||
if( TheUI.InfoPanel.File ) {
|
||||
TheUI.InfoPanel.Graphic=LoadGraphic(TheUI.InfoPanel.File);
|
||||
#ifdef USE_OPENGL
|
||||
MakeTexture(TheUI.InfoPanel.Graphic,TheUI.InfoPanel.Graphic->Width,TheUI.InfoPanel.Graphic->Height);
|
||||
MakeTexture(TheUI.InfoPanel.Graphic,
|
||||
TheUI.InfoPanel.Graphic->Width,
|
||||
TheUI.InfoPanel.Graphic->Height);
|
||||
#endif
|
||||
}
|
||||
if( TheUI.ButtonPanel.File ) {
|
||||
TheUI.ButtonPanel.Graphic=LoadGraphic(TheUI.ButtonPanel.File);
|
||||
#ifdef USE_OPENGL
|
||||
MakeTexture(TheUI.ButtonPanel.Graphic,TheUI.ButtonPanel.Graphic->Width,TheUI.ButtonPanel.Graphic->Height);
|
||||
MakeTexture(TheUI.ButtonPanel.Graphic,
|
||||
TheUI.ButtonPanel.Graphic->Width,
|
||||
TheUI.ButtonPanel.Graphic->Height);
|
||||
#endif
|
||||
}
|
||||
if( TheUI.MenuButton.File ) {
|
||||
TheUI.MenuButton.Graphic=LoadGraphic(TheUI.MenuButton.File);
|
||||
if( TheUI.MenuButtonGraphic.File ) {
|
||||
TheUI.MenuButtonGraphic.Graphic=LoadGraphic(TheUI.MenuButtonGraphic.File);
|
||||
#ifdef USE_OPENGL
|
||||
MakeTexture(TheUI.MenuButton.Graphic,TheUI.MenuButton.Graphic->Width,TheUI.MenuButton.Graphic->Height);
|
||||
MakeTexture(TheUI.MenuButtonGraphic.Graphic,
|
||||
TheUI.MenuButtonGraphic.Graphic->Width,
|
||||
TheUI.MenuButtonGraphic.Graphic->Height);
|
||||
#endif
|
||||
}
|
||||
if( TheUI.Minimap.File ) {
|
||||
TheUI.Minimap.Graphic=LoadGraphic(TheUI.Minimap.File);
|
||||
#ifdef USE_OPENGL
|
||||
MakeTexture(TheUI.Minimap.Graphic,TheUI.Minimap.Graphic->Width,TheUI.Minimap.Graphic->Height);
|
||||
MakeTexture(TheUI.Minimap.Graphic,TheUI.Minimap.Graphic->Width,
|
||||
TheUI.Minimap.Graphic->Height);
|
||||
#endif
|
||||
}
|
||||
if( TheUI.StatusLine.File ) {
|
||||
TheUI.StatusLine.Graphic=LoadGraphic(TheUI.StatusLine.File);
|
||||
#ifdef USE_OPENGL
|
||||
MakeTexture(TheUI.StatusLine.Graphic,TheUI.StatusLine.Graphic->Width,TheUI.StatusLine.Graphic->Height);
|
||||
MakeTexture(TheUI.StatusLine.Graphic,TheUI.StatusLine.Graphic->Width,
|
||||
TheUI.StatusLine.Graphic->Height);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -338,7 +355,8 @@ local void SaveUi(FILE* file,const UI* ui)
|
|||
|
||||
fprintf(file," ; Menu button background\n");
|
||||
fprintf(file," (list \"%s\" %d %d)\n",
|
||||
ui->MenuButton.File,ui->MenuButtonX,ui->MenuButtonY);
|
||||
ui->MenuButtonGraphic.File,ui->MenuButtonGraphicX,
|
||||
ui->MenuButtonGraphicY);
|
||||
|
||||
fprintf(file," ; Minimap background\n");
|
||||
fprintf(file," (list \"%s\" %d %d)\n",
|
||||
|
@ -348,21 +366,62 @@ local void SaveUi(FILE* file,const UI* ui)
|
|||
fprintf(file," (list \"%s\" %d %d)\n",
|
||||
ui->StatusLine.File,ui->StatusLineX,ui->StatusLineY);
|
||||
|
||||
fprintf(file," ; Buttons\n");
|
||||
for( i=0; i<MaxButtons; ++i ) {
|
||||
fprintf(file," (list %3d %3d %4d %3d)\n",
|
||||
ui->Buttons[i].X,ui->Buttons[i].Y,
|
||||
ui->Buttons[i].Width,ui->Buttons[i].Height);
|
||||
}
|
||||
fprintf(file,"\n 'menu-button '(");
|
||||
fprintf(file,"\n pos (%d %d)",
|
||||
ui->MenuButton.X,ui->MenuButton.Y);
|
||||
fprintf(file,"\n size (%d %d)",
|
||||
ui->MenuButton.Width,ui->MenuButton.Height);
|
||||
fprintf(file,"\n caption \"%s\"",
|
||||
ui->MenuButton.Text);
|
||||
fprintf(file,"\n style %s",
|
||||
MenuButtonStyle(ui->MenuButton.Button));
|
||||
fprintf(file,")");
|
||||
|
||||
fprintf(file," ; Buttons II\n");
|
||||
for( i=0; i<6; ++i ) {
|
||||
fprintf(file," (list %3d %3d %4d %3d)\n",
|
||||
ui->Buttons2[i].X,ui->Buttons2[i].Y,
|
||||
ui->Buttons2[i].Width,ui->Buttons2[i].Height);
|
||||
}
|
||||
fprintf(file,"\n 'network-menu-button '(");
|
||||
fprintf(file,"\n pos (%d %d)",
|
||||
ui->NetworkMenuButton.X,ui->NetworkMenuButton.Y);
|
||||
fprintf(file,"\n size (%d %d)",
|
||||
ui->NetworkMenuButton.Width,ui->NetworkMenuButton.Height);
|
||||
fprintf(file,"\n caption \"%s\"",
|
||||
ui->NetworkMenuButton.Text);
|
||||
fprintf(file,"\n style %s",
|
||||
MenuButtonStyle(ui->NetworkMenuButton.Button));
|
||||
fprintf(file,")");
|
||||
|
||||
fprintf(file,"\n 'cursors '(");
|
||||
fprintf(file,"\n 'network-diplomacy-button '(");
|
||||
fprintf(file,"\n pos (%d %d)",
|
||||
ui->NetworkDiplomacyButton.X,ui->NetworkDiplomacyButton.Y);
|
||||
fprintf(file,"\n size (%d %d)",
|
||||
ui->NetworkDiplomacyButton.Width,ui->NetworkDiplomacyButton.Height);
|
||||
fprintf(file,"\n caption \"%s\"",
|
||||
ui->NetworkDiplomacyButton.Text);
|
||||
fprintf(file,"\n style %s",
|
||||
MenuButtonStyle(ui->NetworkDiplomacyButton.Button));
|
||||
fprintf(file,")");
|
||||
|
||||
fprintf(file,"\n\n 'info-buttons '(");
|
||||
for( i=0; i<ui->NumInfoButtons; ++i ) {
|
||||
fprintf(file,"\n (pos (%3d %3d) size (%d %d))",
|
||||
ui->InfoButtons[i].X,ui->InfoButtons[i].Y,
|
||||
ui->InfoButtons[i].Width,ui->InfoButtons[i].Height);
|
||||
}
|
||||
fprintf(file,")");
|
||||
fprintf(file,"\n 'training-buttons '(");
|
||||
for( i=0; i<ui->NumTrainingButtons; ++i ) {
|
||||
fprintf(file,"\n (pos (%3d %3d) size (%d %d))",
|
||||
ui->TrainingButtons[i].X,ui->TrainingButtons[i].Y,
|
||||
ui->TrainingButtons[i].Width,ui->TrainingButtons[i].Height);
|
||||
}
|
||||
fprintf(file,")");
|
||||
fprintf(file,"\n 'button-buttons '(");
|
||||
for( i=0; i<ui->NumButtonButtons; ++i ) {
|
||||
fprintf(file,"\n (pos (%3d %3d) size (%d %d))",
|
||||
ui->ButtonButtons[i].X,ui->ButtonButtons[i].Y,
|
||||
ui->ButtonButtons[i].Width,ui->ButtonButtons[i].Height);
|
||||
}
|
||||
fprintf(file,")");
|
||||
|
||||
fprintf(file,"\n\n 'cursors '(");
|
||||
fprintf(file,"\n point %s", ui->Point.Name);
|
||||
fprintf(file,"\n glass %s", ui->Glass.Name);
|
||||
fprintf(file,"\n cross %s", ui->Cross.Name);
|
||||
|
@ -476,7 +535,7 @@ global void CleanUserInterface(void)
|
|||
|
||||
VideoSaveFree(TheUI.InfoPanel.Graphic);
|
||||
VideoSaveFree(TheUI.ButtonPanel.Graphic);
|
||||
VideoSaveFree(TheUI.MenuButton.Graphic);
|
||||
VideoSaveFree(TheUI.MenuButtonGraphic.Graphic);
|
||||
VideoSaveFree(TheUI.Minimap.Graphic);
|
||||
VideoSaveFree(TheUI.StatusLine.Graphic);
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue