Tiberian Technologies Scripts Reference Revision: 9000
Loading...
Searching...
No Matches
ScriptedDialogClass.h
1/* Renegade Scripts.dll
2 Copyright 2022 Tiberian Technologies
3
4 This file is part of the Renegade scripts.dll
5 The Renegade scripts.dll is free software; you can redistribute it and/or modify it under
6 the terms of the GNU General Public License as published by the Free
7 Software Foundation; either version 2, or (at your option) any later
8 version. See the file COPYING for more details.
9 In addition, an exemption is given to allow Run Time Dynamic Linking of this code with any closed source module that does not contain code covered by this licence.
10 Only the source code to the module(s) containing the licenced code has to be released.
11*/
12
13#pragma once
14
15#include "engine_string.h"
16#include "engine_vector.h"
17#include "vector2.h"
18#include "ScriptedControlClass.h"
19
20class ScriptedMenuDialogClass;
21class ScriptedPopupDialogClass;
22
23typedef enum
24{
25 DIALOGTYPE_POPUP,
26 DIALOGTYPE_MENU
27} DialogType;
28
29typedef enum
30{
31 DIALOGORIENTATION_NONE,
32 DIALOGORIENTATION_TOPLEFT,
33 DIALOGORIENTATION_TOPCENTER,
34 DIALOGORIENTATION_TOPRIGHT,
35 DIALOGORIENTATION_MIDDLELEFT,
36 DIALOGORIENTATION_MIDDLECENTER,
37 DIALOGORIENTATION_MIDDLERIGHT,
38 DIALOGORIENTATION_BOTTOMLEFT,
39 DIALOGORIENTATION_BOTTOMCENTER,
40 DIALOGORIENTATION_BOTTOMRIGHT
41} DialogOrientation;
42
43class ScriptedDialogClass
44{
45public:
46 ScriptedDialogClass(int client, int dlg_id);
47 virtual ~ScriptedDialogClass();
48
49 virtual DialogType Get_Dialog_Type() = 0;
50 virtual ScriptedMenuDialogClass* As_ScriptedMenuDialogClass() { return NULL; }
51 virtual ScriptedPopupDialogClass* As_ScriptedPopupDialogClass() { return NULL; }
52
53 int Get_Dialog_ID() { return id; }
54 int Get_Client_ID() { return clientId; }
55 bool Is_Dirty() { return isDirty; }
56 void Set_Dirty(bool dirty) { isDirty = dirty; }
57
58 virtual void Add_Control(ScriptedControlClass* control);
59 virtual ScriptedControlClass* Create_Control(ControlType type);
60 virtual ScriptedControlClass* Find_Control(int id);
61 virtual int Get_Control_Count();
62 virtual ScriptedControlClass* Get_Control_Index(int index);
63 virtual void Remove_Control(int id);
64 virtual void Remove_Control(ScriptedControlClass* control);
65 virtual void Clear_Controls();
66 virtual void Focus_Control(ScriptedControlClass* control);
67
68protected:
69 int id;
70 int clientId;
71 DynamicVectorClass<ScriptedControlClass*> controls;
72 bool isDirty;
73};
74
75class ScriptedMenuDialogClass : public ScriptedDialogClass
76{
77public:
78 ScriptedMenuDialogClass(int client, int dlg_id);
79 virtual ~ScriptedMenuDialogClass();
80
81 virtual DialogType Get_Dialog_Type() { return DIALOGTYPE_MENU; }
82 virtual ScriptedMenuDialogClass* As_ScriptedMenuDialogClass() { return this; }
83};
84
85class ScriptedPopupDialogClass : public ScriptedDialogClass
86{
87public:
88 ScriptedPopupDialogClass(int client, int dlg_id);
89 virtual ~ScriptedPopupDialogClass();
90
91 virtual DialogType Get_Dialog_Type() { return DIALOGTYPE_POPUP; }
92 virtual ScriptedPopupDialogClass* As_ScriptedPopupDialogClass() { return this; }
93
94 DialogOrientation Get_Orientation() { return orientation; }
95 void Set_Orientation(DialogOrientation newOrientation) { orientation = newOrientation; Set_Dirty(true); }
96 const Vector2& Get_Dialog_Size() { return size; }
97 void Set_Dialog_Size(Vector2& newSize) { size = newSize; Set_Dirty(true); }
98 void Set_Dialog_Size(int width, int height) { size.X = (float)width; size.Y = (float)height; Set_Dirty(true); }
99 const Vector2& Get_Dialog_Location() { return location; }
100 void Set_Dialog_Location(Vector2& newLocation) { location = newLocation; Set_Dirty(true); }
101 void Set_Dialog_Location(int x, int y) { location.X = (float)x; location.Y = (float)y; Set_Dirty(true); }
102 const WideStringClass& Get_Dialog_Title() { return title; }
103 void Set_Dialog_Title(const wchar_t* newTitle) { title = newTitle; Set_Dirty(true); }
104
105protected:
106 Vector2 size;
107 Vector2 location;
108 DialogOrientation orientation;
109 WideStringClass title;
110};