Skip to content

Commit 69f288b

Browse files
authored
Merge branch 'masterv2' into custom-constant-buffer
2 parents f629015 + bdc6c81 commit 69f288b

File tree

11 files changed

+221
-13
lines changed

11 files changed

+221
-13
lines changed

editor/editor_application.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,14 +68,13 @@ void EditorApplication::setGameMode(bool enabled)
6868
InputSystem::GetSingleton()->loadSchemes(m_ApplicationSettings->getJSON()["systems"]["InputSystem"]["inputSchemes"]);
6969
InputSystem::GetSingleton()->pushScheme(m_ApplicationSettings->getJSON()["systems"]["InputSystem"]["startScheme"]);
7070
InputInterface::GetSingleton()->m_IsEnabled = enabled;
71-
m_IsAutoSave = !enabled;
7271

7372
EventManager::GetSingleton()->call(EditorEvents::EditorReset);
7473
}
7574

7675
void EditorApplication::process(float deltaMilliseconds)
7776
{
78-
if (m_IsAutoSave && ((m_ApplicationTimer.Now() - m_PointAtLast10Second).count()) * NS_TO_MS * MS_TO_S > m_AutoSaveDurationS)
77+
if (((m_ApplicationTimer.Now() - m_PointAtLast10Second).count()) * NS_TO_MS * MS_TO_S > m_AutoSaveDurationS)
7978
{
8079
EventManager::GetSingleton()->call(EditorEvents::EditorAutoSave);
8180
m_PointAtLast10Second = m_ApplicationTimer.Now();

editor/editor_application.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ class EditorApplication : public Application
88
static void SetSingleton(EditorApplication* app);
99

1010
unsigned int m_AutoSaveDurationS = 300.0f;
11-
bool m_IsAutoSave = true;
1211
TimePoint m_PointAtLast10Second;
1312
FrameTimer m_FrameTimer;
1413

editor/editor_system.cpp

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -458,6 +458,8 @@ void EditorSystem::drawDefaultUI(float deltaMilliseconds)
458458
}
459459
if (ImGui::BeginMenu("Scene"))
460460
{
461+
ImGui::Checkbox("Autosave", &m_Autosave);
462+
461463
if (SceneLoader::GetSingleton()->getCurrentScene())
462464
{
463465
SceneLoader::GetSingleton()->getCurrentScene()->getSettings().draw();
@@ -859,9 +861,14 @@ Variant EditorSystem::saveAll(const Event* event)
859861

860862
Variant EditorSystem::autoSave(const Event* event)
861863
{
862-
PRINT("Auto-saving current scene...");
863-
saveAll(nullptr);
864-
return true;
864+
if (m_Autosave && !(m_Toolbar->getSettings().m_InEditorPlaying))
865+
{
866+
PRINT("Auto-saving current scene...");
867+
saveAll(nullptr);
868+
return true;
869+
}
870+
871+
return false;
865872
}
866873

867874
Variant EditorSystem::saveBeforeQuit(const Event* event)

editor/editor_system.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ class EditorSystem : public System
3232
unsigned int m_EditorStyleVarPushCount;
3333
bool m_WireframeMode = false;
3434
bool m_WorldMode = true;
35+
bool m_Autosave = false;
3536

3637
ImFont* m_EditorFont;
3738
ImFont* m_EditorFontItalic;

editor/gui/toolbar_dock.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
Variant ToolbarDock::disablePlayInEditor(const Event* e)
1515
{
16-
m_InEditorPlaying = false;
16+
m_ToolbarDockSettings.m_InEditorPlaying = false;
1717
EditorApplication::GetSingleton()->setGameMode(false);
1818
if (!m_StartPlayingScene.empty())
1919
{
@@ -48,7 +48,7 @@ void ToolbarDock::draw(float deltaMilliseconds)
4848
"Play Game"
4949
};
5050

51-
if (m_InEditorPlaying)
51+
if (m_ToolbarDockSettings.m_InEditorPlaying)
5252
{
5353
ImColor lightErrorColor = EditorSystem::GetSingleton()->getFatalColor();
5454
lightErrorColor.Value.x *= 0.8f;
@@ -67,21 +67,21 @@ void ToolbarDock::draw(float deltaMilliseconds)
6767
switch (playModeSelected)
6868
{
6969
case 0:
70-
m_InEditorPlaying = true;
70+
m_ToolbarDockSettings.m_InEditorPlaying = true;
7171
m_StartPlayingScene = SceneLoader::GetSingleton()->getCurrentScene()->getScenePath();
7272
EventManager::GetSingleton()->call(EditorEvents::EditorSaveAll);
7373
EditorApplication::GetSingleton()->setGameMode(true);
7474
SceneLoader::GetSingleton()->loadScene(m_StartPlayingScene, {});
7575
PRINT("Loaded Scene in Editor");
7676
break;
7777
case 1:
78-
m_InEditorPlaying = false;
78+
m_ToolbarDockSettings.m_InEditorPlaying = false;
7979
EventManager::GetSingleton()->call(EditorEvents::EditorSaveAll);
8080
OS::RunApplication("\"" + OS::GetGameExecutablePath() + "\" " + SceneLoader::GetSingleton()->getCurrentScene()->getScenePath());
8181
PRINT("Launched Game process with Scene");
8282
break;
8383
case 2:
84-
m_InEditorPlaying = false;
84+
m_ToolbarDockSettings.m_InEditorPlaying = false;
8585
EventManager::GetSingleton()->call(EditorEvents::EditorSaveAll);
8686
OS::RunApplication("\"" + OS::GetGameExecutablePath() + "\"");
8787
PRINT("Launched Game process");

editor/gui/toolbar_dock.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,13 @@ class ToolbarDock
1313
struct ToolbarDockSettings
1414
{
1515
bool m_IsActive = true;
16+
bool m_InEditorPlaying = false;
1617
};
1718

1819
private:
1920
ToolbarDockSettings m_ToolbarDockSettings;
2021
Vector<float> m_FPSRecords;
2122
unsigned int m_FPSRecordsPoolSize = 100;
22-
bool m_InEditorPlaying = false;
2323
String m_StartPlayingScene;
2424

2525
Variant disablePlayInEditor(const Event* e);
Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
{
2+
"ID": 21,
3+
"children": [
4+
{
5+
"ID": 22,
6+
"children": [],
7+
"entity": {
8+
"components": null,
9+
"script": {
10+
"overrides": {
11+
"pauseScene": ""
12+
},
13+
"path": "rootex/assets/scripts/pause.lua"
14+
}
15+
},
16+
"importStyle": 0,
17+
"name": "pauser",
18+
"pause": false,
19+
"sceneFile": "",
20+
"settings": {
21+
"camera": 1,
22+
"inputSchemes": {},
23+
"listener": 1,
24+
"preloads": [],
25+
"startScheme": ""
26+
}
27+
}
28+
],
29+
"entity": {
30+
"components": {
31+
"MusicComponent": {
32+
"attenuationModel": 53251,
33+
"audio": "rootex/assets/ball.wav",
34+
"isAttenuated": false,
35+
"isLooping": true,
36+
"maxDistance": 100.0,
37+
"playOnStart": true,
38+
"referenceDistance": 1.0,
39+
"rollOffFactor": 1.0,
40+
"volume": 1.0
41+
},
42+
"TextUIComponent": {
43+
"color": {
44+
"a": 1.0,
45+
"b": 0.0,
46+
"g": 0.0,
47+
"r": 0.0
48+
},
49+
"fontResource": "rootex/assets/fonts/lato_30_bold.spritefont",
50+
"isVisible": true,
51+
"mode": 0,
52+
"origin": {
53+
"x": 45.0,
54+
"y": 62.0
55+
},
56+
"rotation": 0.0,
57+
"text": ""
58+
},
59+
"TransformComponent": {
60+
"boundingBox": {
61+
"center": {
62+
"x": 0.0,
63+
"y": 0.0,
64+
"z": 0.0
65+
},
66+
"extents": {
67+
"x": 0.5,
68+
"y": 0.5,
69+
"z": 0.5
70+
}
71+
},
72+
"overrideBoundingBox": false,
73+
"passDown": 7,
74+
"position": {
75+
"x": 0.0,
76+
"y": 0.0,
77+
"z": 0.0
78+
},
79+
"rotation": {
80+
"w": 0.7073882222175598,
81+
"x": -0.7068251967430115,
82+
"y": 0.0,
83+
"z": -0.0
84+
},
85+
"scale": {
86+
"x": 1.0,
87+
"y": 0.9999659061431885,
88+
"z": 0.9999659061431885
89+
}
90+
}
91+
},
92+
"script": null
93+
},
94+
"importStyle": 0,
95+
"name": "pausing",
96+
"pause": true,
97+
"sceneFile": "rootex/assets/scenes/pause.scene.json",
98+
"settings": {
99+
"camera": 1,
100+
"inputSchemes": {},
101+
"listener": 1,
102+
"preloads": [],
103+
"startScheme": "Load"
104+
}
105+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
"ID": 5,
3+
"children": [],
4+
"entity": {
5+
"components": {
6+
"UIComponent": {
7+
"filePath": "rootex/assets/ui/pause/pauseUI.rml"
8+
}
9+
},
10+
"script": null
11+
},
12+
"importStyle": 0,
13+
"name": "pause",
14+
"pause": true,
15+
"sceneFile": "rootex/assets/scenes/pauseUI.scene.json",
16+
"settings": {
17+
"camera": 1,
18+
"inputSchemes": {},
19+
"listener": 1,
20+
"preloads": [],
21+
"startScheme": ""
22+
}
23+
}

rootex/assets/scripts/pause.lua

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
Pause = class("Pause")
2+
3+
function Pause:initialize(entity)
4+
self.exports = {
5+
pauseScene = "Enter scene to pause"
6+
}
7+
self.running = false
8+
9+
end
10+
11+
function Pause:enterScene(entity)
12+
entity:bind("InputPause", Pause.onPauseLevel)
13+
end
14+
15+
function Pause:Resume(entity)
16+
RTX.GetCurrentScene():removeChild(RTX.Scene.FindScenesByName("pause")[1])
17+
self.running = false
18+
RTX.System.unPause()
19+
end
20+
21+
function Pause:onPauseLevel(entity, event)
22+
::start::
23+
if event:getData().y == 1 and self.running == false then
24+
RTX.GetCurrentScene():addChild(RTX.Scene.CreateFromFile("rootex/assets/scenes/pauseUI.scene.json"))
25+
self.running = true
26+
RTX.System.pause()
27+
elseif event:getData().y == 1 and self.running == true then
28+
if((#RTX.Scene.FindScenesByName("pause"))==0) then
29+
self.running=false
30+
goto start
31+
end
32+
RTX.GetCurrentScene():removeChild(RTX.Scene.FindScenesByName("pause")[1])
33+
self.running = false
34+
RTX.System.unPause()
35+
end
36+
37+
return true
38+
end
39+
40+
function Pause:destroy()
41+
end
42+
43+
return Pause

rootex/assets/ui/pause/pauseUI.rml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<rml>
2+
<head>
3+
<title>Transition</title>
4+
<style>
5+
body {
6+
font: "Lato";
7+
font-size: 50px;
8+
color: black;
9+
padding: 2rem 0 2rem 0;
10+
background-color: #808080;
11+
width: 100%;
12+
height: 100%;
13+
opacity: 0.75;
14+
}
15+
h1,h2 {
16+
display:block;
17+
text-align:center;
18+
}
19+
h2:hover {
20+
color: grey;
21+
}
22+
</style>
23+
</head>
24+
25+
<body>
26+
<h1 style="margin-bottom: 2rem; display:block;">Pause Menu</h1>
27+
<h2 onclick="Pause:Resume()">Resume</h2>
28+
<h2>Settings</h2>
29+
<h2>Exit</h2>
30+
</body>
31+
</rml>

0 commit comments

Comments
 (0)