/
hll_gui.cpp
109 lines (90 loc) · 2.28 KB
/
hll_gui.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
// Copyright (c) 2018 Brett Anthony. All rights reserved.
//
// This work is licensed under the terms of the MIT license.
// For a copy, see <https://opensource.org/licenses/MIT>.
#include "hll_gui.h"
Bool HLL::Gui::CreateLayout()
{
return LoadDialogResource(DLG_HLL, nullptr, 0);
}
Bool HLL::Gui::InitValues()
{
// Called before first GUI Draw.
if (!this->SetString(BTN_LISTEN, GeLoadString(STR_START_LISTEN)))
return false;
// to-do: Remember last setting.
if (!this->SetString(TXT_HOSTNAME, "127.0.0.1"_s))
return false;
if (!this->SetString(TXT_PORT, "31337"_s))
return false;
// this returns false even if it works, need to investigate...
this->SetInt32(CBX_COORDINATE_SYSTEM, CBO_Y_UP);
if (!this->SetString(BTN_MAPPING, "<="_s))
return false;
if (!this->SetString(TXT_STATUS, GeLoadString(STR_NO_REPORT)))
return false;
if (!this->SetString(TXT_CAMERANAME, GeLoadString(STR_NO_CAMERA)))
return false;
return true;
}
Bool HLL::Gui::Command(Int32 id, const BaseContainer &msg)
{
// Called when GUI is interacted with.
if (id == BTN_LISTEN)
{
// to-do: Implement Server
String str;
if (this->GetString(BTN_LISTEN, str))
{
if (str == GeLoadString(STR_START_LISTEN))
{
if (!this->SetString(BTN_LISTEN, GeLoadString(STR_STOP_LISTEN)))
return false;
return true;
}
if (!this->SetString(BTN_LISTEN, GeLoadString(STR_START_LISTEN)))
return false;
return true;
}
return false;
}
if (id == BTN_SETCAMERA)
{
// to-do: Camera Setting
if (!this->SetString(TXT_CAMERANAME, "Sample Camera Name"_s))
return false;
return true;
}
if (id == BTN_MAPPING)
{
String str;
if (this->GetString(BTN_MAPPING, str))
{
if (str == "<=")
{
if (!this->SetString(BTN_MAPPING, "=>"_s))
return false;
return true;
}
if (!this->SetString(BTN_MAPPING, "<="_s))
return false;
return true;
}
return false;
}
return false;
}
Bool HLL::GuiCommand::Execute(BaseDocument *doc)
{
// Called when plugin is selected from menu.
oGui = NewObjClear(HLL::Gui);
if (!oGui->Open(DLG_TYPE::ASYNC, 1050016))
return false;
return true;
}
Bool HLL::RegisterHLL()
{
HLL::GuiCommand *oGuiCommand = NewObjClear(HLL::GuiCommand);
return RegisterCommandPlugin(1050016, "HLAELiveLink"_s, 0,
nullptr, "HelpString"_s, oGuiCommand);
}