src/ai/ai_gui.cpp
author truebrain
Thu, 12 Jun 2008 18:14:06 +0000
branchnoai
changeset 10939 e7693a7bb280
parent 10874 705f4caa0796
child 11027 d1ab0da686d1
permissions -rw-r--r--
(svn r13493) [NoAI] -Fix: ReloadAI should reload the AI correctly, no matter what you named your dir
9845
c359062b4db0 (svn r12511) [NoAI] -Add (WIP): AI Debug GUI. For now it is a stripped down copy of performance details. In future it will allow reloading of AI, changing settings, and reading the log of the AI
truebrain
parents:
diff changeset
     1
/* $Id$ */
c359062b4db0 (svn r12511) [NoAI] -Add (WIP): AI Debug GUI. For now it is a stripped down copy of performance details. In future it will allow reloading of AI, changing settings, and reading the log of the AI
truebrain
parents:
diff changeset
     2
c359062b4db0 (svn r12511) [NoAI] -Add (WIP): AI Debug GUI. For now it is a stripped down copy of performance details. In future it will allow reloading of AI, changing settings, and reading the log of the AI
truebrain
parents:
diff changeset
     3
/** @file ai_gui.cpp */
c359062b4db0 (svn r12511) [NoAI] -Add (WIP): AI Debug GUI. For now it is a stripped down copy of performance details. In future it will allow reloading of AI, changing settings, and reading the log of the AI
truebrain
parents:
diff changeset
     4
c359062b4db0 (svn r12511) [NoAI] -Add (WIP): AI Debug GUI. For now it is a stripped down copy of performance details. In future it will allow reloading of AI, changing settings, and reading the log of the AI
truebrain
parents:
diff changeset
     5
#include "../stdafx.h"
c359062b4db0 (svn r12511) [NoAI] -Add (WIP): AI Debug GUI. For now it is a stripped down copy of performance details. In future it will allow reloading of AI, changing settings, and reading the log of the AI
truebrain
parents:
diff changeset
     6
#include "../openttd.h"
c359062b4db0 (svn r12511) [NoAI] -Add (WIP): AI Debug GUI. For now it is a stripped down copy of performance details. In future it will allow reloading of AI, changing settings, and reading the log of the AI
truebrain
parents:
diff changeset
     7
#include "../gui.h"
c359062b4db0 (svn r12511) [NoAI] -Add (WIP): AI Debug GUI. For now it is a stripped down copy of performance details. In future it will allow reloading of AI, changing settings, and reading the log of the AI
truebrain
parents:
diff changeset
     8
#include "../window_gui.h"
9851
a5f5a7cf2b61 (svn r12519) [NoAI] -Add: added AILog with Info(), Warning(), and Error()
truebrain
parents: 9846
diff changeset
     9
#include "../player_func.h"
9845
c359062b4db0 (svn r12511) [NoAI] -Add (WIP): AI Debug GUI. For now it is a stripped down copy of performance details. In future it will allow reloading of AI, changing settings, and reading the log of the AI
truebrain
parents:
diff changeset
    10
#include "../player_base.h"
c359062b4db0 (svn r12511) [NoAI] -Add (WIP): AI Debug GUI. For now it is a stripped down copy of performance details. In future it will allow reloading of AI, changing settings, and reading the log of the AI
truebrain
parents:
diff changeset
    11
#include "../player_gui.h"
c359062b4db0 (svn r12511) [NoAI] -Add (WIP): AI Debug GUI. For now it is a stripped down copy of performance details. In future it will allow reloading of AI, changing settings, and reading the log of the AI
truebrain
parents:
diff changeset
    12
#include "../economy_func.h"
c359062b4db0 (svn r12511) [NoAI] -Add (WIP): AI Debug GUI. For now it is a stripped down copy of performance details. In future it will allow reloading of AI, changing settings, and reading the log of the AI
truebrain
parents:
diff changeset
    13
#include "../variables.h"
c359062b4db0 (svn r12511) [NoAI] -Add (WIP): AI Debug GUI. For now it is a stripped down copy of performance details. In future it will allow reloading of AI, changing settings, and reading the log of the AI
truebrain
parents:
diff changeset
    14
#include "../cargotype.h"
c359062b4db0 (svn r12511) [NoAI] -Add (WIP): AI Debug GUI. For now it is a stripped down copy of performance details. In future it will allow reloading of AI, changing settings, and reading the log of the AI
truebrain
parents:
diff changeset
    15
#include "../strings_func.h"
c359062b4db0 (svn r12511) [NoAI] -Add (WIP): AI Debug GUI. For now it is a stripped down copy of performance details. In future it will allow reloading of AI, changing settings, and reading the log of the AI
truebrain
parents:
diff changeset
    16
#include "../core/alloc_func.hpp"
c359062b4db0 (svn r12511) [NoAI] -Add (WIP): AI Debug GUI. For now it is a stripped down copy of performance details. In future it will allow reloading of AI, changing settings, and reading the log of the AI
truebrain
parents:
diff changeset
    17
#include "../window_func.h"
c359062b4db0 (svn r12511) [NoAI] -Add (WIP): AI Debug GUI. For now it is a stripped down copy of performance details. In future it will allow reloading of AI, changing settings, and reading the log of the AI
truebrain
parents:
diff changeset
    18
#include "../date_func.h"
c359062b4db0 (svn r12511) [NoAI] -Add (WIP): AI Debug GUI. For now it is a stripped down copy of performance details. In future it will allow reloading of AI, changing settings, and reading the log of the AI
truebrain
parents:
diff changeset
    19
#include "../gfx_func.h"
c359062b4db0 (svn r12511) [NoAI] -Add (WIP): AI Debug GUI. For now it is a stripped down copy of performance details. In future it will allow reloading of AI, changing settings, and reading the log of the AI
truebrain
parents:
diff changeset
    20
#include "../debug.h"
10188
13e73691378a (svn r12719) [NoAI] -Add: finished the Reload AI button in AIDebug Window.
truebrain
parents: 9851
diff changeset
    21
#include "../command_func.h"
10643
970417eef395 (svn r13187) [NoAI] -Codechange: rewrote the AI register part; C++ AIs are completely impossible now, and registration happens directly via AISquirrel. This cleans up the registration flow, and makes everything readable again, as sure I made a mess out of it :)
truebrain
parents: 10514
diff changeset
    22
10188
13e73691378a (svn r12719) [NoAI] -Add: finished the Reload AI button in AIDebug Window.
truebrain
parents: 9851
diff changeset
    23
#include "ai.h"
10643
970417eef395 (svn r13187) [NoAI] -Codechange: rewrote the AI register part; C++ AIs are completely impossible now, and registration happens directly via AISquirrel. This cleans up the registration flow, and makes everything readable again, as sure I made a mess out of it :)
truebrain
parents: 10514
diff changeset
    24
#include "api/ai_types.hpp"
970417eef395 (svn r13187) [NoAI] -Codechange: rewrote the AI register part; C++ AIs are completely impossible now, and registration happens directly via AISquirrel. This cleans up the registration flow, and makes everything readable again, as sure I made a mess out of it :)
truebrain
parents: 10514
diff changeset
    25
#include "api/ai_controller.hpp"
9851
a5f5a7cf2b61 (svn r12519) [NoAI] -Add: added AILog with Info(), Warning(), and Error()
truebrain
parents: 9846
diff changeset
    26
#include "api/ai_object.hpp"
a5f5a7cf2b61 (svn r12519) [NoAI] -Add: added AILog with Info(), Warning(), and Error()
truebrain
parents: 9846
diff changeset
    27
#include "api/ai_log.hpp"
10643
970417eef395 (svn r13187) [NoAI] -Codechange: rewrote the AI register part; C++ AIs are completely impossible now, and registration happens directly via AISquirrel. This cleans up the registration flow, and makes everything readable again, as sure I made a mess out of it :)
truebrain
parents: 10514
diff changeset
    28
#include "ai_info.hpp"
9845
c359062b4db0 (svn r12511) [NoAI] -Add (WIP): AI Debug GUI. For now it is a stripped down copy of performance details. In future it will allow reloading of AI, changing settings, and reading the log of the AI
truebrain
parents:
diff changeset
    29
c359062b4db0 (svn r12511) [NoAI] -Add (WIP): AI Debug GUI. For now it is a stripped down copy of performance details. In future it will allow reloading of AI, changing settings, and reading the log of the AI
truebrain
parents:
diff changeset
    30
#include "table/strings.h"
c359062b4db0 (svn r12511) [NoAI] -Add (WIP): AI Debug GUI. For now it is a stripped down copy of performance details. In future it will allow reloading of AI, changing settings, and reading the log of the AI
truebrain
parents:
diff changeset
    31
#include "../table/sprites.h"
c359062b4db0 (svn r12511) [NoAI] -Add (WIP): AI Debug GUI. For now it is a stripped down copy of performance details. In future it will allow reloading of AI, changing settings, and reading the log of the AI
truebrain
parents:
diff changeset
    32
10643
970417eef395 (svn r13187) [NoAI] -Codechange: rewrote the AI register part; C++ AIs are completely impossible now, and registration happens directly via AISquirrel. This cleans up the registration flow, and makes everything readable again, as sure I made a mess out of it :)
truebrain
parents: 10514
diff changeset
    33
extern AIInfo *AI_GetPlayerInfo(PlayerID player);
9845
c359062b4db0 (svn r12511) [NoAI] -Add (WIP): AI Debug GUI. For now it is a stripped down copy of performance details. In future it will allow reloading of AI, changing settings, and reading the log of the AI
truebrain
parents:
diff changeset
    34
10514
8d9dbe82af3c (svn r13057) [NoAI] -Codechange: port the AIDebugWindow to the new Window framework.
rubidium
parents: 10513
diff changeset
    35
struct AIDebugWindow : public Window {
8d9dbe82af3c (svn r13057) [NoAI] -Codechange: port the AIDebugWindow to the new Window framework.
rubidium
parents: 10513
diff changeset
    36
	enum AIDebugWindowWidgets {
8d9dbe82af3c (svn r13057) [NoAI] -Codechange: port the AIDebugWindow to the new Window framework.
rubidium
parents: 10513
diff changeset
    37
		AID_WIDGET_CLOSEBOX = 0,
8d9dbe82af3c (svn r13057) [NoAI] -Codechange: port the AIDebugWindow to the new Window framework.
rubidium
parents: 10513
diff changeset
    38
		AID_WIDGET_CAPTION,
8d9dbe82af3c (svn r13057) [NoAI] -Codechange: port the AIDebugWindow to the new Window framework.
rubidium
parents: 10513
diff changeset
    39
		AID_WIDGET_VIEW,
8d9dbe82af3c (svn r13057) [NoAI] -Codechange: port the AIDebugWindow to the new Window framework.
rubidium
parents: 10513
diff changeset
    40
		AID_WIDGET_NAME_TEXT,
8d9dbe82af3c (svn r13057) [NoAI] -Codechange: port the AIDebugWindow to the new Window framework.
rubidium
parents: 10513
diff changeset
    41
		AID_WIDGET_RELOAD_TOGGLE,
8d9dbe82af3c (svn r13057) [NoAI] -Codechange: port the AIDebugWindow to the new Window framework.
rubidium
parents: 10513
diff changeset
    42
		AID_WIDGET_LOG_PANEL,
10750
e2c339d613d1 (svn r13300) [NoAI] -Add: a scrollbar in AIDebug window.
glx
parents: 10739
diff changeset
    43
		AID_WIDGET_SCROLLBAR,
10514
8d9dbe82af3c (svn r13057) [NoAI] -Codechange: port the AIDebugWindow to the new Window framework.
rubidium
parents: 10513
diff changeset
    44
		AID_WIDGET_UNUSED_1,
8d9dbe82af3c (svn r13057) [NoAI] -Codechange: port the AIDebugWindow to the new Window framework.
rubidium
parents: 10513
diff changeset
    45
		AID_WIDGET_UNUSED_2,
8d9dbe82af3c (svn r13057) [NoAI] -Codechange: port the AIDebugWindow to the new Window framework.
rubidium
parents: 10513
diff changeset
    46
		AID_WIDGET_UNUSED_3,
8d9dbe82af3c (svn r13057) [NoAI] -Codechange: port the AIDebugWindow to the new Window framework.
rubidium
parents: 10513
diff changeset
    47
		AID_WIDGET_UNUSED_4,
8d9dbe82af3c (svn r13057) [NoAI] -Codechange: port the AIDebugWindow to the new Window framework.
rubidium
parents: 10513
diff changeset
    48
		AID_WIDGET_UNUSED_5,
8d9dbe82af3c (svn r13057) [NoAI] -Codechange: port the AIDebugWindow to the new Window framework.
rubidium
parents: 10513
diff changeset
    49
		AID_WIDGET_UNUSED_6,
8d9dbe82af3c (svn r13057) [NoAI] -Codechange: port the AIDebugWindow to the new Window framework.
rubidium
parents: 10513
diff changeset
    50
		AID_WIDGET_UNUSED_7,
9845
c359062b4db0 (svn r12511) [NoAI] -Add (WIP): AI Debug GUI. For now it is a stripped down copy of performance details. In future it will allow reloading of AI, changing settings, and reading the log of the AI
truebrain
parents:
diff changeset
    51
10514
8d9dbe82af3c (svn r13057) [NoAI] -Codechange: port the AIDebugWindow to the new Window framework.
rubidium
parents: 10513
diff changeset
    52
		AID_WIDGET_COMPANY_BUTTON_START,
10804
a02ab0ca5ae9 (svn r13355) [NoAI] -Fix (r13300): GUI glitches caused by too much 'optimisation'
glx
parents: 10750
diff changeset
    53
		AID_WIDGET_COMPANY_BUTTON_END = AID_WIDGET_COMPANY_BUTTON_START + 7,
10514
8d9dbe82af3c (svn r13057) [NoAI] -Codechange: port the AIDebugWindow to the new Window framework.
rubidium
parents: 10513
diff changeset
    54
	};
9845
c359062b4db0 (svn r12511) [NoAI] -Add (WIP): AI Debug GUI. For now it is a stripped down copy of performance details. In future it will allow reloading of AI, changing settings, and reading the log of the AI
truebrain
parents:
diff changeset
    55
10514
8d9dbe82af3c (svn r13057) [NoAI] -Codechange: port the AIDebugWindow to the new Window framework.
rubidium
parents: 10513
diff changeset
    56
	static PlayerID ai_debug_player;
8d9dbe82af3c (svn r13057) [NoAI] -Codechange: port the AIDebugWindow to the new Window framework.
rubidium
parents: 10513
diff changeset
    57
	int redraw_timer;
9845
c359062b4db0 (svn r12511) [NoAI] -Add (WIP): AI Debug GUI. For now it is a stripped down copy of performance details. In future it will allow reloading of AI, changing settings, and reading the log of the AI
truebrain
parents:
diff changeset
    58
10645
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10643
diff changeset
    59
	AIDebugWindow(const WindowDesc *desc, WindowNumber number) : Window(desc, number)
10514
8d9dbe82af3c (svn r13057) [NoAI] -Codechange: port the AIDebugWindow to the new Window framework.
rubidium
parents: 10513
diff changeset
    60
	{
8d9dbe82af3c (svn r13057) [NoAI] -Codechange: port the AIDebugWindow to the new Window framework.
rubidium
parents: 10513
diff changeset
    61
		/* Disable the players who are not active or not an AI */
8d9dbe82af3c (svn r13057) [NoAI] -Codechange: port the AIDebugWindow to the new Window framework.
rubidium
parents: 10513
diff changeset
    62
		for (PlayerID i = PLAYER_FIRST; i < MAX_PLAYERS; i++) {
8d9dbe82af3c (svn r13057) [NoAI] -Codechange: port the AIDebugWindow to the new Window framework.
rubidium
parents: 10513
diff changeset
    63
			this->SetWidgetDisabledState(i + AID_WIDGET_COMPANY_BUTTON_START, !GetPlayer(i)->is_active || !GetPlayer(i)->is_ai);
8d9dbe82af3c (svn r13057) [NoAI] -Codechange: port the AIDebugWindow to the new Window framework.
rubidium
parents: 10513
diff changeset
    64
		}
8d9dbe82af3c (svn r13057) [NoAI] -Codechange: port the AIDebugWindow to the new Window framework.
rubidium
parents: 10513
diff changeset
    65
		this->DisableWidget(AID_WIDGET_RELOAD_TOGGLE);
9845
c359062b4db0 (svn r12511) [NoAI] -Add (WIP): AI Debug GUI. For now it is a stripped down copy of performance details. In future it will allow reloading of AI, changing settings, and reading the log of the AI
truebrain
parents:
diff changeset
    66
10750
e2c339d613d1 (svn r13300) [NoAI] -Add: a scrollbar in AIDebug window.
glx
parents: 10739
diff changeset
    67
		this->vscroll.cap = 14;
e2c339d613d1 (svn r13300) [NoAI] -Add: a scrollbar in AIDebug window.
glx
parents: 10739
diff changeset
    68
		this->vscroll.pos = 0;
e2c339d613d1 (svn r13300) [NoAI] -Add: a scrollbar in AIDebug window.
glx
parents: 10739
diff changeset
    69
		this->resize.step_height = 12;
e2c339d613d1 (svn r13300) [NoAI] -Add: a scrollbar in AIDebug window.
glx
parents: 10739
diff changeset
    70
10514
8d9dbe82af3c (svn r13057) [NoAI] -Codechange: port the AIDebugWindow to the new Window framework.
rubidium
parents: 10513
diff changeset
    71
		if (ai_debug_player != INVALID_PLAYER) this->LowerWidget(ai_debug_player + AID_WIDGET_COMPANY_BUTTON_START);
8d9dbe82af3c (svn r13057) [NoAI] -Codechange: port the AIDebugWindow to the new Window framework.
rubidium
parents: 10513
diff changeset
    72
8d9dbe82af3c (svn r13057) [NoAI] -Codechange: port the AIDebugWindow to the new Window framework.
rubidium
parents: 10513
diff changeset
    73
		this->FindWindowPlacementAndResize(desc);
8d9dbe82af3c (svn r13057) [NoAI] -Codechange: port the AIDebugWindow to the new Window framework.
rubidium
parents: 10513
diff changeset
    74
	}
8d9dbe82af3c (svn r13057) [NoAI] -Codechange: port the AIDebugWindow to the new Window framework.
rubidium
parents: 10513
diff changeset
    75
8d9dbe82af3c (svn r13057) [NoAI] -Codechange: port the AIDebugWindow to the new Window framework.
rubidium
parents: 10513
diff changeset
    76
	virtual void OnPaint()
8d9dbe82af3c (svn r13057) [NoAI] -Codechange: port the AIDebugWindow to the new Window framework.
rubidium
parents: 10513
diff changeset
    77
	{
8d9dbe82af3c (svn r13057) [NoAI] -Codechange: port the AIDebugWindow to the new Window framework.
rubidium
parents: 10513
diff changeset
    78
		/* Check if the currently selected player is still active. */
8d9dbe82af3c (svn r13057) [NoAI] -Codechange: port the AIDebugWindow to the new Window framework.
rubidium
parents: 10513
diff changeset
    79
		if (ai_debug_player == INVALID_PLAYER || !GetPlayer(ai_debug_player)->is_active) {
8d9dbe82af3c (svn r13057) [NoAI] -Codechange: port the AIDebugWindow to the new Window framework.
rubidium
parents: 10513
diff changeset
    80
			if (ai_debug_player != INVALID_PLAYER) {
8d9dbe82af3c (svn r13057) [NoAI] -Codechange: port the AIDebugWindow to the new Window framework.
rubidium
parents: 10513
diff changeset
    81
				/* Raise and disable the widget for the previous selection. */
8d9dbe82af3c (svn r13057) [NoAI] -Codechange: port the AIDebugWindow to the new Window framework.
rubidium
parents: 10513
diff changeset
    82
				this->RaiseWidget(ai_debug_player + AID_WIDGET_COMPANY_BUTTON_START);
8d9dbe82af3c (svn r13057) [NoAI] -Codechange: port the AIDebugWindow to the new Window framework.
rubidium
parents: 10513
diff changeset
    83
				this->DisableWidget(ai_debug_player + AID_WIDGET_COMPANY_BUTTON_START);
8d9dbe82af3c (svn r13057) [NoAI] -Codechange: port the AIDebugWindow to the new Window framework.
rubidium
parents: 10513
diff changeset
    84
8d9dbe82af3c (svn r13057) [NoAI] -Codechange: port the AIDebugWindow to the new Window framework.
rubidium
parents: 10513
diff changeset
    85
				ai_debug_player = INVALID_PLAYER;
10385
4547ef131005 (svn r12927) [NoAI] -Fix: don't crash on the GUI when an AI failed to compile and you still manual it (bug by glx)
truebrain
parents: 10188
diff changeset
    86
			}
9845
c359062b4db0 (svn r12511) [NoAI] -Add (WIP): AI Debug GUI. For now it is a stripped down copy of performance details. In future it will allow reloading of AI, changing settings, and reading the log of the AI
truebrain
parents:
diff changeset
    87
10514
8d9dbe82af3c (svn r13057) [NoAI] -Codechange: port the AIDebugWindow to the new Window framework.
rubidium
parents: 10513
diff changeset
    88
			for (PlayerID i = PLAYER_FIRST; i < MAX_PLAYERS; i++) {
8d9dbe82af3c (svn r13057) [NoAI] -Codechange: port the AIDebugWindow to the new Window framework.
rubidium
parents: 10513
diff changeset
    89
				if (GetPlayer(i)->is_active && GetPlayer(i)->is_ai) {
8d9dbe82af3c (svn r13057) [NoAI] -Codechange: port the AIDebugWindow to the new Window framework.
rubidium
parents: 10513
diff changeset
    90
					/* Lower the widget corresponding to this player. */
8d9dbe82af3c (svn r13057) [NoAI] -Codechange: port the AIDebugWindow to the new Window framework.
rubidium
parents: 10513
diff changeset
    91
					this->LowerWidget(i + AID_WIDGET_COMPANY_BUTTON_START);
9851
a5f5a7cf2b61 (svn r12519) [NoAI] -Add: added AILog with Info(), Warning(), and Error()
truebrain
parents: 9846
diff changeset
    92
10514
8d9dbe82af3c (svn r13057) [NoAI] -Codechange: port the AIDebugWindow to the new Window framework.
rubidium
parents: 10513
diff changeset
    93
					ai_debug_player = i;
8d9dbe82af3c (svn r13057) [NoAI] -Codechange: port the AIDebugWindow to the new Window framework.
rubidium
parents: 10513
diff changeset
    94
					break;
9845
c359062b4db0 (svn r12511) [NoAI] -Add (WIP): AI Debug GUI. For now it is a stripped down copy of performance details. In future it will allow reloading of AI, changing settings, and reading the log of the AI
truebrain
parents:
diff changeset
    95
				}
c359062b4db0 (svn r12511) [NoAI] -Add (WIP): AI Debug GUI. For now it is a stripped down copy of performance details. In future it will allow reloading of AI, changing settings, and reading the log of the AI
truebrain
parents:
diff changeset
    96
			}
c359062b4db0 (svn r12511) [NoAI] -Add (WIP): AI Debug GUI. For now it is a stripped down copy of performance details. In future it will allow reloading of AI, changing settings, and reading the log of the AI
truebrain
parents:
diff changeset
    97
		}
c359062b4db0 (svn r12511) [NoAI] -Add (WIP): AI Debug GUI. For now it is a stripped down copy of performance details. In future it will allow reloading of AI, changing settings, and reading the log of the AI
truebrain
parents:
diff changeset
    98
10738
b9a7a803ee61 (svn r13288) [NoAI] -Fix: 'Reload AI' button could be disabled when it should be enabled
glx
parents: 10653
diff changeset
    99
		/* Update "Reload AI" button */
b9a7a803ee61 (svn r13288) [NoAI] -Fix: 'Reload AI' button could be disabled when it should be enabled
glx
parents: 10653
diff changeset
   100
		this->SetWidgetDisabledState(AID_WIDGET_RELOAD_TOGGLE, ai_debug_player == INVALID_PLAYER);
b9a7a803ee61 (svn r13288) [NoAI] -Fix: 'Reload AI' button could be disabled when it should be enabled
glx
parents: 10653
diff changeset
   101
b9a7a803ee61 (svn r13288) [NoAI] -Fix: 'Reload AI' button could be disabled when it should be enabled
glx
parents: 10653
diff changeset
   102
		/* Draw standard stuff */
b9a7a803ee61 (svn r13288) [NoAI] -Fix: 'Reload AI' button could be disabled when it should be enabled
glx
parents: 10653
diff changeset
   103
		this->DrawWidgets();
b9a7a803ee61 (svn r13288) [NoAI] -Fix: 'Reload AI' button could be disabled when it should be enabled
glx
parents: 10653
diff changeset
   104
10514
8d9dbe82af3c (svn r13057) [NoAI] -Codechange: port the AIDebugWindow to the new Window framework.
rubidium
parents: 10513
diff changeset
   105
		/* If there are no active players, don't display anything else. */
8d9dbe82af3c (svn r13057) [NoAI] -Codechange: port the AIDebugWindow to the new Window framework.
rubidium
parents: 10513
diff changeset
   106
		if (ai_debug_player == INVALID_PLAYER) return;
9845
c359062b4db0 (svn r12511) [NoAI] -Add (WIP): AI Debug GUI. For now it is a stripped down copy of performance details. In future it will allow reloading of AI, changing settings, and reading the log of the AI
truebrain
parents:
diff changeset
   107
10514
8d9dbe82af3c (svn r13057) [NoAI] -Codechange: port the AIDebugWindow to the new Window framework.
rubidium
parents: 10513
diff changeset
   108
		/* Paint the player icons */
8d9dbe82af3c (svn r13057) [NoAI] -Codechange: port the AIDebugWindow to the new Window framework.
rubidium
parents: 10513
diff changeset
   109
		for (PlayerID i = PLAYER_FIRST; i < MAX_PLAYERS; i++) {
8d9dbe82af3c (svn r13057) [NoAI] -Codechange: port the AIDebugWindow to the new Window framework.
rubidium
parents: 10513
diff changeset
   110
			if (!GetPlayer(i)->is_active || !GetPlayer(i)->is_ai) {
8d9dbe82af3c (svn r13057) [NoAI] -Codechange: port the AIDebugWindow to the new Window framework.
rubidium
parents: 10513
diff changeset
   111
				/* Check if we have the player as an active player */
8d9dbe82af3c (svn r13057) [NoAI] -Codechange: port the AIDebugWindow to the new Window framework.
rubidium
parents: 10513
diff changeset
   112
				if (!this->IsWidgetDisabled(i + AID_WIDGET_COMPANY_BUTTON_START)) {
8d9dbe82af3c (svn r13057) [NoAI] -Codechange: port the AIDebugWindow to the new Window framework.
rubidium
parents: 10513
diff changeset
   113
					/* Bah, player gone :( */
8d9dbe82af3c (svn r13057) [NoAI] -Codechange: port the AIDebugWindow to the new Window framework.
rubidium
parents: 10513
diff changeset
   114
					this->DisableWidget(i + AID_WIDGET_COMPANY_BUTTON_START);
9845
c359062b4db0 (svn r12511) [NoAI] -Add (WIP): AI Debug GUI. For now it is a stripped down copy of performance details. In future it will allow reloading of AI, changing settings, and reading the log of the AI
truebrain
parents:
diff changeset
   115
10514
8d9dbe82af3c (svn r13057) [NoAI] -Codechange: port the AIDebugWindow to the new Window framework.
rubidium
parents: 10513
diff changeset
   116
					/* We need a repaint */
8d9dbe82af3c (svn r13057) [NoAI] -Codechange: port the AIDebugWindow to the new Window framework.
rubidium
parents: 10513
diff changeset
   117
					this->SetDirty();
9845
c359062b4db0 (svn r12511) [NoAI] -Add (WIP): AI Debug GUI. For now it is a stripped down copy of performance details. In future it will allow reloading of AI, changing settings, and reading the log of the AI
truebrain
parents:
diff changeset
   118
				}
10514
8d9dbe82af3c (svn r13057) [NoAI] -Codechange: port the AIDebugWindow to the new Window framework.
rubidium
parents: 10513
diff changeset
   119
				continue;
9845
c359062b4db0 (svn r12511) [NoAI] -Add (WIP): AI Debug GUI. For now it is a stripped down copy of performance details. In future it will allow reloading of AI, changing settings, and reading the log of the AI
truebrain
parents:
diff changeset
   120
			}
c359062b4db0 (svn r12511) [NoAI] -Add (WIP): AI Debug GUI. For now it is a stripped down copy of performance details. In future it will allow reloading of AI, changing settings, and reading the log of the AI
truebrain
parents:
diff changeset
   121
10514
8d9dbe82af3c (svn r13057) [NoAI] -Codechange: port the AIDebugWindow to the new Window framework.
rubidium
parents: 10513
diff changeset
   122
			/* Check if we have the player marked as inactive */
8d9dbe82af3c (svn r13057) [NoAI] -Codechange: port the AIDebugWindow to the new Window framework.
rubidium
parents: 10513
diff changeset
   123
			if (this->IsWidgetDisabled(i + AID_WIDGET_COMPANY_BUTTON_START)) {
8d9dbe82af3c (svn r13057) [NoAI] -Codechange: port the AIDebugWindow to the new Window framework.
rubidium
parents: 10513
diff changeset
   124
				/* New AI! Yippie :p */
8d9dbe82af3c (svn r13057) [NoAI] -Codechange: port the AIDebugWindow to the new Window framework.
rubidium
parents: 10513
diff changeset
   125
				this->EnableWidget(i + AID_WIDGET_COMPANY_BUTTON_START);
10738
b9a7a803ee61 (svn r13288) [NoAI] -Fix: 'Reload AI' button could be disabled when it should be enabled
glx
parents: 10653
diff changeset
   126
10514
8d9dbe82af3c (svn r13057) [NoAI] -Codechange: port the AIDebugWindow to the new Window framework.
rubidium
parents: 10513
diff changeset
   127
				/* We need a repaint */
8d9dbe82af3c (svn r13057) [NoAI] -Codechange: port the AIDebugWindow to the new Window framework.
rubidium
parents: 10513
diff changeset
   128
				this->SetDirty();
8d9dbe82af3c (svn r13057) [NoAI] -Codechange: port the AIDebugWindow to the new Window framework.
rubidium
parents: 10513
diff changeset
   129
			}
9845
c359062b4db0 (svn r12511) [NoAI] -Add (WIP): AI Debug GUI. For now it is a stripped down copy of performance details. In future it will allow reloading of AI, changing settings, and reading the log of the AI
truebrain
parents:
diff changeset
   130
10514
8d9dbe82af3c (svn r13057) [NoAI] -Codechange: port the AIDebugWindow to the new Window framework.
rubidium
parents: 10513
diff changeset
   131
			byte x = (i == ai_debug_player) ? 1 : 0;
8d9dbe82af3c (svn r13057) [NoAI] -Codechange: port the AIDebugWindow to the new Window framework.
rubidium
parents: 10513
diff changeset
   132
			DrawPlayerIcon(i, i * 37 + 13 + x, 16 + x);
8d9dbe82af3c (svn r13057) [NoAI] -Codechange: port the AIDebugWindow to the new Window framework.
rubidium
parents: 10513
diff changeset
   133
		}
8d9dbe82af3c (svn r13057) [NoAI] -Codechange: port the AIDebugWindow to the new Window framework.
rubidium
parents: 10513
diff changeset
   134
10738
b9a7a803ee61 (svn r13288) [NoAI] -Fix: 'Reload AI' button could be disabled when it should be enabled
glx
parents: 10653
diff changeset
   135
		/* Draw the AI name */
10643
970417eef395 (svn r13187) [NoAI] -Codechange: rewrote the AI register part; C++ AIs are completely impossible now, and registration happens directly via AISquirrel. This cleans up the registration flow, and makes everything readable again, as sure I made a mess out of it :)
truebrain
parents: 10514
diff changeset
   136
		AIInfo *info = AI_GetPlayerInfo(ai_debug_player);
10738
b9a7a803ee61 (svn r13288) [NoAI] -Fix: 'Reload AI' button could be disabled when it should be enabled
glx
parents: 10653
diff changeset
   137
		assert(info != NULL);
b9a7a803ee61 (svn r13288) [NoAI] -Fix: 'Reload AI' button could be disabled when it should be enabled
glx
parents: 10653
diff changeset
   138
		DoDrawString(info->GetName(), 7, 34, TC_BLACK);
10514
8d9dbe82af3c (svn r13057) [NoAI] -Codechange: port the AIDebugWindow to the new Window framework.
rubidium
parents: 10513
diff changeset
   139
8d9dbe82af3c (svn r13057) [NoAI] -Codechange: port the AIDebugWindow to the new Window framework.
rubidium
parents: 10513
diff changeset
   140
		PlayerID old_cp = _current_player;
8d9dbe82af3c (svn r13057) [NoAI] -Codechange: port the AIDebugWindow to the new Window framework.
rubidium
parents: 10513
diff changeset
   141
		_current_player = ai_debug_player;
10750
e2c339d613d1 (svn r13300) [NoAI] -Add: a scrollbar in AIDebug window.
glx
parents: 10739
diff changeset
   142
		AILog::LogData *log = (AILog::LogData *)AIObject::GetLogPointer();
e2c339d613d1 (svn r13300) [NoAI] -Add: a scrollbar in AIDebug window.
glx
parents: 10739
diff changeset
   143
		_current_player = old_cp;
10514
8d9dbe82af3c (svn r13057) [NoAI] -Codechange: port the AIDebugWindow to the new Window framework.
rubidium
parents: 10513
diff changeset
   144
10804
a02ab0ca5ae9 (svn r13355) [NoAI] -Fix (r13300): GUI glitches caused by too much 'optimisation'
glx
parents: 10750
diff changeset
   145
		SetVScrollCount(this, (log == NULL) ? 0 : log->used);
a02ab0ca5ae9 (svn r13355) [NoAI] -Fix (r13300): GUI glitches caused by too much 'optimisation'
glx
parents: 10750
diff changeset
   146
		this->InvalidateWidget(AID_WIDGET_SCROLLBAR);
10750
e2c339d613d1 (svn r13300) [NoAI] -Add: a scrollbar in AIDebug window.
glx
parents: 10739
diff changeset
   147
		if (log == NULL) return;
10514
8d9dbe82af3c (svn r13057) [NoAI] -Codechange: port the AIDebugWindow to the new Window framework.
rubidium
parents: 10513
diff changeset
   148
10750
e2c339d613d1 (svn r13300) [NoAI] -Add: a scrollbar in AIDebug window.
glx
parents: 10739
diff changeset
   149
		int y = 6;
e2c339d613d1 (svn r13300) [NoAI] -Add: a scrollbar in AIDebug window.
glx
parents: 10739
diff changeset
   150
		for (int i = this->vscroll.pos; i < (this->vscroll.cap + this->vscroll.pos); i++) {
10514
8d9dbe82af3c (svn r13057) [NoAI] -Codechange: port the AIDebugWindow to the new Window framework.
rubidium
parents: 10513
diff changeset
   151
			uint pos = (log->count + log->pos - i) % log->count;
10650
30fc5395b1b8 (svn r13194) [NoAI] -Change [API CHANGE]: split 'main.nut' in 'info.nut' and 'main.nut'. The first contains the information about the AI, the second the AI. This avoid several problems we had. It also speeds up OpenTTD start-up.
truebrain
parents: 10645
diff changeset
   152
			if (log->lines[pos] == NULL) break;
10514
8d9dbe82af3c (svn r13057) [NoAI] -Codechange: port the AIDebugWindow to the new Window framework.
rubidium
parents: 10513
diff changeset
   153
8d9dbe82af3c (svn r13057) [NoAI] -Codechange: port the AIDebugWindow to the new Window framework.
rubidium
parents: 10513
diff changeset
   154
			uint colour;
8d9dbe82af3c (svn r13057) [NoAI] -Codechange: port the AIDebugWindow to the new Window framework.
rubidium
parents: 10513
diff changeset
   155
			switch (log->type[pos]) {
8d9dbe82af3c (svn r13057) [NoAI] -Codechange: port the AIDebugWindow to the new Window framework.
rubidium
parents: 10513
diff changeset
   156
				case AILog::LOG_SQ_INFO:  colour = TC_BLACK;  break;
8d9dbe82af3c (svn r13057) [NoAI] -Codechange: port the AIDebugWindow to the new Window framework.
rubidium
parents: 10513
diff changeset
   157
				case AILog::LOG_SQ_ERROR: colour = TC_RED;    break;
8d9dbe82af3c (svn r13057) [NoAI] -Codechange: port the AIDebugWindow to the new Window framework.
rubidium
parents: 10513
diff changeset
   158
				case AILog::LOG_INFO:     colour = TC_BLACK;  break;
8d9dbe82af3c (svn r13057) [NoAI] -Codechange: port the AIDebugWindow to the new Window framework.
rubidium
parents: 10513
diff changeset
   159
				case AILog::LOG_WARNING:  colour = TC_YELLOW; break;
8d9dbe82af3c (svn r13057) [NoAI] -Codechange: port the AIDebugWindow to the new Window framework.
rubidium
parents: 10513
diff changeset
   160
				case AILog::LOG_ERROR:    colour = TC_RED;    break;
8d9dbe82af3c (svn r13057) [NoAI] -Codechange: port the AIDebugWindow to the new Window framework.
rubidium
parents: 10513
diff changeset
   161
				default:                  colour = TC_BLACK;  break;
8d9dbe82af3c (svn r13057) [NoAI] -Codechange: port the AIDebugWindow to the new Window framework.
rubidium
parents: 10513
diff changeset
   162
			}
8d9dbe82af3c (svn r13057) [NoAI] -Codechange: port the AIDebugWindow to the new Window framework.
rubidium
parents: 10513
diff changeset
   163
10750
e2c339d613d1 (svn r13300) [NoAI] -Add: a scrollbar in AIDebug window.
glx
parents: 10739
diff changeset
   164
			DoDrawStringTruncated(log->lines[pos], 7, this->widget[AID_WIDGET_LOG_PANEL].top + y, colour, this->widget[AID_WIDGET_LOG_PANEL].right - this->widget[AID_WIDGET_LOG_PANEL].left - 14);
e2c339d613d1 (svn r13300) [NoAI] -Add: a scrollbar in AIDebug window.
glx
parents: 10739
diff changeset
   165
			y += 12;
10514
8d9dbe82af3c (svn r13057) [NoAI] -Codechange: port the AIDebugWindow to the new Window framework.
rubidium
parents: 10513
diff changeset
   166
		}
9845
c359062b4db0 (svn r12511) [NoAI] -Add (WIP): AI Debug GUI. For now it is a stripped down copy of performance details. In future it will allow reloading of AI, changing settings, and reading the log of the AI
truebrain
parents:
diff changeset
   167
	}
10514
8d9dbe82af3c (svn r13057) [NoAI] -Codechange: port the AIDebugWindow to the new Window framework.
rubidium
parents: 10513
diff changeset
   168
8d9dbe82af3c (svn r13057) [NoAI] -Codechange: port the AIDebugWindow to the new Window framework.
rubidium
parents: 10513
diff changeset
   169
	virtual void OnClick(Point pt, int widget)
8d9dbe82af3c (svn r13057) [NoAI] -Codechange: port the AIDebugWindow to the new Window framework.
rubidium
parents: 10513
diff changeset
   170
	{
8d9dbe82af3c (svn r13057) [NoAI] -Codechange: port the AIDebugWindow to the new Window framework.
rubidium
parents: 10513
diff changeset
   171
		/* Check which button is clicked */
10874
705f4caa0796 (svn r13425) [NoAI] -Fix (r13355): obiwan in AIDebug window
glx
parents: 10804
diff changeset
   172
		if (IsInsideMM(widget, AID_WIDGET_COMPANY_BUTTON_START, AID_WIDGET_COMPANY_BUTTON_END + 1)) {
10514
8d9dbe82af3c (svn r13057) [NoAI] -Codechange: port the AIDebugWindow to the new Window framework.
rubidium
parents: 10513
diff changeset
   173
			/* Is it no on disable? */
8d9dbe82af3c (svn r13057) [NoAI] -Codechange: port the AIDebugWindow to the new Window framework.
rubidium
parents: 10513
diff changeset
   174
			if (!this->IsWidgetDisabled(widget)) {
8d9dbe82af3c (svn r13057) [NoAI] -Codechange: port the AIDebugWindow to the new Window framework.
rubidium
parents: 10513
diff changeset
   175
				this->RaiseWidget(ai_debug_player + AID_WIDGET_COMPANY_BUTTON_START);
8d9dbe82af3c (svn r13057) [NoAI] -Codechange: port the AIDebugWindow to the new Window framework.
rubidium
parents: 10513
diff changeset
   176
				ai_debug_player = (PlayerID)(widget - AID_WIDGET_COMPANY_BUTTON_START);
8d9dbe82af3c (svn r13057) [NoAI] -Codechange: port the AIDebugWindow to the new Window framework.
rubidium
parents: 10513
diff changeset
   177
				this->LowerWidget(ai_debug_player + AID_WIDGET_COMPANY_BUTTON_START);
8d9dbe82af3c (svn r13057) [NoAI] -Codechange: port the AIDebugWindow to the new Window framework.
rubidium
parents: 10513
diff changeset
   178
				this->SetDirty();
8d9dbe82af3c (svn r13057) [NoAI] -Codechange: port the AIDebugWindow to the new Window framework.
rubidium
parents: 10513
diff changeset
   179
			}
8d9dbe82af3c (svn r13057) [NoAI] -Codechange: port the AIDebugWindow to the new Window framework.
rubidium
parents: 10513
diff changeset
   180
		}
8d9dbe82af3c (svn r13057) [NoAI] -Codechange: port the AIDebugWindow to the new Window framework.
rubidium
parents: 10513
diff changeset
   181
		if (widget == AID_WIDGET_RELOAD_TOGGLE && !this->IsWidgetDisabled(widget)) {
8d9dbe82af3c (svn r13057) [NoAI] -Codechange: port the AIDebugWindow to the new Window framework.
rubidium
parents: 10513
diff changeset
   182
			/* Set the current AI as forced next AI */
10643
970417eef395 (svn r13187) [NoAI] -Codechange: rewrote the AI register part; C++ AIs are completely impossible now, and registration happens directly via AISquirrel. This cleans up the registration flow, and makes everything readable again, as sure I made a mess out of it :)
truebrain
parents: 10514
diff changeset
   183
			AIInfo *info = AI_GetPlayerInfo(ai_debug_player);
10939
e7693a7bb280 (svn r13493) [NoAI] -Fix: ReloadAI should reload the AI correctly, no matter what you named your dir
truebrain
parents: 10874
diff changeset
   184
			AI_ForceAI(info->GetDirName());
10514
8d9dbe82af3c (svn r13057) [NoAI] -Codechange: port the AIDebugWindow to the new Window framework.
rubidium
parents: 10513
diff changeset
   185
8d9dbe82af3c (svn r13057) [NoAI] -Codechange: port the AIDebugWindow to the new Window framework.
rubidium
parents: 10513
diff changeset
   186
			/* First kill the company of the AI, then start a new one. This should start the current AI again */
8d9dbe82af3c (svn r13057) [NoAI] -Codechange: port the AIDebugWindow to the new Window framework.
rubidium
parents: 10513
diff changeset
   187
			DoCommandP(0, 2, ai_debug_player, NULL, CMD_PLAYER_CTRL);
8d9dbe82af3c (svn r13057) [NoAI] -Codechange: port the AIDebugWindow to the new Window framework.
rubidium
parents: 10513
diff changeset
   188
			DoCommandP(0, 1, 0, NULL, CMD_PLAYER_CTRL);
8d9dbe82af3c (svn r13057) [NoAI] -Codechange: port the AIDebugWindow to the new Window framework.
rubidium
parents: 10513
diff changeset
   189
		}
8d9dbe82af3c (svn r13057) [NoAI] -Codechange: port the AIDebugWindow to the new Window framework.
rubidium
parents: 10513
diff changeset
   190
	}
8d9dbe82af3c (svn r13057) [NoAI] -Codechange: port the AIDebugWindow to the new Window framework.
rubidium
parents: 10513
diff changeset
   191
8d9dbe82af3c (svn r13057) [NoAI] -Codechange: port the AIDebugWindow to the new Window framework.
rubidium
parents: 10513
diff changeset
   192
	virtual void OnTimeout()
8d9dbe82af3c (svn r13057) [NoAI] -Codechange: port the AIDebugWindow to the new Window framework.
rubidium
parents: 10513
diff changeset
   193
	{
8d9dbe82af3c (svn r13057) [NoAI] -Codechange: port the AIDebugWindow to the new Window framework.
rubidium
parents: 10513
diff changeset
   194
		this->RaiseWidget(AID_WIDGET_RELOAD_TOGGLE);
8d9dbe82af3c (svn r13057) [NoAI] -Codechange: port the AIDebugWindow to the new Window framework.
rubidium
parents: 10513
diff changeset
   195
		this->SetDirty();
8d9dbe82af3c (svn r13057) [NoAI] -Codechange: port the AIDebugWindow to the new Window framework.
rubidium
parents: 10513
diff changeset
   196
	}
10739
0d70706cf183 (svn r13289) [NoAI] -Codechange: better refreshing of AIDebug window
glx
parents: 10738
diff changeset
   197
0d70706cf183 (svn r13289) [NoAI] -Codechange: better refreshing of AIDebug window
glx
parents: 10738
diff changeset
   198
	virtual void OnInvalidateData(int data = 0)
0d70706cf183 (svn r13289) [NoAI] -Codechange: better refreshing of AIDebug window
glx
parents: 10738
diff changeset
   199
	{
0d70706cf183 (svn r13289) [NoAI] -Codechange: better refreshing of AIDebug window
glx
parents: 10738
diff changeset
   200
		if (data == -1 || ai_debug_player == data) this->SetDirty();
0d70706cf183 (svn r13289) [NoAI] -Codechange: better refreshing of AIDebug window
glx
parents: 10738
diff changeset
   201
	}
10750
e2c339d613d1 (svn r13300) [NoAI] -Add: a scrollbar in AIDebug window.
glx
parents: 10739
diff changeset
   202
e2c339d613d1 (svn r13300) [NoAI] -Add: a scrollbar in AIDebug window.
glx
parents: 10739
diff changeset
   203
	virtual void OnResize(Point new_size, Point delta)
e2c339d613d1 (svn r13300) [NoAI] -Add: a scrollbar in AIDebug window.
glx
parents: 10739
diff changeset
   204
	{
e2c339d613d1 (svn r13300) [NoAI] -Add: a scrollbar in AIDebug window.
glx
parents: 10739
diff changeset
   205
		this->vscroll.cap += delta.y / (int)this->resize.step_height;
e2c339d613d1 (svn r13300) [NoAI] -Add: a scrollbar in AIDebug window.
glx
parents: 10739
diff changeset
   206
	}
10514
8d9dbe82af3c (svn r13057) [NoAI] -Codechange: port the AIDebugWindow to the new Window framework.
rubidium
parents: 10513
diff changeset
   207
};
8d9dbe82af3c (svn r13057) [NoAI] -Codechange: port the AIDebugWindow to the new Window framework.
rubidium
parents: 10513
diff changeset
   208
8d9dbe82af3c (svn r13057) [NoAI] -Codechange: port the AIDebugWindow to the new Window framework.
rubidium
parents: 10513
diff changeset
   209
PlayerID AIDebugWindow::ai_debug_player = INVALID_PLAYER;
9845
c359062b4db0 (svn r12511) [NoAI] -Add (WIP): AI Debug GUI. For now it is a stripped down copy of performance details. In future it will allow reloading of AI, changing settings, and reading the log of the AI
truebrain
parents:
diff changeset
   210
c359062b4db0 (svn r12511) [NoAI] -Add (WIP): AI Debug GUI. For now it is a stripped down copy of performance details. In future it will allow reloading of AI, changing settings, and reading the log of the AI
truebrain
parents:
diff changeset
   211
static const Widget _ai_debug_widgets[] = {
9846
6dcf51a0cf7c (svn r12512) [NoAI] -Fix r12511: it was pointed out to me to handle widgets with enums... I only wish there was a guideline for their names ;)
truebrain
parents: 9845
diff changeset
   212
{   WWT_CLOSEBOX,   RESIZE_NONE,    14,     0,    10,     0,    13, STR_00C5,                   STR_018B_CLOSE_WINDOW},                 // AID_WIDGET_CLOSEBOX
10653
c389705ba89f (svn r13197) [NoAI] -Codechange: make the AIDebugWindow resizable
glx
parents: 10652
diff changeset
   213
{    WWT_CAPTION,  RESIZE_RIGHT,    14,    11,   298,     0,    13, STR_AI_DEBUG,               STR_018C_WINDOW_TITLE_DRAG_THIS},       // AID_WIDGET_CAPTION
c389705ba89f (svn r13197) [NoAI] -Codechange: make the AIDebugWindow resizable
glx
parents: 10652
diff changeset
   214
{      WWT_PANEL,  RESIZE_RIGHT,    14,     0,   298,    14,    27, 0x0,                        STR_NULL},                              // AID_WIDGET_VIEW
9845
c359062b4db0 (svn r12511) [NoAI] -Add (WIP): AI Debug GUI. For now it is a stripped down copy of performance details. In future it will allow reloading of AI, changing settings, and reading the log of the AI
truebrain
parents:
diff changeset
   215
10653
c389705ba89f (svn r13197) [NoAI] -Codechange: make the AIDebugWindow resizable
glx
parents: 10652
diff changeset
   216
{      WWT_PANEL,  RESIZE_RIGHT,    14,     0,   149,    28,    47, 0x0,                        STR_AI_DEBUG_NAME_TIP},                 // AID_WIDGET_NAME_TEXT
c389705ba89f (svn r13197) [NoAI] -Codechange: make the AIDebugWindow resizable
glx
parents: 10652
diff changeset
   217
{ WWT_PUSHTXTBTN,     RESIZE_LR,    14,   150,   298,    28,    47, STR_AI_DEBUG_RELOAD,        STR_AI_DEBUG_RELOAD_TIP},               // AID_WIDGET_RELOAD_TOGGLE
10750
e2c339d613d1 (svn r13300) [NoAI] -Add: a scrollbar in AIDebug window.
glx
parents: 10739
diff changeset
   218
{      WWT_PANEL,     RESIZE_RB,    14,     0,   286,    48,   227, 0x0,                        STR_NULL},                              // AID_WIDGET_LOG_PANEL
e2c339d613d1 (svn r13300) [NoAI] -Add: a scrollbar in AIDebug window.
glx
parents: 10739
diff changeset
   219
{  WWT_SCROLLBAR,    RESIZE_LRB,    14,   287,   298,    48,   215, STR_NULL,                   STR_0190_SCROLL_BAR_SCROLLS_LIST},      // AID_WIDGET_SCROLLBAR
9845
c359062b4db0 (svn r12511) [NoAI] -Add (WIP): AI Debug GUI. For now it is a stripped down copy of performance details. In future it will allow reloading of AI, changing settings, and reading the log of the AI
truebrain
parents:
diff changeset
   220
/* As this is WIP, leave the next few so we can work a bit with the GUI */
9846
6dcf51a0cf7c (svn r12512) [NoAI] -Fix r12511: it was pointed out to me to handle widgets with enums... I only wish there was a guideline for their names ;)
truebrain
parents: 9845
diff changeset
   221
{      WWT_EMPTY,   RESIZE_NONE,    14,     0,   298,    88,   107, 0x0,                        STR_NULL},                              // AID_WIDGET_UNUSED_1
6dcf51a0cf7c (svn r12512) [NoAI] -Fix r12511: it was pointed out to me to handle widgets with enums... I only wish there was a guideline for their names ;)
truebrain
parents: 9845
diff changeset
   222
{      WWT_EMPTY,   RESIZE_NONE,    14,     0,   298,   108,   127, 0x0,                        STR_NULL},                              // AID_WIDGET_UNUSED_2
6dcf51a0cf7c (svn r12512) [NoAI] -Fix r12511: it was pointed out to me to handle widgets with enums... I only wish there was a guideline for their names ;)
truebrain
parents: 9845
diff changeset
   223
{      WWT_EMPTY,   RESIZE_NONE,    14,     0,   298,   128,   147, 0x0,                        STR_NULL},                              // AID_WIDGET_UNUSED_3
6dcf51a0cf7c (svn r12512) [NoAI] -Fix r12511: it was pointed out to me to handle widgets with enums... I only wish there was a guideline for their names ;)
truebrain
parents: 9845
diff changeset
   224
{      WWT_EMPTY,   RESIZE_NONE,    14,     0,   298,   148,   167, 0x0,                        STR_NULL},                              // AID_WIDGET_UNUSED_4
6dcf51a0cf7c (svn r12512) [NoAI] -Fix r12511: it was pointed out to me to handle widgets with enums... I only wish there was a guideline for their names ;)
truebrain
parents: 9845
diff changeset
   225
{      WWT_EMPTY,   RESIZE_NONE,    14,     0,   298,   168,   187, 0x0,                        STR_NULL},                              // AID_WIDGET_UNUSED_5
6dcf51a0cf7c (svn r12512) [NoAI] -Fix r12511: it was pointed out to me to handle widgets with enums... I only wish there was a guideline for their names ;)
truebrain
parents: 9845
diff changeset
   226
{      WWT_EMPTY,   RESIZE_NONE,    14,     0,   298,   188,   207, 0x0,                        STR_NULL},                              // AID_WIDGET_UNUSED_6
6dcf51a0cf7c (svn r12512) [NoAI] -Fix r12511: it was pointed out to me to handle widgets with enums... I only wish there was a guideline for their names ;)
truebrain
parents: 9845
diff changeset
   227
{      WWT_EMPTY,   RESIZE_NONE,    14,     0,   298,   208,   227, 0x0,                        STR_NULL},                              // AID_WIDGET_UNUSED_7
9845
c359062b4db0 (svn r12511) [NoAI] -Add (WIP): AI Debug GUI. For now it is a stripped down copy of performance details. In future it will allow reloading of AI, changing settings, and reading the log of the AI
truebrain
parents:
diff changeset
   228
9846
6dcf51a0cf7c (svn r12512) [NoAI] -Fix r12511: it was pointed out to me to handle widgets with enums... I only wish there was a guideline for their names ;)
truebrain
parents: 9845
diff changeset
   229
{      WWT_PANEL,   RESIZE_NONE,    14,     2,    38,    14,    26, 0x0,                        STR_704F_CLICK_HERE_TO_TOGGLE_COMPANY}, // AID_WIDGET_COMPANY_BUTTON_START
9845
c359062b4db0 (svn r12511) [NoAI] -Add (WIP): AI Debug GUI. For now it is a stripped down copy of performance details. In future it will allow reloading of AI, changing settings, and reading the log of the AI
truebrain
parents:
diff changeset
   230
{      WWT_PANEL,   RESIZE_NONE,    14,    39,    75,    14,    26, 0x0,                        STR_704F_CLICK_HERE_TO_TOGGLE_COMPANY},
c359062b4db0 (svn r12511) [NoAI] -Add (WIP): AI Debug GUI. For now it is a stripped down copy of performance details. In future it will allow reloading of AI, changing settings, and reading the log of the AI
truebrain
parents:
diff changeset
   231
{      WWT_PANEL,   RESIZE_NONE,    14,    76,   112,    14,    26, 0x0,                        STR_704F_CLICK_HERE_TO_TOGGLE_COMPANY},
c359062b4db0 (svn r12511) [NoAI] -Add (WIP): AI Debug GUI. For now it is a stripped down copy of performance details. In future it will allow reloading of AI, changing settings, and reading the log of the AI
truebrain
parents:
diff changeset
   232
{      WWT_PANEL,   RESIZE_NONE,    14,   113,   149,    14,    26, 0x0,                        STR_704F_CLICK_HERE_TO_TOGGLE_COMPANY},
c359062b4db0 (svn r12511) [NoAI] -Add (WIP): AI Debug GUI. For now it is a stripped down copy of performance details. In future it will allow reloading of AI, changing settings, and reading the log of the AI
truebrain
parents:
diff changeset
   233
{      WWT_PANEL,   RESIZE_NONE,    14,   150,   186,    14,    26, 0x0,                        STR_704F_CLICK_HERE_TO_TOGGLE_COMPANY},
c359062b4db0 (svn r12511) [NoAI] -Add (WIP): AI Debug GUI. For now it is a stripped down copy of performance details. In future it will allow reloading of AI, changing settings, and reading the log of the AI
truebrain
parents:
diff changeset
   234
{      WWT_PANEL,   RESIZE_NONE,    14,   187,   223,    14,    26, 0x0,                        STR_704F_CLICK_HERE_TO_TOGGLE_COMPANY},
c359062b4db0 (svn r12511) [NoAI] -Add (WIP): AI Debug GUI. For now it is a stripped down copy of performance details. In future it will allow reloading of AI, changing settings, and reading the log of the AI
truebrain
parents:
diff changeset
   235
{      WWT_PANEL,   RESIZE_NONE,    14,   224,   260,    14,    26, 0x0,                        STR_704F_CLICK_HERE_TO_TOGGLE_COMPANY},
9846
6dcf51a0cf7c (svn r12512) [NoAI] -Fix r12511: it was pointed out to me to handle widgets with enums... I only wish there was a guideline for their names ;)
truebrain
parents: 9845
diff changeset
   236
{      WWT_PANEL,   RESIZE_NONE,    14,   261,   297,    14,    26, 0x0,                        STR_704F_CLICK_HERE_TO_TOGGLE_COMPANY}, // AID_WIDGET_COMPANY_BUTTON_END
10653
c389705ba89f (svn r13197) [NoAI] -Codechange: make the AIDebugWindow resizable
glx
parents: 10652
diff changeset
   237
{  WWT_RESIZEBOX,   RESIZE_LRTB,    14,   287,   298,   216,   227, STR_NULL,                   STR_RESIZE_BUTTON},
9845
c359062b4db0 (svn r12511) [NoAI] -Add (WIP): AI Debug GUI. For now it is a stripped down copy of performance details. In future it will allow reloading of AI, changing settings, and reading the log of the AI
truebrain
parents:
diff changeset
   238
{   WIDGETS_END},
c359062b4db0 (svn r12511) [NoAI] -Add (WIP): AI Debug GUI. For now it is a stripped down copy of performance details. In future it will allow reloading of AI, changing settings, and reading the log of the AI
truebrain
parents:
diff changeset
   239
};
c359062b4db0 (svn r12511) [NoAI] -Add (WIP): AI Debug GUI. For now it is a stripped down copy of performance details. In future it will allow reloading of AI, changing settings, and reading the log of the AI
truebrain
parents:
diff changeset
   240
c359062b4db0 (svn r12511) [NoAI] -Add (WIP): AI Debug GUI. For now it is a stripped down copy of performance details. In future it will allow reloading of AI, changing settings, and reading the log of the AI
truebrain
parents:
diff changeset
   241
static const WindowDesc _ai_debug_desc = {
c359062b4db0 (svn r12511) [NoAI] -Add (WIP): AI Debug GUI. For now it is a stripped down copy of performance details. In future it will allow reloading of AI, changing settings, and reading the log of the AI
truebrain
parents:
diff changeset
   242
	WDP_AUTO, WDP_AUTO, 299, 228, 299, 228,
10652
cbd10d63440b (svn r13196) [NoAI] -Fix: don't use WC_PERFORMANCE_DETAIL for AIDebugWindow
glx
parents: 10650
diff changeset
   243
	WC_AI_DEBUG, WC_NONE,
10653
c389705ba89f (svn r13197) [NoAI] -Codechange: make the AIDebugWindow resizable
glx
parents: 10652
diff changeset
   244
	WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_RESIZABLE,
10645
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10643
diff changeset
   245
	_ai_debug_widgets
9845
c359062b4db0 (svn r12511) [NoAI] -Add (WIP): AI Debug GUI. For now it is a stripped down copy of performance details. In future it will allow reloading of AI, changing settings, and reading the log of the AI
truebrain
parents:
diff changeset
   246
};
c359062b4db0 (svn r12511) [NoAI] -Add (WIP): AI Debug GUI. For now it is a stripped down copy of performance details. In future it will allow reloading of AI, changing settings, and reading the log of the AI
truebrain
parents:
diff changeset
   247
c359062b4db0 (svn r12511) [NoAI] -Add (WIP): AI Debug GUI. For now it is a stripped down copy of performance details. In future it will allow reloading of AI, changing settings, and reading the log of the AI
truebrain
parents:
diff changeset
   248
void ShowAIDebugWindow()
c359062b4db0 (svn r12511) [NoAI] -Add (WIP): AI Debug GUI. For now it is a stripped down copy of performance details. In future it will allow reloading of AI, changing settings, and reading the log of the AI
truebrain
parents:
diff changeset
   249
{
10514
8d9dbe82af3c (svn r13057) [NoAI] -Codechange: port the AIDebugWindow to the new Window framework.
rubidium
parents: 10513
diff changeset
   250
	AllocateWindowDescFront<AIDebugWindow>(&_ai_debug_desc, 0);
9845
c359062b4db0 (svn r12511) [NoAI] -Add (WIP): AI Debug GUI. For now it is a stripped down copy of performance details. In future it will allow reloading of AI, changing settings, and reading the log of the AI
truebrain
parents:
diff changeset
   251
}