src/ai/ai_gui.cpp
author glx
Tue, 27 May 2008 14:11:56 +0000
branchnoai
changeset 10739 0d70706cf183
parent 10738 b9a7a803ee61
child 10750 e2c339d613d1
permissions -rw-r--r--
(svn r13289) [NoAI] -Codechange: better refreshing of AIDebug window
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,
8d9dbe82af3c (svn r13057) [NoAI] -Codechange: port the AIDebugWindow to the new Window framework.
rubidium
parents: 10513
diff changeset
    43
		AID_WIDGET_UNUSED_1,
8d9dbe82af3c (svn r13057) [NoAI] -Codechange: port the AIDebugWindow to the new Window framework.
rubidium
parents: 10513
diff changeset
    44
		AID_WIDGET_UNUSED_2,
8d9dbe82af3c (svn r13057) [NoAI] -Codechange: port the AIDebugWindow to the new Window framework.
rubidium
parents: 10513
diff changeset
    45
		AID_WIDGET_UNUSED_3,
8d9dbe82af3c (svn r13057) [NoAI] -Codechange: port the AIDebugWindow to the new Window framework.
rubidium
parents: 10513
diff changeset
    46
		AID_WIDGET_UNUSED_4,
8d9dbe82af3c (svn r13057) [NoAI] -Codechange: port the AIDebugWindow to the new Window framework.
rubidium
parents: 10513
diff changeset
    47
		AID_WIDGET_UNUSED_5,
8d9dbe82af3c (svn r13057) [NoAI] -Codechange: port the AIDebugWindow to the new Window framework.
rubidium
parents: 10513
diff changeset
    48
		AID_WIDGET_UNUSED_6,
8d9dbe82af3c (svn r13057) [NoAI] -Codechange: port the AIDebugWindow to the new Window framework.
rubidium
parents: 10513
diff changeset
    49
		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
    50
10514
8d9dbe82af3c (svn r13057) [NoAI] -Codechange: port the AIDebugWindow to the new Window framework.
rubidium
parents: 10513
diff changeset
    51
		AID_WIDGET_COMPANY_BUTTON_START,
8d9dbe82af3c (svn r13057) [NoAI] -Codechange: port the AIDebugWindow to the new Window framework.
rubidium
parents: 10513
diff changeset
    52
		AID_WIDGET_COMPANY_BUTTON_END = AID_WIDGET_COMPANY_BUTTON_START + 8,
8d9dbe82af3c (svn r13057) [NoAI] -Codechange: port the AIDebugWindow to the new Window framework.
rubidium
parents: 10513
diff changeset
    53
	};
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
    54
10514
8d9dbe82af3c (svn r13057) [NoAI] -Codechange: port the AIDebugWindow to the new Window framework.
rubidium
parents: 10513
diff changeset
    55
	static PlayerID ai_debug_player;
8d9dbe82af3c (svn r13057) [NoAI] -Codechange: port the AIDebugWindow to the new Window framework.
rubidium
parents: 10513
diff changeset
    56
	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
    57
10645
8cbdb511a674 (svn r13189) [NoAI] -Sync: with trunk r13055:13185.
glx
parents: 10643
diff changeset
    58
	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
    59
	{
8d9dbe82af3c (svn r13057) [NoAI] -Codechange: port the AIDebugWindow to the new Window framework.
rubidium
parents: 10513
diff changeset
    60
		/* 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
    61
		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
    62
			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
    63
		}
8d9dbe82af3c (svn r13057) [NoAI] -Codechange: port the AIDebugWindow to the new Window framework.
rubidium
parents: 10513
diff changeset
    64
		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
    65
10514
8d9dbe82af3c (svn r13057) [NoAI] -Codechange: port the AIDebugWindow to the new Window framework.
rubidium
parents: 10513
diff changeset
    66
		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
    67
8d9dbe82af3c (svn r13057) [NoAI] -Codechange: port the AIDebugWindow to the new Window framework.
rubidium
parents: 10513
diff changeset
    68
		this->FindWindowPlacementAndResize(desc);
8d9dbe82af3c (svn r13057) [NoAI] -Codechange: port the AIDebugWindow to the new Window framework.
rubidium
parents: 10513
diff changeset
    69
	}
8d9dbe82af3c (svn r13057) [NoAI] -Codechange: port the AIDebugWindow to the new Window framework.
rubidium
parents: 10513
diff changeset
    70
8d9dbe82af3c (svn r13057) [NoAI] -Codechange: port the AIDebugWindow to the new Window framework.
rubidium
parents: 10513
diff changeset
    71
	virtual void OnPaint()
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
		/* 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
    74
		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
    75
			if (ai_debug_player != INVALID_PLAYER) {
8d9dbe82af3c (svn r13057) [NoAI] -Codechange: port the AIDebugWindow to the new Window framework.
rubidium
parents: 10513
diff changeset
    76
				/* 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
    77
				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
    78
				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
    79
8d9dbe82af3c (svn r13057) [NoAI] -Codechange: port the AIDebugWindow to the new Window framework.
rubidium
parents: 10513
diff changeset
    80
				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
    81
			}
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
    82
10514
8d9dbe82af3c (svn r13057) [NoAI] -Codechange: port the AIDebugWindow to the new Window framework.
rubidium
parents: 10513
diff changeset
    83
			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
    84
				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
    85
					/* 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
    86
					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
    87
10514
8d9dbe82af3c (svn r13057) [NoAI] -Codechange: port the AIDebugWindow to the new Window framework.
rubidium
parents: 10513
diff changeset
    88
					ai_debug_player = i;
8d9dbe82af3c (svn r13057) [NoAI] -Codechange: port the AIDebugWindow to the new Window framework.
rubidium
parents: 10513
diff changeset
    89
					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
    90
				}
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
    91
			}
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
    92
		}
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
    93
10738
b9a7a803ee61 (svn r13288) [NoAI] -Fix: 'Reload AI' button could be disabled when it should be enabled
glx
parents: 10653
diff changeset
    94
		/* 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
    95
		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
    96
b9a7a803ee61 (svn r13288) [NoAI] -Fix: 'Reload AI' button could be disabled when it should be enabled
glx
parents: 10653
diff changeset
    97
		/* Draw standard stuff */
b9a7a803ee61 (svn r13288) [NoAI] -Fix: 'Reload AI' button could be disabled when it should be enabled
glx
parents: 10653
diff changeset
    98
		this->DrawWidgets();
b9a7a803ee61 (svn r13288) [NoAI] -Fix: 'Reload AI' button could be disabled when it should be enabled
glx
parents: 10653
diff changeset
    99
10514
8d9dbe82af3c (svn r13057) [NoAI] -Codechange: port the AIDebugWindow to the new Window framework.
rubidium
parents: 10513
diff changeset
   100
		/* 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
   101
		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
   102
10514
8d9dbe82af3c (svn r13057) [NoAI] -Codechange: port the AIDebugWindow to the new Window framework.
rubidium
parents: 10513
diff changeset
   103
		/* Paint the player icons */
8d9dbe82af3c (svn r13057) [NoAI] -Codechange: port the AIDebugWindow to the new Window framework.
rubidium
parents: 10513
diff changeset
   104
		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
   105
			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
   106
				/* 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
   107
				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
   108
					/* Bah, player gone :( */
8d9dbe82af3c (svn r13057) [NoAI] -Codechange: port the AIDebugWindow to the new Window framework.
rubidium
parents: 10513
diff changeset
   109
					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
   110
10514
8d9dbe82af3c (svn r13057) [NoAI] -Codechange: port the AIDebugWindow to the new Window framework.
rubidium
parents: 10513
diff changeset
   111
					/* We need a repaint */
8d9dbe82af3c (svn r13057) [NoAI] -Codechange: port the AIDebugWindow to the new Window framework.
rubidium
parents: 10513
diff changeset
   112
					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
   113
				}
10514
8d9dbe82af3c (svn r13057) [NoAI] -Codechange: port the AIDebugWindow to the new Window framework.
rubidium
parents: 10513
diff changeset
   114
				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
   115
			}
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
   116
10514
8d9dbe82af3c (svn r13057) [NoAI] -Codechange: port the AIDebugWindow to the new Window framework.
rubidium
parents: 10513
diff changeset
   117
			/* 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
   118
			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
   119
				/* New AI! Yippie :p */
8d9dbe82af3c (svn r13057) [NoAI] -Codechange: port the AIDebugWindow to the new Window framework.
rubidium
parents: 10513
diff changeset
   120
				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
   121
10514
8d9dbe82af3c (svn r13057) [NoAI] -Codechange: port the AIDebugWindow to the new Window framework.
rubidium
parents: 10513
diff changeset
   122
				/* We need a repaint */
8d9dbe82af3c (svn r13057) [NoAI] -Codechange: port the AIDebugWindow to the new Window framework.
rubidium
parents: 10513
diff changeset
   123
				this->SetDirty();
8d9dbe82af3c (svn r13057) [NoAI] -Codechange: port the AIDebugWindow to the new Window framework.
rubidium
parents: 10513
diff changeset
   124
			}
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
   125
10514
8d9dbe82af3c (svn r13057) [NoAI] -Codechange: port the AIDebugWindow to the new Window framework.
rubidium
parents: 10513
diff changeset
   126
			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
   127
			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
   128
		}
8d9dbe82af3c (svn r13057) [NoAI] -Codechange: port the AIDebugWindow to the new Window framework.
rubidium
parents: 10513
diff changeset
   129
10738
b9a7a803ee61 (svn r13288) [NoAI] -Fix: 'Reload AI' button could be disabled when it should be enabled
glx
parents: 10653
diff changeset
   130
		/* 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
   131
		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
   132
		assert(info != NULL);
b9a7a803ee61 (svn r13288) [NoAI] -Fix: 'Reload AI' button could be disabled when it should be enabled
glx
parents: 10653
diff changeset
   133
		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
   134
8d9dbe82af3c (svn r13057) [NoAI] -Codechange: port the AIDebugWindow to the new Window framework.
rubidium
parents: 10513
diff changeset
   135
		PlayerID old_cp = _current_player;
8d9dbe82af3c (svn r13057) [NoAI] -Codechange: port the AIDebugWindow to the new Window framework.
rubidium
parents: 10513
diff changeset
   136
		_current_player = ai_debug_player;
8d9dbe82af3c (svn r13057) [NoAI] -Codechange: port the AIDebugWindow to the new Window framework.
rubidium
parents: 10513
diff changeset
   137
8d9dbe82af3c (svn r13057) [NoAI] -Codechange: port the AIDebugWindow to the new Window framework.
rubidium
parents: 10513
diff changeset
   138
		if (AIObject::GetLogPointer() == NULL) {
8d9dbe82af3c (svn r13057) [NoAI] -Codechange: port the AIDebugWindow to the new Window framework.
rubidium
parents: 10513
diff changeset
   139
			_current_player = old_cp;
8d9dbe82af3c (svn r13057) [NoAI] -Codechange: port the AIDebugWindow to the new Window framework.
rubidium
parents: 10513
diff changeset
   140
			return;
8d9dbe82af3c (svn r13057) [NoAI] -Codechange: port the AIDebugWindow to the new Window framework.
rubidium
parents: 10513
diff changeset
   141
		}
8d9dbe82af3c (svn r13057) [NoAI] -Codechange: port the AIDebugWindow to the new Window framework.
rubidium
parents: 10513
diff changeset
   142
		AILog::LogData *log = (AILog::LogData *)AIObject::GetLogPointer();
8d9dbe82af3c (svn r13057) [NoAI] -Codechange: port the AIDebugWindow to the new Window framework.
rubidium
parents: 10513
diff changeset
   143
8d9dbe82af3c (svn r13057) [NoAI] -Codechange: port the AIDebugWindow to the new Window framework.
rubidium
parents: 10513
diff changeset
   144
		for (int i = 0; i < log->count; i++) {
8d9dbe82af3c (svn r13057) [NoAI] -Codechange: port the AIDebugWindow to the new Window framework.
rubidium
parents: 10513
diff changeset
   145
			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
   146
			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
   147
8d9dbe82af3c (svn r13057) [NoAI] -Codechange: port the AIDebugWindow to the new Window framework.
rubidium
parents: 10513
diff changeset
   148
			int y = 12 * i;
8d9dbe82af3c (svn r13057) [NoAI] -Codechange: port the AIDebugWindow to the new Window framework.
rubidium
parents: 10513
diff changeset
   149
			if (y >= this->widget[AID_WIDGET_LOG_PANEL].bottom - this->widget[AID_WIDGET_LOG_PANEL].top - 12) break;
8d9dbe82af3c (svn r13057) [NoAI] -Codechange: port the AIDebugWindow to the new Window framework.
rubidium
parents: 10513
diff changeset
   150
8d9dbe82af3c (svn r13057) [NoAI] -Codechange: port the AIDebugWindow to the new Window framework.
rubidium
parents: 10513
diff changeset
   151
			uint colour;
8d9dbe82af3c (svn r13057) [NoAI] -Codechange: port the AIDebugWindow to the new Window framework.
rubidium
parents: 10513
diff changeset
   152
			switch (log->type[pos]) {
8d9dbe82af3c (svn r13057) [NoAI] -Codechange: port the AIDebugWindow to the new Window framework.
rubidium
parents: 10513
diff changeset
   153
				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
   154
				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
   155
				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
   156
				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
   157
				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
   158
				default:                  colour = TC_BLACK;  break;
8d9dbe82af3c (svn r13057) [NoAI] -Codechange: port the AIDebugWindow to the new Window framework.
rubidium
parents: 10513
diff changeset
   159
			}
8d9dbe82af3c (svn r13057) [NoAI] -Codechange: port the AIDebugWindow to the new Window framework.
rubidium
parents: 10513
diff changeset
   160
8d9dbe82af3c (svn r13057) [NoAI] -Codechange: port the AIDebugWindow to the new Window framework.
rubidium
parents: 10513
diff changeset
   161
			DoDrawStringTruncated(log->lines[pos], 7, this->widget[AID_WIDGET_LOG_PANEL].top + 6 + y, colour, this->widget[AID_WIDGET_LOG_PANEL].right - this->widget[AID_WIDGET_LOG_PANEL].left - 14);
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
8d9dbe82af3c (svn r13057) [NoAI] -Codechange: port the AIDebugWindow to the new Window framework.
rubidium
parents: 10513
diff changeset
   164
		_current_player = old_cp;
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
   165
	}
10514
8d9dbe82af3c (svn r13057) [NoAI] -Codechange: port the AIDebugWindow to the new Window framework.
rubidium
parents: 10513
diff changeset
   166
8d9dbe82af3c (svn r13057) [NoAI] -Codechange: port the AIDebugWindow to the new Window framework.
rubidium
parents: 10513
diff changeset
   167
	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
   168
	{
8d9dbe82af3c (svn r13057) [NoAI] -Codechange: port the AIDebugWindow to the new Window framework.
rubidium
parents: 10513
diff changeset
   169
		/* Check which button is clicked */
8d9dbe82af3c (svn r13057) [NoAI] -Codechange: port the AIDebugWindow to the new Window framework.
rubidium
parents: 10513
diff changeset
   170
		if (IsInsideMM(widget, AID_WIDGET_COMPANY_BUTTON_START, AID_WIDGET_COMPANY_BUTTON_END)) {
8d9dbe82af3c (svn r13057) [NoAI] -Codechange: port the AIDebugWindow to the new Window framework.
rubidium
parents: 10513
diff changeset
   171
			/* Is it no on disable? */
8d9dbe82af3c (svn r13057) [NoAI] -Codechange: port the AIDebugWindow to the new Window framework.
rubidium
parents: 10513
diff changeset
   172
			if (!this->IsWidgetDisabled(widget)) {
8d9dbe82af3c (svn r13057) [NoAI] -Codechange: port the AIDebugWindow to the new Window framework.
rubidium
parents: 10513
diff changeset
   173
				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
   174
				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
   175
				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
   176
				this->SetDirty();
8d9dbe82af3c (svn r13057) [NoAI] -Codechange: port the AIDebugWindow to the new Window framework.
rubidium
parents: 10513
diff changeset
   177
			}
8d9dbe82af3c (svn r13057) [NoAI] -Codechange: port the AIDebugWindow to the new Window framework.
rubidium
parents: 10513
diff changeset
   178
		}
8d9dbe82af3c (svn r13057) [NoAI] -Codechange: port the AIDebugWindow to the new Window framework.
rubidium
parents: 10513
diff changeset
   179
		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
   180
			/* 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
   181
			AIInfo *info = AI_GetPlayerInfo(ai_debug_player);
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
   182
			AI_ForceAI(info->GetName());
10514
8d9dbe82af3c (svn r13057) [NoAI] -Codechange: port the AIDebugWindow to the new Window framework.
rubidium
parents: 10513
diff changeset
   183
8d9dbe82af3c (svn r13057) [NoAI] -Codechange: port the AIDebugWindow to the new Window framework.
rubidium
parents: 10513
diff changeset
   184
			/* 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
   185
			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
   186
			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
   187
		}
8d9dbe82af3c (svn r13057) [NoAI] -Codechange: port the AIDebugWindow to the new Window framework.
rubidium
parents: 10513
diff changeset
   188
	}
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
	virtual void OnTimeout()
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
		this->RaiseWidget(AID_WIDGET_RELOAD_TOGGLE);
8d9dbe82af3c (svn r13057) [NoAI] -Codechange: port the AIDebugWindow to the new Window framework.
rubidium
parents: 10513
diff changeset
   193
		this->SetDirty();
8d9dbe82af3c (svn r13057) [NoAI] -Codechange: port the AIDebugWindow to the new Window framework.
rubidium
parents: 10513
diff changeset
   194
	}
10739
0d70706cf183 (svn r13289) [NoAI] -Codechange: better refreshing of AIDebug window
glx
parents: 10738
diff changeset
   195
0d70706cf183 (svn r13289) [NoAI] -Codechange: better refreshing of AIDebug window
glx
parents: 10738
diff changeset
   196
	virtual void OnInvalidateData(int data = 0)
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
		if (data == -1 || ai_debug_player == data) this->SetDirty();
0d70706cf183 (svn r13289) [NoAI] -Codechange: better refreshing of AIDebug window
glx
parents: 10738
diff changeset
   199
	}
10514
8d9dbe82af3c (svn r13057) [NoAI] -Codechange: port the AIDebugWindow to the new Window framework.
rubidium
parents: 10513
diff changeset
   200
};
8d9dbe82af3c (svn r13057) [NoAI] -Codechange: port the AIDebugWindow to the new Window framework.
rubidium
parents: 10513
diff changeset
   201
8d9dbe82af3c (svn r13057) [NoAI] -Codechange: port the AIDebugWindow to the new Window framework.
rubidium
parents: 10513
diff changeset
   202
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
   203
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
   204
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
   205
{   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
   206
{    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
   207
{      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
   208
10653
c389705ba89f (svn r13197) [NoAI] -Codechange: make the AIDebugWindow resizable
glx
parents: 10652
diff changeset
   209
{      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
   210
{ WWT_PUSHTXTBTN,     RESIZE_LR,    14,   150,   298,    28,    47, STR_AI_DEBUG_RELOAD,        STR_AI_DEBUG_RELOAD_TIP},               // AID_WIDGET_RELOAD_TOGGLE
c389705ba89f (svn r13197) [NoAI] -Codechange: make the AIDebugWindow resizable
glx
parents: 10652
diff changeset
   211
{      WWT_PANEL,     RESIZE_RB,    14,     0,   298,    48,   227, 0x0,                        STR_NULL},                              // AID_WIDGET_LOG_PANEL
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
   212
/* 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
   213
{      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
   214
{      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
   215
{      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
   216
{      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
   217
{      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
   218
{      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
   219
{      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
   220
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_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
   222
{      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
   223
{      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
   224
{      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
   225
{      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
   226
{      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
   227
{      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
   228
{      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
   229
{  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
   230
{   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
   231
};
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
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
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
   234
	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
   235
	WC_AI_DEBUG, WC_NONE,
10653
c389705ba89f (svn r13197) [NoAI] -Codechange: make the AIDebugWindow resizable
glx
parents: 10652
diff changeset
   236
	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
   237
	_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
   238
};
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
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
   241
{
10514
8d9dbe82af3c (svn r13057) [NoAI] -Codechange: port the AIDebugWindow to the new Window framework.
rubidium
parents: 10513
diff changeset
   242
	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
   243
}