This repository has been archived by the owner on Apr 23, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Client.pyw
190 lines (139 loc) · 5.65 KB
/
Client.pyw
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
# Copyright (C) 2004-2007 Prairie Games, Inc
# Please see LICENSE.TXT for details
#I have to disable this on client until it has SSL
#from twisted.internet.iocpreactor import install
#install()
import imp, os, sys,time,shutil,traceback
from mud.gamesettings import *
if sys.platform[:6] != 'darwin':
import win32con
import win32api
import win32event
import winerror
import win32gui
import struct
#only allow one instance
if "-patch" in sys.argv:
HMUTEX = win32event.CreateMutex(None, 1, "PrairieGamesMinionsOfMirthPatcher")
else:
HMUTEX = win32event.CreateMutex(None, 1, "PrairieGamesMinionsOfMirth")
if win32api.GetLastError() == winerror.ERROR_ALREADY_EXISTS:
win32api.MessageBox(0, 'There is another instance of MinionsOfMirth.exe running. Please close this instance down or restart your computer and try again.', "Error",win32con.MB_OK)
sys.exit()
def main_is_frozen():
return (hasattr(sys, "frozen") or # new py2exe
hasattr(sys, "importers") # old py2exe
or imp.is_frozen("__main__")) # tools/freeze
def get_main_dir():
if main_is_frozen():
return os.path.dirname(sys.executable)
return os.path.dirname(sys.argv[0])
def main():
#if we're running from py2exe add the cwd
if main_is_frozen():
#maindir = get_main_dir()
if sys.platform[:6] == 'darwin':
#need to go up three folders
os.chdir("../../../common")
maindir = os.getcwd()
else:
os.chdir("../common")
maindir = os.getcwd()
sys.path.append(maindir)
print "main dir",maindir
print "cwd",os.getcwd()
#editor is importing this and running it
import pytorque
from twisted.internet import reactor
from mud.world.core import CoreSettings
sys.argv.append("-game")
sys.argv.append(GAMEROOT)
if "-ide" in sys.argv:
CoreSettings.IDE = True
#we're launching from ide
for v in sys.argv:
if v.startswith("-idezone="):
CoreSettings.IDE_ZONE = v[9:]
if v.startswith("-editzone"):
CoreSettings.IDE_EDITZONE = True
pytorque.Init(len(sys.argv),sys.argv)
import tgenative
from tgenative import TGESetGlobal,TGEGetGlobal,TGEEval
from mud.world.defines import RPG_BUILD_DEMO,RPG_BUILD_TESTING
import mud.client
import mud.client.jukebox
if "-ide" in sys.argv:
TGESetGlobal("$pref::developer",1)
if RPG_BUILD_DEMO:
gui = ["SinglePlayerGui","MultiplayerGui","NewCharacterGui","MainMenuGui","MasterGui","WorldGui","PatcherGui"]
for g in gui:
tgenative.TGEObject(g).setBitmap("~/client/ui/mom_menu_background_demo")
elif RPG_BUILD_TESTING:
gui = ["SinglePlayerGui","MultiplayerGui","NewCharacterGui","MainMenuGui","MasterGui","WorldGui","PatcherGui"]
for g in gui:
tgenative.TGEObject(g).setBitmap("~/client/ui/mom_menu_background_test")
else:
gui = ["SinglePlayerGui","MultiplayerGui","NewCharacterGui","MainMenuGui","MasterGui","WorldGui","PatcherGui"]
for g in gui:
tgenative.TGEObject(g).setBitmap("~/client/ui/mom_menu_background")
cf = "./log_MoMChat.txt"
gf = "./log_MoMGame.txt"
if sys.platform[:6] != 'darwin':
gf = "./log_Game.txt"
cf = "./log_Chat.txt"
from twisted.python.logfile import LogFile
try:
os.remove(cf)
except:
pass
try:
os.remove(gf)
except:
pass
if sys.platform[:6] != 'darwin':
CoreSettings.LOGCHAT = LogFile("log_Chat.txt","./",None)
CoreSettings.LOGGAME = LogFile("log_Game.txt","./",None)
else:
CoreSettings.LOGCHAT = LogFile("log_Chat.txt","./",None)
CoreSettings.LOGGAME = LogFile("log_Game.txt","./",None)
import datetime
n = datetime.datetime.now()
s = n.strftime("%A %B %d %I:%M:%S %p %Y")
CoreSettings.LOGCHAT.write("\n-------------------------------------------\n")
CoreSettings.LOGCHAT.write("%s - Chat Log Opened\n"%s)
CoreSettings.LOGCHAT.write("-------------------------------------------\n")
CoreSettings.LOGGAME.write("\n-------------------------------------------\n")
CoreSettings.LOGGAME.write("%s - Game Log Opened\n"%s)
CoreSettings.LOGGAME.write("-------------------------------------------\n")
checkide = True
while pytorque.Tick():
if checkide:
checkide = False
if CoreSettings.IDE and CoreSettings.IDE_ZONE:
TGEEval("Canvas.setContent(SinglePlayerGui);")
from mud.client.gui.singleplayerGui import OnLoadSingleWorld
OnLoadSingleWorld("editworld")
# Make sure to clean up if we exited by shortcut.
from mud.client.playermind import CLIENTEXITED,OnReallyQuit
if not CLIENTEXITED:
OnReallyQuit(True)
sys.stdout = sys.oldstdout
sys.stderr = sys.oldstderr
CoreSettings.LOGCHAT.close()
CoreSettings.LOGGAME.close()
pytorque.Shutdown()
if __name__ == '__main__':
if "-patch" in sys.argv:
from patcher import RunPatcher
RunPatcher()
else:
#import profile
from twisted.python import log
f = "./log_Client.txt"
LOGFILE = file(f,"w")
log.startLogging(LOGFILE,setStdout=True)
#profile.run("main()","profile.prof")
main()
LOGFILE.close()
if sys.platform[:6] != 'darwin':
win32api.CloseHandle(HMUTEX)