-
Notifications
You must be signed in to change notification settings - Fork 27
/
gamemode.cpp
127 lines (108 loc) · 4.11 KB
/
gamemode.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
//////////////////////////////////////////////////////////////////////
// Yet Another Tibia Client
//////////////////////////////////////////////////////////////////////
// Base gamemode class
//////////////////////////////////////////////////////////////////////
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software Foundation,
// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
//////////////////////////////////////////////////////////////////////
#include <GLICT/messagebox.h>
#include "gamemode.h"
GameMode* g_game = NULL;
/* ****** gamemode ******* */
void GameMode::centerWindow (glictWindow *win)
{
glictSize s;
win->GetSize(&s);
win->SetPos(glictGlobals.w / 2 - s.w / 2, glictGlobals.h/2 - s.h / 2);
}
void GameMode::MBOnDismiss(glictPos* pos, glictContainer* caller)
{
if (caller->GetCustomData()) {
glictContainer* focusOnDismiss = (glictContainer*)caller->GetCustomData();
focusOnDismiss->SetVisible(true);
focusOnDismiss->Focus(NULL);
}
g_game->renderScene();
}
void GameMode::msgBox (const char* mbox, const char* title, glictContainer* focusondismiss)
{
glictSize s;
glictMessageBox *mb;
desktop.AddObject(mb = new glictMessageBox);
mb->SetCaption(title);
mb->SetMessage(mbox);
mb->SetHeight(glictFontNumberOfLines(mbox)*12 + 35 + 10 + 10);
int size1 = (int)glictFontSize(title, "system");
int size2 = (int)glictFontSize(mbox, "system");
mb->SetWidth(MAX(size1, size2) + 10 + 10);
mb->Focus(NULL);
#if (GLICT_APIREV >= 85)
mb->SetTextOffset(10,10);
#else
#warning For nicer msgboxes get GLICT APIREV 85+.
#endif
#if (GLICT_APIREV >= 2020010401)
mb->SetButtonCaption(gettext("Ok"));
mb->SetButtonFont("minifont", 8);
mb->EnableSeparator(&g_skin.chk, 2, 6, 8, .1, .1, .1, 1.0);
mb->SetButtonHeight(18);
mb->SetButtonMarginY(5);
mb->SetButtonMarginX(5);
mb->SetButtonAlignment(GLICT_VALIGN_RIGHT);
#else
#warning For nicer msgboxes get GLICT APIREV 2020010401+.
#endif
mb->GetSize(&s);
mb->SetPos(glictGlobals.w / 2 - s.w / 2, glictGlobals.h/ 2 - s.h / 2);
mb->SetOnDismiss(MBOnDismiss);
mb->SetCustomData(focusondismiss);
}
/* ****** gamemode with options ***** */
GameModeOptions::GameModeOptions()
{
winOptions.initiateAll(&desktop);
}
void GameModeOptions::winOptions_btnNetwork_OnClick(glictPos* relmousepos, glictContainer* callerclass)
{
winOptions_t* winOptions = g_game->getOptionsWindow();
winOptions->winOptionsNetwork.Init();
winOptions->winOptionsNetwork.window.SetVisible(true);
winOptions->winOptionsNetwork.txtServer.Focus(NULL);
}
void GameModeOptions::winOptionsNetwork_btnOk_OnClick(glictPos* relmousepos, glictContainer* callerclass)
{
winOptions_t* winOptions = g_game->getOptionsWindow();
winOptions->winOptionsNetwork.Store();
//((*GM_MainMenu)g_game)->desktop.SetFocus(NULL);
winOptions->winOptionsNetwork.window.SetVisible(false);
glictGlobals.topFocused = NULL;
}
void GameModeOptions::winOptionsNetwork_btnCancel_OnClick(glictPos* relmousepos, glictContainer* callerclass)
{
winOptions_t* winOptions = g_game->getOptionsWindow();
//((*GM_MainMenu)g_game)->desktop.SetFocus(NULL);
winOptions->winOptionsNetwork.window.SetVisible(false);
glictGlobals.topFocused = NULL;
}
void GameModeOptions::doResize(float w, float h)
{
centerWindow(&winOptions.window);
centerWindow(&winOptions.winOptionsGeneral.window);
centerWindow(&winOptions.winOptionsConsole.window);
centerWindow(&winOptions.winOptionsGraphics.window);
centerWindow(&winOptions.winOptionsGraphicsAdvanced.window);
centerWindow(&winOptions.winOptionsHotkeys.window);
centerWindow(&winOptions.winOptionsNetwork.window);
}