-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathuimenu_AddMatchMenu.cpp
More file actions
152 lines (117 loc) · 4.81 KB
/
uimenu_AddMatchMenu.cpp
File metadata and controls
152 lines (117 loc) · 4.81 KB
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
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
/*
Copyright (C) 2007 Will Franklin
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 "uicore_Global.h"
#include "uimenu_AddMatchMenu.h"
#include "uiwsw_Export.h"
#include "uiwsw_SysCalls.h"
#include "uiwsw_Utils.h"
using namespace UICore;
using namespace UIMenu;
using namespace UIWsw;
AddMatchMenu *addmatchmenu;
void AddMatchMenu::btnAddHandler( BaseObject * )
{
int players, scorelimit;
float timelimit;
char *skilltype;
if( !addmatchmenu->lstGametype->getNbSelectedItem() )
return;
players = atoi( addmatchmenu->txtNoOfPlayers->getText() );
scorelimit = atoi( addmatchmenu->txtScorelimit->getText() );
timelimit = atof( addmatchmenu->txtTimelimit->getText() );
skilltype = ( char* )(addmatchmenu->btnAllSkills->isPressed() ? "all" : "dependent");
Trap::MM_UIRequest( ACTION_ADDMATCH, va( "%s %d %d %.2f %s",
gametype_names[addmatchmenu->lstGametype->getSelectedPosition()][1],
players, scorelimit, timelimit, skilltype ) );
}
void AddMatchMenu::btnBackHandler( BaseObject * )
{
if( addmatchmenu->cancelCallback )
addmatchmenu->cancelCallback();
addmatchmenu->Hide();
}
void AddMatchMenu::skillsHandler( BaseObject *btn, bool )
{
static_cast<SwitchButton *>( btn )->setPressed( true );
if( btn == addmatchmenu->btnAllSkills )
addmatchmenu->btnDependent->setPressed( false );
else
addmatchmenu->btnAllSkills->setPressed( false );
}
AddMatchMenu::AddMatchMenu( void )
{
pBackground = Factory::newPanel( rootPanel, 0, 0, 800, 600 );
pBackground->setBorderWidth( 0 );
pBackground->setVisible( false );
panel = Factory::newPanel( pBackground, 225, 185, 350, 230 );
lblTitle = Factory::newLabel( panel, 20, 20, 200, 20, "Add match" );
lblTitle->setFont( Local::getFontBig() );
lblGametype = Factory::newLabel( panel, 20, 50, 90, 20, "Gametype:" );
lblGametype->setAlign( ALIGN_MIDDLE_LEFT );
lstGametype = Factory::newDropDownBox( panel, 100, 50, 200, 20, 75 );
for( int i = 0 ; i < GAMETYPE_NB ; i++ )
Factory::newListItem( lstGametype, gametype_names[i][0] );
lblNoOfPlayers = Factory::newLabel( panel, 20, 75, 120, 20, "No. of players:" );
lblNoOfPlayers->setAlign( ALIGN_MIDDLE_LEFT );
txtNoOfPlayers = Factory::newTextBox( panel, 140, 75, 25, 20, 3 );
txtNoOfPlayers->setFlags( TEXTBOX_NUMBERSONLY );
lblTimelimit = Factory::newLabel( panel, 20, 100, 120, 20, "Timelimit:" );
lblTimelimit->setAlign( ALIGN_MIDDLE_LEFT );
txtTimelimit = Factory::newTextBox( panel, 140, 100, 50, 20, 6 );
txtTimelimit->setFlags( TEXTBOX_NUMBERSONLY );
lblScorelimit = Factory::newLabel( panel, 20, 125, 120, 20, "Scorelimit:" );
lblScorelimit->setAlign( ALIGN_MIDDLE_LEFT );
txtScorelimit = Factory::newTextBox( panel, 140, 125, 25, 20, 3 );
txtScorelimit->setFlags( TEXTBOX_NUMBERSONLY );
lblSkill = Factory::newLabel( panel, 20, 150, 100, 20, "Skill type:" );
lblSkill->setAlign( ALIGN_MIDDLE_LEFT );
btnAllSkills = Factory::newSwitchButton( panel, 120, 150, 50, 20, "All" );
btnAllSkills->setSwitchHandler( AddMatchMenu::skillsHandler );
btnAllSkills->setPressed( true );
btnDependent = Factory::newSwitchButton( panel, 175, 150, 100, 20, "Dependent" );
btnDependent->setSwitchHandler( AddMatchMenu::skillsHandler );
btnAdd = Factory::newButton( panel, 20, 180, 100, 30, "Add match" );
btnAdd->setClickHandler( AddMatchMenu::btnAddHandler );
btnBack = Factory::newButton( panel, 130, 180, 80, 30, "Cancel" );
btnBack->setClickHandler( AddMatchMenu::btnBackHandler );
#if 0
panel->PutOnTop( lstGametype );
#endif
messageBox = Factory::newMessageBox();
setCancelCallback( NULL );
}
ALLOCATOR_DEFINITION( AddMatchMenu );
DELETER_DEFINITION( AddMatchMenu );
void AddMatchMenu::Show( void )
{
pBackground->setVisible( true );
addmatchmenu = this;
lstGametype->showList( false );
txtNoOfPlayers->ClearText();
txtTimelimit->ClearText();
txtScorelimit->ClearText();
btnAllSkills->setPressed( true );
btnDependent->setPressed( false );
}
void AddMatchMenu::Hide( void )
{
pBackground->setVisible( false );
addmatchmenu = NULL;
messageBox->Hide();
}
void AddMatchMenu::setGametype( int index )
{
addmatchmenu->lstGametype->selectItem( index );
}