-
Notifications
You must be signed in to change notification settings - Fork 3
/
GishLauncher.cpp
202 lines (183 loc) · 8.35 KB
/
GishLauncher.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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
/************************************************************************************
** The MIT License (MIT)
**
** Copyright (c) 2018 EXL
**
** Permission is hereby granted, free of charge, to any person obtaining a copy
** of this software and associated documentation files (the "Software"), to deal
** in the Software without restriction, including without limitation the rights
** to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
** copies of the Software, and to permit persons to whom the Software is
** furnished to do so, subject to the following conditions:
**
** The above copyright notice and this permission notice shall be included in all
** copies or substantial portions of the Software.
**
** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
** IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
** FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
** AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
** LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
** OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
** SOFTWARE.
************************************************************************************/
#include "BeApp.h"
#include "BeLauncherBase.h"
#include "BeAboutWindow.h"
#include "BeUrlStringView.h"
#include "BeUtils.h"
#include <Font.h>
#include <Rect.h>
#include <String.h>
#include <StringView.h>
#include <Entry.h>
#include <GroupLayout.h>
#include <LayoutBuilder.h>
#include <InterfaceDefs.h>
#include <Catalog.h>
#ifndef SIGNATURE
#error "Application SIGNATURE is not defined. Check your build system."
#endif // !SIGNATURE
#undef B_TRANSLATION_CONTEXT
#define B_TRANSLATION_CONTEXT "GishLauncher"
// Launcher Settings
#define TITLE "Gish Launcher"
#define VERSION "1.2"
#define PACKAGE_DIR "Gish"
#define SETTINGS_FILE "GishLauncher.set"
#define EXECUTABLE_FILE "engine/Gish"
#define DATA_PATH_OPT "GISH_DATA_DIR"
// Various Strings
#define L_ABOUT_STRING B_TRANSLATE("Gish is a side-scrolling platformer video game with some physics " \
"puzzle elements developed by Cryptic Sea (pseudonym of Alex " \
"Austin), Edmund McMillen, Josiah Pisciotta and published by " \
"Chronic Logic in 2004. Cryptic Sea pledged Gish to go open " \
"source under the GPLv2 on May 29, 2010.\n\n" \
"This is my port of the Gish game to Haiku OS which uses " \
"SDL2, OpenAL and Ogg Vorbis libraries.\n\n")
#define L_ABOUT_THANKS_STR_H B_TRANSLATE("Thanks to:\n\t")
#define L_ABOUT_THANKS_STR B_TRANSLATE("3dEyes**\n\n")
#define L_ABOUT_PORT_STR_H B_TRANSLATE("Port to Haiku OS:\n\t")
#define L_ABOUT_PORT_STR B_TRANSLATE("EXL\n")
#define L_ABOUT_LINK B_TRANSLATE("http://chroniclogic.com/gish.htm")
#define L_ABOUT_LINK_DESC B_TRANSLATE("Official site:")
#define L_ABOUT_SRC_LINK B_TRANSLATE("http://github.com/EXL/Gish")
#define L_ABOUT_SRC_LINK_DESC B_TRANSLATE("Source code:")
#define L_ABOUT_OTH_LINK B_TRANSLATE("http://exlmoto.ru/gish-droid")
#define L_ABOUT_OTH_LINK_DESC B_TRANSLATE("Information:")
#define L_DATA_LINK B_TRANSLATE("https://store.steampowered.com/app/9500/")
#define L_DATA_TEXT B_TRANSLATE("Gish game")
#define L_DATA_FILES_LINK_D B_TRANSLATE("Buy game files on Steam: ")
#define L_DOT B_TRANSLATE(".")
#define L_ERROR_NO_GAMEINFO_FILE B_TRANSLATE("Required data file %file% not found.")
// Object Names
#define O_DOT "dotView"
#define O_ABOUT_LINK "aboutLink"
#define O_ABOUT_LINK_DESC "aboutLinkDesc"
#define O_DATA_LINK "dataLink"
#define O_DATA_LINK_DESC "dataLinkDesc"
class GishAboutWindow : public BeAboutWindow
{
public:
explicit
GishAboutWindow(const BRect &frame, const char *title, const char *version)
: BeAboutWindow(frame, title, version)
{
BStringView *urlDescString = new BStringView(O_ABOUT_LINK_DESC, L_ABOUT_LINK_DESC);
BeUrlStringView *urlString = new BeUrlStringView(O_ABOUT_LINK, L_ABOUT_LINK);
BStringView *urlDescSrcString = new BStringView(O_ABOUT_LINK_DESC, L_ABOUT_SRC_LINK_DESC);
BeUrlStringView *urlSrcString = new BeUrlStringView(O_ABOUT_LINK, L_ABOUT_SRC_LINK);
BStringView *urlDescOthString = new BStringView(O_ABOUT_LINK_DESC, L_ABOUT_OTH_LINK_DESC);
BeUrlStringView *urlOthString = new BeUrlStringView(O_ABOUT_LINK, L_ABOUT_OTH_LINK);
BeAboutWindow::GetInformationView()->Insert(L_ABOUT_STRING);
BeAboutWindow::GetInformationView()->SetFontAndColor(be_bold_font);
BeAboutWindow::GetInformationView()->Insert(L_ABOUT_THANKS_STR_H);
BeAboutWindow::GetInformationView()->SetFontAndColor(be_plain_font);
BeAboutWindow::GetInformationView()->Insert(L_ABOUT_THANKS_STR);
BeAboutWindow::GetInformationView()->SetFontAndColor(be_bold_font);
BeAboutWindow::GetInformationView()->Insert(L_ABOUT_PORT_STR_H);
BeAboutWindow::GetInformationView()->SetFontAndColor(be_plain_font);
BeAboutWindow::GetInformationView()->Insert(L_ABOUT_PORT_STR);
BGroupLayout *boxLayout = BLayoutBuilder::Group<>(B_VERTICAL, 0.0f)
.AddGroup(B_HORIZONTAL, B_USE_HALF_ITEM_SPACING)
.Add(urlDescString)
.Add(urlString)
.AddGlue()
.End()
.AddGroup(B_HORIZONTAL, B_USE_HALF_ITEM_SPACING)
.Add(urlDescSrcString)
.Add(urlSrcString)
.AddGlue()
.End()
.AddGroup(B_HORIZONTAL, B_USE_HALF_ITEM_SPACING)
.Add(urlDescOthString)
.Add(urlOthString)
.AddGlue()
.End();
BeAboutWindow::GetAdditionalBox()->AddChild(boxLayout->View());
}
};
class GishLauncher : public BeLauncherBase
{
virtual bool
CheckCache(void)
{
BString path = BeLauncherBase::GetTextControl()->Text();
if(!path.EndsWith("/"))
{
path << "/";
}
// NOTE: Check some file in the game cache.
path << "texture/face.tga";
BEntry fileToCheck(path);
if(!fileToCheck.Exists())
{
BString errorMessage(L_ERROR_NO_GAMEINFO_FILE);
errorMessage.ReplaceAll("%file%", path);
SetStatusString(B_COLOR_RED, errorMessage);
return false;
}
return true;
}
virtual bool
RunGame(void)
{
return BeLauncherBase::RunGameViaRoster(true, false);
}
virtual void
ShowAboutDialog(void)
{
GishAboutWindow *gameAboutWindow = new GishAboutWindow(Frame().InsetBySelf(BannerWidth(), -(Gap() * 3)),
TITLE, VERSION);
gameAboutWindow->Show();
}
public:
explicit
GishLauncher(const char *startPath)
: BeLauncherBase(TITLE, PACKAGE_DIR, EXECUTABLE_FILE, SETTINGS_FILE, DATA_PATH_OPT,
startPath, true, true)
{
BStringView *urlDescString = new BStringView(O_DATA_LINK_DESC, L_DATA_FILES_LINK_D);
BeUrlStringView *urlString = new BeUrlStringView(O_DATA_LINK, L_DATA_TEXT, L_DATA_LINK);
BStringView *dot = new BStringView(O_DOT, L_DOT);
BGroupLayout *boxLayout = BLayoutBuilder::Group<>(B_VERTICAL, B_USE_HALF_ITEM_SPACING)
.AddGroup(B_HORIZONTAL, 0.0f)
.Add(urlDescString)
.Add(urlString)
.Add(dot)
.AddGlue()
.End();
BeLauncherBase::GetAdditionalBox()->AddChild(boxLayout->View());
}
};
int
main(void)
{
BeApp *beApp = new BeApp(SIGNATURE);
GishLauncher *gishLauncher = new GishLauncher(BeUtils::GetPathToHomeDir());
beApp->SetMainWindow(gishLauncher);
beApp->Run();
delete beApp;
beApp = NULL;
return 0;
}