summaryrefslogtreecommitdiff
path: root/src/gui/setup_other.cpp
blob: 7a43b5480502256acde93c81b32f332ece329380 (plain) (blame)
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
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
/*
 *  The Mana World
 *  Copyright (C) 2009  The Mana World Development Team
 *  Copyright (C) 2009-2010  Andrei Karas
 *
 *  This file is part of The Mana World.
 *
 *  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
 *  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 "gui/setup_other.h"
#include "gui/editdialog.h"

#include "gui/widgets/button.h"
#include "gui/widgets/checkbox.h"
#include "gui/widgets/label.h"
#include "gui/widgets/layouthelper.h"
#include "gui/widgets/textfield.h"

#include "configuration.h"
#include "localplayer.h"
#include "log.h"

#include "utils/gettext.h"

#define ACTION_SHOW_TAKEDDAMAGE "taked damage"
#define ACTION_ONLY_REACHABLE "only reachable"
#define ACTION_ERRORS_IN_DEBUG "errors in debug"
#define ACTION_HIGHLIGHT_PORTALS "highlight portals"
#define ACTION_HIGHLIGHT_ATTACK_RANGE "highlight attack"
#define ACTION_HIGHLIGHT_MONSTER_ATTACK_RANGE "highlight monster attack"
#define ACTION_CYCLE_PLAYERS "cycle players"
#define ACTION_CYCLE_MONSTERS "cycle monsters"
#define ACTION_ENABLE_BOTCHECKER "bot checker"
#define ACTION_FLOORITEMS_HIGHLIGHT "floor items"
#define ACTION_MOVE_PROGRAM "move program"
#define ACTION_EDIT_PROGRAM "edit program"
#define ACTION_EDIT_PROGRAM_OK "edit program ok"
#define ACTION_AFK "move afk"
#define ACTION_EDIT_AFK "edit afk"
#define ACTION_EDIT_AFK_OK "edit afk ok"
#define ACTION_ENABLE_AFK "enable afk"
#define ACTION_TRADEBOT "trade bot"
#define ACTION_BUGGY_SERVERS "buggy servers"
#define ACTION_DEBUG_LOG "debug log"
#define ACTION_SERVER_ATTACK "server attack"
#define ACTION_FIX_POS "fix pos"
#define ACTION_ATTACK_MOVING "attack moving"
#define ACTION_QUICK_STATS "quick stats"
#define ACTION_WARP_PARTICLE "warp particle"
#define ACTION_AUTO_SHOP "auto shop"
#define ACTION_SHOW_MOB_HP "show mob hp"
#define ACTION_SHOW_OWN_HP "show own hp"
#define ACTION_SHOW_JOB_EXP "show job exp"
#define ACTION_SHOW_BEING_POPUP "show being popup"
#define ACTION_SHOW_EXTENDED_MINIMAPS "show extended minimaps"

Setup_Other::Setup_Other():
    mShowMonstersTakedDamage(config.getBoolValue("showMonstersTakedDamage")),
    mTargetOnlyReachable(config.getBoolValue("targetOnlyReachable")),
    mHighlightPortals(config.getBoolValue("highlightMapPortals")),
    mHighlightAttackRange(config.getBoolValue("highlightAttackRange")),
    mHighlightMonsterAttackRange(
        config.getBoolValue("highlightMonsterAttackRange")),
    mCyclePlayers(config.getBoolValue("cyclePlayers")),
    mCycleMonsters(config.getBoolValue("cycleMonsters")),
    mEnableBotChecker(config.getBoolValue("enableBotCheker")),
    mFloorItemsHighlight(config.getBoolValue("floorItemsHighlight")),
    mMoveProgram(config.getStringValue("crazyMoveProgram")),
    mAfk(config.getStringValue("afkMessage")),
    mTradeBot(config.getBoolValue("tradebot")),
    mBuggyServers(serverConfig.getValueBool("enableBuggyServers", true)),
    mDebugLog(config.getBoolValue("debugLog")),
    mServerAttack(config.getBoolValue("serverAttack")),
    mAutofixPos(config.getBoolValue("autofixPos")),
    mAttackMoving(config.getBoolValue("attackMoving")),
    mQuickStats(config.getBoolValue("quickStats")),
    mWarpParticle(config.getBoolValue("warpParticle")),
    mAutoShop(config.getBoolValue("autoShop")),
    mShowMobHP(config.getBoolValue("showMobHP")),
    mShowOwnHP(config.getBoolValue("showOwnHP")),
    mShowJobExp(config.getBoolValue("showJobExp")),
    mShowBeingPopup(config.getBoolValue("showBeingPopup")),
    mShowExtMinimaps(config.getBoolValue("showExtMinimaps")),
    mEditDialog(0)
{
    setName(_("Misc"));

    mShowMonstersTakedDamageCheckBox = new CheckBox(
        _("Show damage inflicted to monsters"),
        mShowMonstersTakedDamage,
        this, ACTION_SHOW_TAKEDDAMAGE);

    mTargetOnlyReachableCheckBox = new CheckBox(
        _("Auto target only reachable monsters"),
        mTargetOnlyReachable,
        this, ACTION_ONLY_REACHABLE);

    mHighlightPortalsCheckBox = new CheckBox(_("Highlight map portals"),
        mHighlightPortals,
        this, ACTION_HIGHLIGHT_PORTALS);

    mHighlightAttackRangeCheckBox = new CheckBox(
        _("Highlight player attack range"),
        mHighlightAttackRange,
        this, ACTION_HIGHLIGHT_ATTACK_RANGE);

    mHighlightMonsterAttackRangeCheckBox = new CheckBox(
        _("Highlight monster attack range"),
        mHighlightMonsterAttackRange,
        this, ACTION_HIGHLIGHT_MONSTER_ATTACK_RANGE);

    mCyclePlayersCheckBox = new CheckBox(_("Cycle player targets"),
        mCyclePlayers, this, ACTION_CYCLE_PLAYERS);

    mCycleMonstersCheckBox = new CheckBox(_("Cycle monster targets"),
        mCycleMonsters, this, ACTION_CYCLE_MONSTERS);

    mEnableBotCheckerCheckBox = new CheckBox(_("Enable bot checker"),
        mEnableBotChecker, this, ACTION_ENABLE_BOTCHECKER);

    mFloorItemsHighlightCheckBox = new CheckBox(_("Highlight floor items"),
        mFloorItemsHighlight, this, ACTION_FLOORITEMS_HIGHLIGHT);

    mMoveProgramLabel = new Label(_("Crazy move A program"));

    mMoveProgramField = new TextField(mMoveProgram, true,
                                      this, ACTION_MOVE_PROGRAM);

    mMoveProgramButton = new Button(_("Edit"), ACTION_EDIT_PROGRAM, this);

    mAfkField = new TextField(mAfk, true, this, ACTION_AFK);

    mAfkButton = new Button(_("Edit"), ACTION_EDIT_AFK, this);

    mTradeBotCheckBox = new CheckBox(_("Enable shop mode"),
        mTradeBot, this, ACTION_TRADEBOT);

    mBuggyServersCheckBox = new CheckBox(_("Enable buggy servers protection"),
        mBuggyServers, this, ACTION_BUGGY_SERVERS);

    mDebugLogCheckBox = new CheckBox(_("Enable debug log"),
        mDebugLog, this, ACTION_DEBUG_LOG);

    mServerAttackCheckBox = new CheckBox(_("Enable server side attack"),
        mServerAttack, this, ACTION_SERVER_ATTACK);

    mAutofixPosCheckBox = new CheckBox(_("Auto fix position"),
        mAutofixPos, this, ACTION_FIX_POS);

    mAttackMovingCheckBox = new CheckBox(_("Attack while moving"),
        mAttackMoving, this, ACTION_ATTACK_MOVING);

    mQuickStatsCheckBox = new CheckBox(_("Enable quick stats"),
        mQuickStats, this, ACTION_QUICK_STATS);

    mWarpParticleCheckBox = new CheckBox(_("Show warps particles"),
        mWarpParticle, this, ACTION_WARP_PARTICLE);

    mAutoShopCheckBox = new CheckBox(_("Accept sell/buy requests"),
        mAutoShop, this, ACTION_AUTO_SHOP);

    mShowMobHPCheckBox = new CheckBox(_("Show monster hp bar"),
        mShowMobHP, this, ACTION_SHOW_MOB_HP);

    mShowOwnHPCheckBox = new CheckBox(_("Show own hp bar"),
        mShowOwnHP, this, ACTION_SHOW_OWN_HP);

    mShowJobExpCheckBox = new CheckBox(_("Show job exp messages"),
        mShowJobExp, this, ACTION_SHOW_JOB_EXP);

    mShowBeingPopupCheckBox = new CheckBox(_("Show players popups"),
        mShowBeingPopup, this, ACTION_SHOW_BEING_POPUP);

    mShowExtMinimapsCheckBox = new CheckBox(_("Show extended minimaps"),
        mShowExtMinimaps, this, ACTION_SHOW_EXTENDED_MINIMAPS);

    // Do the layout
    LayoutHelper h(this);
    ContainerPlacer place = h.getPlacer(0, 0);

    place(0, 0, mShowMonstersTakedDamageCheckBox, 12);
    place(12, 0, mServerAttackCheckBox, 10);
    place(0, 1, mTargetOnlyReachableCheckBox, 12);
    place(12, 1, mAutofixPosCheckBox, 10);
    place(0, 2, mHighlightPortalsCheckBox, 12);
    place(12, 2, mAttackMovingCheckBox, 10);
    place(12, 3, mQuickStatsCheckBox, 10);
    place(12, 4, mWarpParticleCheckBox, 10);
    place(12, 5, mAutoShopCheckBox, 10);
    place(12, 6, mShowMobHPCheckBox, 10);
    place(12, 7, mShowOwnHPCheckBox, 10);
    place(12, 8, mShowJobExpCheckBox, 10);
    place(12, 9, mShowBeingPopupCheckBox, 10);
    place(12, 10, mShowExtMinimapsCheckBox, 10);
    place(0, 3, mFloorItemsHighlightCheckBox, 12);
    place(0, 4, mHighlightAttackRangeCheckBox, 12);
    place(0, 5, mHighlightMonsterAttackRangeCheckBox, 12);
    place(0, 6, mCyclePlayersCheckBox, 12);
    place(0, 7, mCycleMonstersCheckBox, 12);
    place(0, 8, mEnableBotCheckerCheckBox, 12);
    place(0, 9, mMoveProgramLabel, 12);
    place(0, 10, mMoveProgramField, 9);
    place(9, 10, mMoveProgramButton, 2);
    place(0, 11, mAfkField, 9);
    place(9, 11, mAfkButton, 2);
    place(0, 12, mTradeBotCheckBox, 12);
    place(0, 13, mBuggyServersCheckBox, 12);
    place(0, 14, mDebugLogCheckBox, 12);

    place.getCell().matchColWidth(0, 0);
    place = h.getPlacer(0, 1);

    setDimension(gcn::Rectangle(0, 0, 550, 500));
}

void Setup_Other::action(const gcn::ActionEvent &event)
{
    if (event.getId() == ACTION_SHOW_TAKEDDAMAGE)
    {
        mShowMonstersTakedDamage = mShowMonstersTakedDamageCheckBox
            ->isSelected();
    }
    else if (event.getId() == ACTION_ONLY_REACHABLE)
    {
        mTargetOnlyReachable = mTargetOnlyReachableCheckBox->isSelected();
    }
    else if (event.getId() == ACTION_HIGHLIGHT_PORTALS)
    {
        mHighlightPortals = mHighlightPortalsCheckBox->isSelected();
    }
    else if (event.getId() == ACTION_HIGHLIGHT_ATTACK_RANGE)
    {
        mHighlightAttackRange = mHighlightAttackRangeCheckBox->isSelected();
    }
    else if (event.getId() == ACTION_HIGHLIGHT_MONSTER_ATTACK_RANGE)
    {
        mHighlightMonsterAttackRange = mHighlightMonsterAttackRangeCheckBox
            ->isSelected();
    }
    else if (event.getId() == ACTION_CYCLE_PLAYERS)
    {
        mCyclePlayers = mCyclePlayersCheckBox->isSelected();
    }
    else if (event.getId() == ACTION_CYCLE_MONSTERS)
    {
        mCycleMonsters = mCycleMonstersCheckBox->isSelected();
    }
    else if (event.getId() == ACTION_ENABLE_BOTCHECKER)
    {
        mEnableBotChecker = mEnableBotCheckerCheckBox->isSelected();
    }
    else if (event.getId() == ACTION_FLOORITEMS_HIGHLIGHT)
    {
        mFloorItemsHighlight = mFloorItemsHighlightCheckBox->isSelected();
    }
    else if (event.getId() == ACTION_MOVE_PROGRAM)
    {
        mMoveProgram = mMoveProgramField->getText();
    }
    else if (event.getId() == ACTION_EDIT_PROGRAM)
    {
        mEditDialog =  new EditDialog("Crazy Move A",
            mMoveProgramField->getText(), ACTION_EDIT_PROGRAM_OK);
        mEditDialog->addActionListener(this);
    }
    else if (event.getId() == ACTION_EDIT_PROGRAM_OK)
    {
        mMoveProgramField->setText(mEditDialog->getMsg());
    }

    else if (event.getId() == ACTION_AFK)
        mAfk = mAfkField->getText();
    else if (event.getId() == ACTION_EDIT_AFK)
    {
        mEditDialog =  new EditDialog("Afk message", mAfkField->getText(), 
                                      ACTION_EDIT_AFK_OK);
        mEditDialog->addActionListener(this);
    }
    else if (event.getId() == ACTION_EDIT_AFK_OK)
    {
        mAfkField->setText(mEditDialog->getMsg());
    }
    else if (event.getId() == ACTION_TRADEBOT)
    {
        mTradeBot = mTradeBotCheckBox->isSelected();
    }
    else if (event.getId() == ACTION_BUGGY_SERVERS)
    {
        mBuggyServers = mBuggyServersCheckBox->isSelected();
    }
    else if (event.getId() == ACTION_DEBUG_LOG)
    {
        mDebugLog = mDebugLogCheckBox->isSelected();
    }
    else if (event.getId() == ACTION_SERVER_ATTACK)
    {
        mServerAttack = mServerAttackCheckBox->isSelected();
    }
    else if (event.getId() == ACTION_FIX_POS)
    {
        mAutofixPos = mAutofixPosCheckBox->isSelected();
    }
    else if (event.getId() == ACTION_ATTACK_MOVING)
    {
        mAttackMoving = mAttackMovingCheckBox->isSelected();
    }
    else if (event.getId() == ACTION_QUICK_STATS)
    {
        mQuickStats = mQuickStatsCheckBox->isSelected();
    }
    else if (event.getId() == ACTION_WARP_PARTICLE)
    {
        mWarpParticle = mWarpParticleCheckBox->isSelected();
    }
    else if (event.getId() == ACTION_AUTO_SHOP)
    {
        mAutoShop = mAutoShopCheckBox->isSelected();
    }
    else if (event.getId() == ACTION_SHOW_MOB_HP)
    {
        mShowMobHP = mShowMobHPCheckBox->isSelected();
    }
    else if (event.getId() == ACTION_SHOW_OWN_HP)
    {
        mShowOwnHP = mShowOwnHPCheckBox->isSelected();
    }
    else if (event.getId() == ACTION_SHOW_JOB_EXP)
    {
        mShowJobExp = mShowJobExpCheckBox->isSelected();
    }
    else if (event.getId() == ACTION_SHOW_BEING_POPUP)
    {
        mShowBeingPopup = mShowBeingPopupCheckBox->isSelected();
    }
    else if (event.getId() == ACTION_SHOW_EXTENDED_MINIMAPS)
    {
        mShowExtMinimaps = mShowExtMinimapsCheckBox->isSelected();
    }
}

void Setup_Other::cancel()
{
    mShowMonstersTakedDamage = config.getBoolValue(
        "showMonstersTakedDamage");
    mShowMonstersTakedDamageCheckBox->setSelected(mShowMonstersTakedDamage);

    mTargetOnlyReachable = config.getBoolValue("targetOnlyReachable");
    mTargetOnlyReachableCheckBox->setSelected(mTargetOnlyReachable);

    mHighlightPortals = config.getBoolValue("highlightMapPortals");
    mHighlightPortalsCheckBox->setSelected(mHighlightPortals);

    mHighlightAttackRange = config.getBoolValue("highlightAttackRange");
    mHighlightAttackRangeCheckBox->setSelected(mHighlightAttackRange);

    mHighlightMonsterAttackRange = config.getBoolValue(
        "highlightMonsterAttackRange");
    mHighlightMonsterAttackRangeCheckBox->setSelected(
        mHighlightMonsterAttackRange);

    mCyclePlayers = config.getBoolValue("cyclePlayers");
    mCyclePlayersCheckBox->setSelected(mCyclePlayers);

    mCycleMonsters = config.getBoolValue("cycleMonsters");
    mCycleMonstersCheckBox->setSelected(mCycleMonsters);

    mEnableBotChecker = config.getBoolValue("enableBotCheker");
    mEnableBotCheckerCheckBox->setSelected(mEnableBotChecker);

    mFloorItemsHighlight = config.getBoolValue("floorItemsHighlight");
    mFloorItemsHighlightCheckBox->setSelected(mFloorItemsHighlight);

    mMoveProgram = config.getStringValue("crazyMoveProgram");
    mMoveProgramField->setText(mMoveProgram);

    mAfk = config.getStringValue("afkMessage");
    mAfkField->setText(mAfk);

    mTradeBot = config.getBoolValue("tradebot");
    mTradeBotCheckBox->setSelected(mTradeBot);

    mBuggyServers = serverConfig.getValueBool("enableBuggyServers", true);
    mBuggyServersCheckBox->setSelected(mBuggyServers);

    mDebugLog = config.getBoolValue("debugLog");
    mDebugLogCheckBox->setSelected(mDebugLog);

    mServerAttack = config.getBoolValue("serverAttack");
    mServerAttackCheckBox->setSelected(mServerAttack);

    mAutofixPos = config.getBoolValue("autofixPos");
    mAutofixPosCheckBox->setSelected(mAutofixPos);

    mAttackMoving = config.getBoolValue("attackMoving");
    mAttackMovingCheckBox->setSelected(mAttackMoving);

    mQuickStats = config.getBoolValue("quickStats");
    mQuickStatsCheckBox->setSelected(mQuickStats);

    mWarpParticle = config.getBoolValue("warpParticle");
    mWarpParticleCheckBox->setSelected(mWarpParticle);

    mAutoShop = config.getBoolValue("autoShop");
    mAutoShopCheckBox->setSelected(mAutoShop);

    mShowMobHP = config.getBoolValue("showMobHP");
    mShowMobHPCheckBox->setSelected(mShowMobHP);

    mShowOwnHP = config.getBoolValue("showOwnHP");
    mShowOwnHPCheckBox->setSelected(mShowOwnHP);

    mShowJobExp = config.getBoolValue("showJobExp");
    mShowJobExpCheckBox->setSelected(mShowJobExp);

    mShowBeingPopup = config.getBoolValue("showBeingPopup");
    mShowBeingPopupCheckBox->setSelected(mShowBeingPopup);

    mShowExtMinimaps = config.getBoolValue("showExtMinimaps");
    mShowExtMinimapsCheckBox->setSelected(mShowExtMinimaps);
}

void Setup_Other::apply()
{
    config.setValue("showMonstersTakedDamage", mShowMonstersTakedDamage);
    config.setValue("targetOnlyReachable", mTargetOnlyReachable);
    config.setValue("highlightMapPortals", mHighlightPortals);
    config.setValue("highlightAttackRange", mHighlightAttackRange);
    config.setValue("highlightMonsterAttackRange",
                    mHighlightMonsterAttackRange);
    config.setValue("cyclePlayers", mCyclePlayers);
    config.setValue("cycleMonsters", mCycleMonsters);
    config.setValue("enableBotCheker", mEnableBotChecker);
    config.setValue("floorItemsHighlight", mFloorItemsHighlight);
    config.setValue("crazyMoveProgram", mMoveProgramField->getText());
    config.setValue("afkMessage", mAfkField->getText());
    config.setValue("tradebot", mTradeBot);
    serverConfig.setValue("enableBuggyServers", mBuggyServers);
    config.setValue("debugLog", mDebugLog);
    config.setValue("serverAttack", mServerAttack);
    config.setValue("autofixPos", mAutofixPos);
    config.setValue("attackMoving", mAttackMoving);
    config.setValue("quickStats", mQuickStats);
    config.setValue("warpParticle", mWarpParticle);
    config.setValue("autoShop", mAutoShop);
    config.setValue("showMobHP", mShowMobHP);
    config.setValue("showOwnHP", mShowOwnHP);
    config.setValue("showJobExp", mShowJobExp);
    config.setValue("showBeingPopup", mShowBeingPopup);
    config.setValue("showExtMinimaps", mShowExtMinimaps);
    logger->setDebugLog(mDebugLog);
}

void Setup_Other::externalUpdated()
{
    mBuggyServers = serverConfig.getValueBool("enableBuggyServers", true);
    mBuggyServersCheckBox->setSelected(mBuggyServers);
}