-
Notifications
You must be signed in to change notification settings - Fork 2
/
app.monkey2
115 lines (94 loc) · 2.67 KB
/
app.monkey2
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
Namespace diddy2.app
Class DiddyApp
Private
Global _Instance:DiddyApp = null
Field _window:DiddyWindow
Field _assetBank:AssetBank
Field _channelManager:ChannelManager
Field _soundVolume:Float = 1
Field _musicVolume:Float = 1
Field _filterTextures:Bool
Field _appInstance:AppInstance
Public
Method New(title:String, width:Int, height:Int, virtualResolutionWidth:Int, virtualResolutionHeight:Int, filterTextures:Bool = True, flags:WindowFlags = WindowFlags.Resizable, layout:String = "letterbox", fps:Int = 60, swapInterval:Int = 1)
_appInstance = New AppInstance
_Instance = Self
_window = New DiddyWindow(title, width, height, virtualResolutionWidth, virtualResolutionHeight, filterTextures, flags, layout, fps, swapInterval)
_assetBank = New AssetBank(filterTextures)
_filterTextures = filterTextures
_channelManager = New ChannelManager
_window.CreateScreenBank(_Instance)
End
Function GetInstance:DiddyApp()
If Not _Instance
Print "ERROR: DiddyApp instance is NULL"
End
Return _Instance
End
Property SoundVolume:Float()
Return _soundVolume
Setter(amount:Float)
amount = Clamp(amount, 0.0, 1.0)
_soundVolume = amount
For Local i:Int = 0 Until ChannelManager.MAX_CHANNELS
ChannelManager.SetChannelVolume(_soundVolume, i)
ChannelManager.MaxVolume = _soundVolume
Next
End
Property MusicVolume:Float()
Return _musicVolume
Setter(amount:Float)
amount = Clamp(amount, 0.0, 1.0)
_musicVolume = amount
ChannelManager.SetMusicVolume(_musicVolume)
End
Property AppInstance:AppInstance()
Return _appInstance
End
Property FilterTextures:Bool()
Return _filterTextures
End
Property AssetBank:AssetBank()
Return _assetBank
End
Function GetAssetBank:AssetBank()
Return GetInstance()._assetBank
End
Property ChannelManager:ChannelManager()
Return _channelManager
End
Property Window:DiddyWindow()
Return _window
End
Function GetWindow:DiddyWindow()
Return GetInstance()._window
End
Function GetChannelManager:ChannelManager()
Return GetInstance()._channelManager
End
Function GetScreenBank:ScreenBank()
Return GetInstance()._window.ScreenBank
End
Function GetScreenFunc:Screen(screen:String)
Return GetInstance()._window.ScreenBank.GetScreen(screen)
End
Method Start(screen:Screen)
_window.Start(screen)
App.Run()
End
Method AddScreen(screen:Screen)
_window.ScreenBank.AddScreen(screen)
End
Method GetScreen:Screen(name:String)
Return _window.ScreenBank.GetScreen(name)
End
Method GetCurrentScreen:Screen()
Return _window.CurrentScreen
End
Method SetCurrentScreen(screen:Screen)
_window.CurrentScreen = screen
End
Method SetDebug(debugOn:Bool)
_window.DebugOn = debugOn
End
End