-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.cpp
108 lines (78 loc) · 2.38 KB
/
main.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
#include <clocale>
#include <locale>
#include <iostream>
#include <string>
#if defined __GNUC__ || defined __GNUG__
#include <windows.h>
#else
#include <Windows.h>
#endif
#include <conio.h>
#include "localization.hpp"
#include "simpleSelect.hpp"
#define MAIN_CM "start zdoom.exe Wolf3D_Common.pk7 -config \"zdoom - wolf3d.ini\""
std::string input(const std::string& helpText,bool important){
std::string ret;
std::string printText = helpText + ( (!important)? localizedString(LTEXT_SKIP) : "") + ":";
std::cout << printText << std::flush;
std::getline(std::cin,ret);
if(ret[0]<32){
if(important){
while(ret[0]<32){
std::cout << localizedString(LTEXT_IMPORTANT_PARAMETER) << std::endl;
std::cout << printText << std::flush;
std::getline(std::cin,ret);
}
}else{
return std::string();
}
}
return ret;
}
void connect() {
std::string joinip;
std::string cm = MAIN_CM;
cm.append(" -join " + input(localizedString(LTEXT_IP_TO_JOIN),true));
clearConsole();
std::cout << std::endl << localizedString(LTEXT_LAUNCH_WOLF) << cm << std::endl;
system(cm.c_str());
}
void createServer() {
std::string host,map,skill;
std::string cm = MAIN_CM;
cm.append(" -host " + input(localizedString(LTEXT_AMOUNT_OF_PLAYERS),true));
cm.append(" +map " + input(localizedString(LTEXT_MAP_CODE),true));
cm.append(" -skill " + input(localizedString(LTEXT_DIFFICULTY_NUMBER),true));
cm.append(" " + input(localizedString(LTEXT_CUSTOM_PARAMETERS),false));
clearConsole();
std::cout << std::endl << localizedString(LTEXT_LAUNCH_WOLF) << cm << std::endl;
system(cm.c_str());
}
void playOffline() {
std::string cm = MAIN_CM;
cm.append(" " + input(localizedString(LTEXT_CUSTOM_PARAMETERS),false));
std::cout << std::endl << localizedString(LTEXT_LAUNCH_WOLF) << cm << std::endl;
system(cm.c_str());
}
int main() {
setlocale(LC_ALL,"Russian");
SetConsoleTitle("TUIWolfCoopLauncher v1.2 by dartvader316");
SetCurrentDirectory(".\\base");
int selectedMode = 0;
selectLanguage();
clearAnswers();
bool quit = false;
makeAnswer(LTEXT_PLAY_OFFLINE);
makeAnswer(LTEXT_HOST_COOP_SERVER);
makeAnswer(LTEXT_CONNECT_TO_SERVER);
makeAnswer(LTEXT_EXIT);
while (!quit) {
selectedMode = question(LTEXT_SELECT_WHAT_TO_TO,0);
switch (selectedMode) {
case 1: playOffline(); break;
case 2: createServer(); break;
case 3: connect(); break;
case 4: quit = true; break;
}
}
}