/
GameViewController.swift
112 lines (81 loc) · 3.1 KB
/
GameViewController.swift
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
//
// GameViewController.swift
// DOOM3-iOS
//
// Created by Tom Kidd on 1/26/19.
//
import UIKit
class GameViewController: UIViewController {
var difficulty = -1
var newgame = false
@IBOutlet weak var backgroundImage: UIImageView!
@IBOutlet weak var loadingLabel: UILabel!
var selectedSavedGame = ""
override func viewDidLoad() {
super.viewDidLoad()
var gameDir = ""
gameDir = "base"
#if os(tvOS)
let documentsDir = try! FileManager().url(for: .cachesDirectory, in: .userDomainMask, appropriateFor: nil, create: true).path
#else
let documentsDir = try! FileManager().url(for: .documentDirectory, in: .userDomainMask, appropriateFor: nil, create: true).path
#endif
// print("documentsDir: \(documentsDir)")
// todo: fix for DOOM3 -tkidd
//Sys_SetHomeDir(documentsDir)
DispatchQueue.main.asyncAfter(deadline: .now() + 1.0) { // Change `2.0` to the desired number of seconds.
var argv: [String?] = [ Bundle.main.resourcePath! + "/doom3"];
// argv.append("+map")
// argv.append("game/alphalabs2")
// argv.append("\(self.difficulty)")
if self.difficulty >= 0 {
argv.append("+set")
argv.append("g_skill")
argv.append("\(self.difficulty)")
}
if self.newgame {
// argv.append("+startGame")
// mars_city1
argv.append("+map")
argv.append("game/mars_city1")
}
// Mission Pack
#if _D3XP
argv.append("+set")
argv.append("fs_game")
argv.append("d3xp")
#endif
if !self.selectedSavedGame.isEmpty {
argv.append("+loadGame")
argv.append(self.selectedSavedGame)
}
var commandLine = ""
for arg in argv {
commandLine += " " + arg!
}
print(commandLine)
argv.append(nil)
let argc:Int32 = Int32(argv.count - 1)
var cargs = argv.map { $0.flatMap { UnsafeMutablePointer<Int8>(strdup($0)) } }
// todo: fix for DOOM3 -tkidd
Sys_Startup(argc, &cargs)
for ptr in cargs { free(UnsafeMutablePointer(mutating: ptr)) }
}
}
#if os(iOS)
override var prefersHomeIndicatorAutoHidden: Bool {
return true
}
override var preferredScreenEdgesDeferringSystemGestures: UIRectEdge {
return .bottom
}
#endif
/*
// MARK: - Navigation
// In a storyboard-based application, you will often want to do a little preparation before navigation
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
// Get the new view controller using segue.destination.
// Pass the selected object to the new view controller.
}
*/
}