src/ai/ai_gui.cpp
author rubidium
Sun, 11 May 2008 20:09:34 +0000
branchnoai
changeset 10513 33cb70ff2f5d
parent 10385 4547ef131005
child 10514 8d9dbe82af3c
permissions -rw-r--r--
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
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"
13e73691378a (svn r12719) [NoAI] -Add: finished the Reload AI button in AIDebug Window.
truebrain
parents: 9851
diff changeset
    22
#include "ai.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
    23
#include "ai_factory.hpp"
9851
a5f5a7cf2b61 (svn r12519) [NoAI] -Add: added AILog with Info(), Warning(), and Error()
truebrain
parents: 9846
diff changeset
    24
#include "api/ai_object.hpp"
a5f5a7cf2b61 (svn r12519) [NoAI] -Add: added AILog with Info(), Warning(), and Error()
truebrain
parents: 9846
diff changeset
    25
#include "api/ai_log.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
    26
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
    27
#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
    28
#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
    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
extern AIFactoryBase *AI_GetPlayerFactory(PlayerID player);
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
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
    32
enum AIDebugWindowWidgets {
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
    33
	AID_WIDGET_CLOSEBOX = 0,
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
    34
	AID_WIDGET_CAPTION,
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
    35
	AID_WIDGET_VIEW,
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
    36
	AID_WIDGET_NAME_TEXT,
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
    37
	AID_WIDGET_RELOAD_TOGGLE,
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
    38
	AID_WIDGET_LOG_PANEL,
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
    39
	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
    40
	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
    41
	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
    42
	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
    43
	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
    44
	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
    45
	AID_WIDGET_UNUSED_7,
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
    46
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
    47
	AID_WIDGET_COMPANY_BUTTON_START,
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
    48
	AID_WIDGET_COMPANY_BUTTON_END = AID_WIDGET_COMPANY_BUTTON_START + 8,
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
    49
};
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
    50
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
static void AIDebugWndProc(Window *w, WindowEvent *e)
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
    52
{
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
    53
	static PlayerID _ai_debug_player = INVALID_PLAYER;
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
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
	switch (e->event) {
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
    56
		case WE_PAINT: {
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
			byte x;
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
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
    59
			/* Draw standard stuff */
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
    60
			DrawWindowWidgets(w);
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
    61
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
    62
			/* Check if the currently selected player is still active. */
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
    63
			if (_ai_debug_player == INVALID_PLAYER || !GetPlayer(_ai_debug_player)->is_active) {
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
    64
				if (_ai_debug_player != INVALID_PLAYER) {
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
					/* Raise and disable the widget for the previous selection. */
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
    66
					w->RaiseWidget(_ai_debug_player + AID_WIDGET_COMPANY_BUTTON_START);
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
    67
					w->DisableWidget(_ai_debug_player + 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
    68
					SetWindowDirty(w);
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
    69
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
    70
					_ai_debug_player = INVALID_PLAYER;
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
    71
				}
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
    72
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
    73
				for (PlayerID i = PLAYER_FIRST; i < MAX_PLAYERS; i++) {
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
    74
					if (GetPlayer(i)->is_active && GetPlayer(i)->is_ai) {
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
    75
						/* Lower the widget corresponding to this player. */
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
    76
						w->LowerWidget(i + AID_WIDGET_COMPANY_BUTTON_START);
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
    77
						w->EnableWidget(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
    78
						SetWindowDirty(w);
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
    79
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
    80
						_ai_debug_player = i;
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
    81
						break;
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
					}
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
    83
				}
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
    84
			}
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
    85
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
    86
			/* If there are no active players, don't display anything else. */
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
			if (_ai_debug_player == INVALID_PLAYER) break;
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
    88
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
    89
			/* Paint the player icons */
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
			for (PlayerID i = PLAYER_FIRST; i < MAX_PLAYERS; i++) {
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
				if (!GetPlayer(i)->is_active || !GetPlayer(i)->is_ai) {
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
					/* Check if we have the player as an active player */
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
    93
					if (!w->IsWidgetDisabled(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
    94
						/* Bah, player gone :( */
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
    95
						w->DisableWidget(i + AID_WIDGET_COMPANY_BUTTON_START);
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
    96
						w->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
    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
						/* We need a repaint */
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
    99
						SetWindowDirty(w);
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
   100
					}
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
   101
					continue;
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
				}
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
   103
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
   104
				/* Check if we have the player marked as inactive */
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
   105
				if (w->IsWidgetDisabled(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
   106
					/* New AI! Yippie :p */
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
   107
					w->EnableWidget(i + AID_WIDGET_COMPANY_BUTTON_START);
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
   108
					w->EnableWidget(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
   109
					/* We need a repaint */
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
					SetWindowDirty(w);
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
   111
				}
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
   112
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
				x = (i == _ai_debug_player) ? 1 : 0;
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
   114
				DrawPlayerIcon(i, i * 37 + 13 + x, 16 + x);
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
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
   117
			AIFactoryBase *factory = AI_GetPlayerFactory(_ai_debug_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
   118
			if (factory == NULL) {
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
   119
				DoDrawString("(unknown)", 7, 34, TC_BLACK);
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
   120
				w->DisableWidget(AID_WIDGET_RELOAD_TOGGLE);
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
   121
			} else {
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
   122
				DoDrawString(factory->GetAIName(), 7, 34, TC_BLACK);
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
   123
			}
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
   124
9851
a5f5a7cf2b61 (svn r12519) [NoAI] -Add: added AILog with Info(), Warning(), and Error()
truebrain
parents: 9846
diff changeset
   125
			PlayerID old_cp = _current_player;
a5f5a7cf2b61 (svn r12519) [NoAI] -Add: added AILog with Info(), Warning(), and Error()
truebrain
parents: 9846
diff changeset
   126
			_current_player = _ai_debug_player;
a5f5a7cf2b61 (svn r12519) [NoAI] -Add: added AILog with Info(), Warning(), and Error()
truebrain
parents: 9846
diff changeset
   127
a5f5a7cf2b61 (svn r12519) [NoAI] -Add: added AILog with Info(), Warning(), and Error()
truebrain
parents: 9846
diff changeset
   128
			if (AIObject::GetLogPointer() == NULL) {
a5f5a7cf2b61 (svn r12519) [NoAI] -Add: added AILog with Info(), Warning(), and Error()
truebrain
parents: 9846
diff changeset
   129
				_current_player = old_cp;
a5f5a7cf2b61 (svn r12519) [NoAI] -Add: added AILog with Info(), Warning(), and Error()
truebrain
parents: 9846
diff changeset
   130
				break;
a5f5a7cf2b61 (svn r12519) [NoAI] -Add: added AILog with Info(), Warning(), and Error()
truebrain
parents: 9846
diff changeset
   131
			}
a5f5a7cf2b61 (svn r12519) [NoAI] -Add: added AILog with Info(), Warning(), and Error()
truebrain
parents: 9846
diff changeset
   132
			AILog::LogData *log = (AILog::LogData *)AIObject::GetLogPointer();
a5f5a7cf2b61 (svn r12519) [NoAI] -Add: added AILog with Info(), Warning(), and Error()
truebrain
parents: 9846
diff changeset
   133
a5f5a7cf2b61 (svn r12519) [NoAI] -Add: added AILog with Info(), Warning(), and Error()
truebrain
parents: 9846
diff changeset
   134
			for (int i = 0; i < log->count; i++) {
a5f5a7cf2b61 (svn r12519) [NoAI] -Add: added AILog with Info(), Warning(), and Error()
truebrain
parents: 9846
diff changeset
   135
				uint pos = (log->count + log->pos - i) % log->count;
a5f5a7cf2b61 (svn r12519) [NoAI] -Add: added AILog with Info(), Warning(), and Error()
truebrain
parents: 9846
diff changeset
   136
				if (log->type[pos] == 0) break;
a5f5a7cf2b61 (svn r12519) [NoAI] -Add: added AILog with Info(), Warning(), and Error()
truebrain
parents: 9846
diff changeset
   137
a5f5a7cf2b61 (svn r12519) [NoAI] -Add: added AILog with Info(), Warning(), and Error()
truebrain
parents: 9846
diff changeset
   138
				int y = 12 * i;
a5f5a7cf2b61 (svn r12519) [NoAI] -Add: added AILog with Info(), Warning(), and Error()
truebrain
parents: 9846
diff changeset
   139
				if (y >= w->widget[AID_WIDGET_LOG_PANEL].bottom - w->widget[AID_WIDGET_LOG_PANEL].top - 12) break;
a5f5a7cf2b61 (svn r12519) [NoAI] -Add: added AILog with Info(), Warning(), and Error()
truebrain
parents: 9846
diff changeset
   140
a5f5a7cf2b61 (svn r12519) [NoAI] -Add: added AILog with Info(), Warning(), and Error()
truebrain
parents: 9846
diff changeset
   141
				uint colour;
a5f5a7cf2b61 (svn r12519) [NoAI] -Add: added AILog with Info(), Warning(), and Error()
truebrain
parents: 9846
diff changeset
   142
				switch (log->type[pos]) {
a5f5a7cf2b61 (svn r12519) [NoAI] -Add: added AILog with Info(), Warning(), and Error()
truebrain
parents: 9846
diff changeset
   143
					case AILog::LOG_SQ_INFO:  colour = TC_BLACK;  break;
a5f5a7cf2b61 (svn r12519) [NoAI] -Add: added AILog with Info(), Warning(), and Error()
truebrain
parents: 9846
diff changeset
   144
					case AILog::LOG_SQ_ERROR: colour = TC_RED;    break;
a5f5a7cf2b61 (svn r12519) [NoAI] -Add: added AILog with Info(), Warning(), and Error()
truebrain
parents: 9846
diff changeset
   145
					case AILog::LOG_INFO:     colour = TC_BLACK;  break;
a5f5a7cf2b61 (svn r12519) [NoAI] -Add: added AILog with Info(), Warning(), and Error()
truebrain
parents: 9846
diff changeset
   146
					case AILog::LOG_WARNING:  colour = TC_YELLOW; break;
a5f5a7cf2b61 (svn r12519) [NoAI] -Add: added AILog with Info(), Warning(), and Error()
truebrain
parents: 9846
diff changeset
   147
					case AILog::LOG_ERROR:    colour = TC_RED;    break;
a5f5a7cf2b61 (svn r12519) [NoAI] -Add: added AILog with Info(), Warning(), and Error()
truebrain
parents: 9846
diff changeset
   148
					default:                  colour = TC_BLACK;  break;
a5f5a7cf2b61 (svn r12519) [NoAI] -Add: added AILog with Info(), Warning(), and Error()
truebrain
parents: 9846
diff changeset
   149
				}
a5f5a7cf2b61 (svn r12519) [NoAI] -Add: added AILog with Info(), Warning(), and Error()
truebrain
parents: 9846
diff changeset
   150
a5f5a7cf2b61 (svn r12519) [NoAI] -Add: added AILog with Info(), Warning(), and Error()
truebrain
parents: 9846
diff changeset
   151
				DoDrawStringTruncated(log->lines[pos], 7, w->widget[AID_WIDGET_LOG_PANEL].top + 6 + y, colour, w->widget[AID_WIDGET_LOG_PANEL].right - w->widget[AID_WIDGET_LOG_PANEL].left - 14);
a5f5a7cf2b61 (svn r12519) [NoAI] -Add: added AILog with Info(), Warning(), and Error()
truebrain
parents: 9846
diff changeset
   152
			}
a5f5a7cf2b61 (svn r12519) [NoAI] -Add: added AILog with Info(), Warning(), and Error()
truebrain
parents: 9846
diff changeset
   153
a5f5a7cf2b61 (svn r12519) [NoAI] -Add: added AILog with Info(), Warning(), and Error()
truebrain
parents: 9846
diff changeset
   154
			_current_player = old_cp;
a5f5a7cf2b61 (svn r12519) [NoAI] -Add: added AILog with Info(), Warning(), and Error()
truebrain
parents: 9846
diff changeset
   155
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
   156
			break;
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
   157
		}
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
   158
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
   159
		case WE_CLICK:
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
   160
			/* Check which button is clicked */
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
   161
			if (IsInsideMM(e->we.click.widget, AID_WIDGET_COMPANY_BUTTON_START, AID_WIDGET_COMPANY_BUTTON_END)) {
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
   162
				/* Is it no on disable? */
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
   163
				if (!w->IsWidgetDisabled(e->we.click.widget)) {
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
   164
					w->RaiseWidget(_ai_debug_player + AID_WIDGET_COMPANY_BUTTON_START);
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
   165
					_ai_debug_player = (PlayerID)(e->we.click.widget - AID_WIDGET_COMPANY_BUTTON_START);
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
   166
					w->LowerWidget(_ai_debug_player + 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
   167
					SetWindowDirty(w);
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
   168
				}
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
   169
			}
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
   170
			if (e->we.click.widget == AID_WIDGET_RELOAD_TOGGLE && !w->IsWidgetDisabled(e->we.click.widget)) {
10188
13e73691378a (svn r12719) [NoAI] -Add: finished the Reload AI button in AIDebug Window.
truebrain
parents: 9851
diff changeset
   171
				/* Set the current AI as forced next AI */
13e73691378a (svn r12719) [NoAI] -Add: finished the Reload AI button in AIDebug Window.
truebrain
parents: 9851
diff changeset
   172
				AIFactoryBase *factory = AI_GetPlayerFactory(_ai_debug_player);
13e73691378a (svn r12719) [NoAI] -Add: finished the Reload AI button in AIDebug Window.
truebrain
parents: 9851
diff changeset
   173
				AI_ForceAI(factory->GetAIName());
13e73691378a (svn r12719) [NoAI] -Add: finished the Reload AI button in AIDebug Window.
truebrain
parents: 9851
diff changeset
   174
13e73691378a (svn r12719) [NoAI] -Add: finished the Reload AI button in AIDebug Window.
truebrain
parents: 9851
diff changeset
   175
				/* First kill the company of the AI, then start a new one. This should start the current AI again */
13e73691378a (svn r12719) [NoAI] -Add: finished the Reload AI button in AIDebug Window.
truebrain
parents: 9851
diff changeset
   176
				DoCommandP(0, 2, _ai_debug_player, NULL, CMD_PLAYER_CTRL);
13e73691378a (svn r12719) [NoAI] -Add: finished the Reload AI button in AIDebug Window.
truebrain
parents: 9851
diff changeset
   177
				DoCommandP(0, 1, 0, NULL, CMD_PLAYER_CTRL);
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
   178
			}
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
   179
			break;
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
   180
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
   181
		case WE_CREATE: {
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
   182
			/* Disable the players who are not active or not an AI */
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
   183
			for (PlayerID i = PLAYER_FIRST; i < MAX_PLAYERS; i++) {
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
   184
				w->SetWidgetDisabledState(i + AID_WIDGET_COMPANY_BUTTON_START, !GetPlayer(i)->is_active || !GetPlayer(i)->is_ai);
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
   185
			}
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
   186
			w->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
   187
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
   188
			w->custom[0] = DAY_TICKS;
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
   189
			w->custom[1] = 5;
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
   190
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
   191
			if (_ai_debug_player != INVALID_PLAYER) w->LowerWidget(_ai_debug_player + 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
   192
			SetWindowDirty(w);
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
   193
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
   194
			break;
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
   195
		}
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
   196
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
   197
		case WE_TICK:
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
   198
			if (_pause_game != 0) break;
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
   199
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
   200
			/* Update the AI logs every 5 days */
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
   201
			if (--w->custom[0] == 0) {
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
   202
				w->custom[0] = DAY_TICKS;
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
				if (--w->custom[1] == 0) {
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
					w->custom[1] = 5;
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
   205
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
   206
					SetWindowDirty(w);
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
   207
				}
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
			}
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
   209
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
			break;
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
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
		case WE_TIMEOUT:
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
			w->RaiseWidget(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
   214
			SetWindowDirty(w);
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
			break;
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
   216
	}
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
   217
}
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
   218
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
   219
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
   220
{   WWT_CLOSEBOX,   RESIZE_NONE,    14,     0,    10,     0,    13, STR_00C5,                   STR_018B_CLOSE_WINDOW},                 // AID_WIDGET_CLOSEBOX
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_CAPTION,   RESIZE_NONE,    14,    11,   298,     0,    13, STR_AI_DEBUG,               STR_018C_WINDOW_TITLE_DRAG_THIS},       // AID_WIDGET_CAPTION
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_PANEL,   RESIZE_NONE,    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
   223
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
   224
{      WWT_PANEL,   RESIZE_NONE,    14,     0,   149,    28,    47, 0x0,                        STR_AI_DEBUG_NAME_TIP},                 // AID_WIDGET_NAME_TEXT
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_PUSHTXTBTN,   RESIZE_NONE,    14,   150,   298,    28,    47, STR_AI_DEBUG_RELOAD,        STR_AI_DEBUG_RELOAD_TIP},               // AID_WIDGET_RELOAD_TOGGLE
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_PANEL,   RESIZE_NONE,    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
   227
/* 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
   228
{      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
   229
{      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
   230
{      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
   231
{      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
   232
{      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
   233
{      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
   234
{      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
   235
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,     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
   237
{      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
   238
{      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
   239
{      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
   240
{      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
   241
{      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
   242
{      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
   243
{      WWT_PANEL,   RESIZE_NONE,    14,   261,   297,    14,    26, 0x0,                        STR_704F_CLICK_HERE_TO_TOGGLE_COMPANY}, // AID_WIDGET_COMPANY_BUTTON_END
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
   244
{   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
   245
};
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
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
   248
	WDP_AUTO, WDP_AUTO, 299, 228, 299, 228,
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
	WC_PERFORMANCE_DETAIL, WC_NONE,
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
   250
	WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET,
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
	_ai_debug_widgets,
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
   252
	AIDebugWndProc
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
   253
};
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
   254
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
   255
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
   256
{
10513
33cb70ff2f5d (svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents: 10385
diff changeset
   257
	AllocateWindowDescFront<Window>(&_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
   258
}