-
Notifications
You must be signed in to change notification settings - Fork 0
/
mapeditor.py
105 lines (84 loc) · 3.03 KB
/
mapeditor.py
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
#Tools/Mapeditor
from engine import shared, debug
shared.logInit("mapeditor")
shared.DPrint("Main",1,"Initializing Modules...")
from engine.Render import render
from engine.Object import prop, decorator, zone, directormanager
from engine.Networking.client import client
from engine.World import maploader, pathfinding
from engine.Tool import astarGen
from engine.Tool.Mapeditor import globalgui, toolmanager, backend, mapfile
from sys import argv
from os.path import isfile
shared.wd="./Data/Map/"
shared.side = "Tool"
#Mainloop
shared.DPrint("Main",1,"Initializing Mainloop...")
shared.client=client.Service()
shared.reactor=client.reactor
#Render
shared.DPrint("Main",1,"Initializing Render...")
shared.render=render.RenderApplication(True) #Render should only Initialize, not setup
#Managers
shared.DPrint("Main",1,"Initializing Managers...")
#shared.unitManager=unitmanager.UnitManager()
shared.unitHandeler=shared.unitManager
shared.decHandeler=decorator.DecoratorHandeler()
shared.propManager=prop.propManager()
shared.zoneManager=zone.zoneManager()
#Mapeditor spesific
shared.toolManager=toolmanager.ToolManager()
shared.mapBackend=backend.MapeditorBackend()
#MapLoader
shared.MapLoader=maploader.MapLoader()
if len(argv)!=1:
if isfile(shared.wd+argv[1]):
shared.Map=shared.MapLoader.Load(argv[1])
else:
print("Map %s does not exsist!" % (shared.wd+argv[1]))
exit()
else:
print("No map specified. Loading empty map..")
shared.Map=shared.MapLoader.Load("empty.map")
#MapSaver
shared.Mapfile=mapfile.Mapfile()
#CommandParser
shared.DPrint("Main",1,"Initializing CommandParser...")
shared.ParseCommand=debug.ParseCommand
#DirectorManager
shared.DPrint("Main",1,"Initializing DirectorManager...")
shared.DirectorManager=directormanager.DirectorManager()
shared.DirectorManager.Init("Mapeditor")
shared.DirectorManager.Action("Mapeditor")
#Pathfinding
shared.Pathfinder = pathfinding
shared.astarGen=astarGen.aStarGenerators()
#Power it up!
shared.DPrint("Main",1,"Startin' Powerin' up!..")
shared.DPrint("Main",1,"PWR: UnitManager")
#shared.unitManager.PowerUp()
shared.DPrint("Main",1,"PWR: Render")
shared.render.PowerUp()
shared.render3dScene.Setup()
#shared.renderGUI.SetupBare()
shared.globalGUI=globalgui.MapeditorGUI()
shared.globalGUI.Setup()
shared.renderGUI.createDebugOnly()
shared.renderioInput.SetupBare()
from engine.Render.render3dcamera import MASK_CAMERA
from engine.Render.render3dwater import MASK_WATER
from engine.Render.render3dent import MASK_UNIT, MASK_DECO, MASK_OTHER, MASK_GADGET
from engine.Render.render3dterrain import MASK_TERRAIN
shared.render3dSelectStuff.Trigger = MASK_UNIT | MASK_DECO | MASK_OTHER
shared.DPrint("Main",1,"PWR: MapSetup")
shared.Map.Setup()
shared.Map.SetupUnits()
#Release tha clutch and start moving forward
shared.DPrint("Main", 1, "Starting Mainloop..")
shared.client.Run()
#We have come to a stop, lets clean up after ourselves
shared.DPrint("Main", 1, "Mainloop stopped..")
shared.client.cleanUp()
shared.DPrint("Main", 1, "Cleaning up render..")
shared.render.cleanUp()
shared.DPrint("Main", 1, "Ha det bra..")