Skip to content

Commit

Permalink
save settings
Browse files Browse the repository at this point in the history
  • Loading branch information
karliky committed Jun 28, 2020
1 parent 715e48f commit 8a46421
Show file tree
Hide file tree
Showing 9 changed files with 114 additions and 12 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "bugcraft-studio",
"version": "1.0.2-beta",
"version": "1.0.3-beta",
"author": "karliky <[email protected]>",
"description": "In-game cinematics for World of Warcraft",
"license": "Unlicense",
Expand Down
1 change: 1 addition & 0 deletions settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"camera":{"collision":true,"spectateSpeed":"0.6"},"environment":{"timeOfDayEnabled":false},"settings":{"alwaysOnTop":false}}
7 changes: 7 additions & 0 deletions src/core/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ window.launch = launchCore;
// Legion working 55 8B EC 83 7D 0C 00 8B 45 08 74 08 09 05 ????????
// 0.5.3 .port -1315 -1216 60.0582 0
// rendering 0.5.3 top lighting 80 99 90 07
// Wireframe ligithing 82FAF921
// only wmo wireframe 74 4B 10 31
// more clear 755500FF
// only near 09D2F824
Expand Down Expand Up @@ -180,6 +181,8 @@ window.launch = launchCore;
// WoW.exe+83486 - C7 45 DC 00000000 - mov [ebp-24],00000000 { 0 }
// WoW.exe+8348D - C7 45 E0 00000000 - mov [ebp-20],00000000 { 0 }
// 0.5.3 WoWClient.DayNightRenderSky+8B - E9 2024FEFF - jmp WoWClient.DNClouds::Render
// 0.5.3 WoWClient.GxRsSet+72 - 68 58788500 - push WoWClient.exe+457858 { ("value >= -2.0f && value <= 2.0f") }
// 0.5.3 Texture LOD 00E40520
// 1.12.1 funny low poly mode WoW.exe+8368F - D9 05 A0B4C700 - fld dword ptr [WoW.exe+87B4A0] { (0.00) }
// 1.12.1 disable m2 rendering WoW.exe+836A6 - E8 55522800 - call WoW.exe+308900
// 1.12.1 disable grass rendering WoW.exe+836CA - E8 F1CA1E00 - call WoW.exe+2701C0
Expand Down Expand Up @@ -228,3 +231,7 @@ window.launch = launchCore;
// WMO Common pattern 74 8B 1E 46 7C 0B BC C5
// 4.3.4 WMO rendering related wow.exe+39F37E - 39 46 50 - cmp [esi+50],eax
// 4.3.4 WMO Rendering change this wow.exe+39F378 - 8B 87 94000000 - mov eax,[edi+00000094] to 00000090
// Player Scale pattern 1.12 00 00 80 3F 00 00 80 3F 00 00 80 3F 9A 99 99 3F 00 00 00 00 00 00 00 3F 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 D9 11 68 40 F8 64 00 C0 42 DA 94 BF C8 53 54 BF B5 31 CB 3F
// Small pattern by nogg 00 00 00 3F 00 00 80 3F 00 00 80 3F 9A 99 99 3F 00 00 00 00 00 00 80 3F 00 00 00 00 00 00 00 00
// 0.5.3 Scale WoWClient.CGObject_C::GetScale+3 - D9 40 10 - fld dword ptr [eax+10]
// 0.5.3 WoWClient.CGObject_C::GetScale+3 - D9 05 18390B01 - fld dword ptr [WoWClient.exe+CB23B4] { (0.70) }
43 changes: 43 additions & 0 deletions src/renderer/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
</template>

<script>
const electron = require("electron");
const fs = require('fs');
const { get } = require('lodash');
export default {
name: 'bugcraft-studio',
mounted() {
Expand All @@ -16,9 +19,49 @@
}
store.commit('setGameInfo', AppManager.Game);
store.commit('setCore', AppManager);
setTimeout(() => {
/**
* Save/Load Settings
*/
const settingsPaths = this.$store.state.settings.configPath;
try {
console.log('# Loading settings from ', settingsPaths);
fs.accessSync(settingsPaths, fs.constants.R_OK | fs.constants.W_OK);
const settings = JSON.parse(fs.readFileSync(settingsPaths, 'utf8'));
console.log('# Existing settings', settings);
applySettings(settings, store);
} catch (error) {
try {
if (error.message.includes('ENOENT: no such file or directory, access')) {
console.log('# Creating settings as they don\'t exist ', settingsPaths);
const settings = JSON.stringify(this.$store.getters.getExistingSettings);
return fs.writeFileSync(settingsPaths, settings, 'utf8');
}
this.$router.push({ name: 'error', params: { error: error.message }});
} catch (error) {
this.$router.push({ name: 'error', params: { error: error.message }});
}
}
});
});
}
};
function applySettings (settings, store) {
const win = electron.remote.getCurrentWindow();
const cameraCollision = get(settings, 'camera.collision', undefined);
const spectateSpeed = get(settings, 'camera.spectateSpeed', undefined);
const timeOfDayEnabled = get(settings, 'environment.timeOfDayEnabled', undefined);
const alwaysOnTop = get(settings, 'settings.alwaysOnTop', undefined);
if (cameraCollision !== undefined) store.commit("setCollision", cameraCollision);
if (spectateSpeed !== undefined) store.commit("setSpeed", spectateSpeed);
if (timeOfDayEnabled !== undefined) store.commit("setTimeOfDayStatus", timeOfDayEnabled);
if (alwaysOnTop !== undefined) {
store.commit("setAlwaysOnTop", alwaysOnTop);
win.setAlwaysOnTop(alwaysOnTop);
}
}
</script>

<style lang="scss">
Expand Down
21 changes: 13 additions & 8 deletions src/renderer/components/error.vue
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,13 @@
v-on:click="open('https://github.com/noggaholic/bugcraft-studio')"
>https://github.com/noggaholic/bugcraft-studio</a>
</p>
<button class="err-button" v-on:click="exit()">Close BugCraft Studio</button>
<div class="actions">
<button class="err-button" v-on:click="reload()">Reload</button>
<button class="err-button" v-on:click="exit()">Close BugCraft Studio</button>
</div>
</div>
</div>
</div>
<!-- <div class="card card--default is-active">
<div class="card__header">
<img class="card__img"..../>
<h1 class="card__title"></h1>
</div>
<div class="card__body"></div>
</div> -->
</template>
<script>
const { shell, remote } = require('electron');
Expand All @@ -36,6 +32,10 @@
let w = remote.getCurrentWindow()
w.close();
},
reload() {
const getUrl = window.location;
window.location.href = getUrl.protocol + "//" + getUrl.host + "/" + getUrl.pathname.split('/')[1];
},
open(link) {
shell.openExternal(link);
}
Expand Down Expand Up @@ -88,6 +88,7 @@
}
.err-button {
border-radius: 5px;
margin: 5px;
padding: 10px 10px 15px 10px;
font-size: 16px;
font-size: 16px;
Expand All @@ -112,4 +113,8 @@
.description {
color: red;
}
.actions {
display: flex;
align-items: center;
}
</style>
6 changes: 6 additions & 0 deletions src/renderer/components/sections/settings.vue
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@
</label>
</div>
</div>
<div class="columns">
Settings are saved at {{this.$store.state.settings.configPath}}
</div>
<small><i>World of Warcraft® and Blizzard Entertainment® are
all trademarks or registered trademarks of Blizzard
Entertainment in the United States and/or other
Expand Down Expand Up @@ -89,4 +92,7 @@ export default {
</script>

<style scoped>
small {
color:#5a5a5a;
}
</style>
16 changes: 13 additions & 3 deletions src/renderer/components/topbar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -31,20 +31,29 @@
<script>
const { remote } = require('electron');
var TMP = { maximized: false }
let win;
export default {
name: 'topbar',
created() {
win = remote.BrowserWindow.getFocusedWindow();
const store = this.$store;
window.onbeforeunload = (e) => {
const win = remote.getCurrentWindow();
store.dispatch('saveSettings');
store.commit('setMode', 'DISABLED');
store.commit("setTimeOfDayStatus", false);
process.nextTick(() => win.destroy());
}
},
mounted() {
feather.replace({ width: "16", height: "16" })
feather.replace({ width: "16", height: "16" })
},
methods: {
minimize() {
const win = remote.getCurrentWindow();
win.minimize();
},
maximize() {
const win = remote.getCurrentWindow();
if(TMP.maximized === true) {
TMP.maximized = false;
win.unmaximize();
Expand All @@ -54,6 +63,7 @@
}
},
close() {
const win = remote.getCurrentWindow();
win.close();
},
},
Expand Down
25 changes: 25 additions & 0 deletions src/renderer/store/modules/settings.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,29 @@
const path = require('path');
const saveSettings = require('./settings/saveSettings');

export default {
state: {
alwaysOnTop: false,
windowTransparency: 100,
build: 0,
client: 0,
configPath: path.resolve(process.cwd(), 'settings.json'),
},
getters: {
getExistingSettings: (state, context, store) => {
return {
camera: {
collision: store.camera.collision,
spectateSpeed: store.camera.speed,
},
environment: {
timeOfDayEnabled: store.environment.isTimeOfDayEnabled,
},
settings: {
alwaysOnTop: state.alwaysOnTop,
},
};
},
},
mutations: {
setGameInfo(state, { build, client }) {
Expand All @@ -19,4 +38,10 @@ export default {
state.windowTransparency = value;
},
},
actions: {
saveSettings(context) {
const settings = JSON.stringify(context.getters.getExistingSettings);
saveSettings(context.state.configPath, settings);
},
},
};
5 changes: 5 additions & 0 deletions src/renderer/store/modules/settings/saveSettings.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
const fs = require('fs');

module.exports = (path, settings) => {
fs.writeFileSync(path, settings);
};

0 comments on commit 8a46421

Please sign in to comment.