mirror of
https://github.com/loot/libloot.git
synced 2026-07-27 14:16:01 -07:00
Settings, game types, languages get passed to UI.
Only most settings are not set in UI yet.
This commit is contained in:
@@ -777,10 +777,10 @@ function processURLParams() {
|
||||
|
||||
/* Fill in game row template's game type options. */
|
||||
var select = document.getElementById('gameRow').content.querySelector('select');
|
||||
for (var j = 0; j < data.gameTypes.length; ++j) {
|
||||
for (var j = 0; j < loot.gameTypes.length; ++j) {
|
||||
var option = document.createElement('option');
|
||||
option.value = data.gameTypes[j];
|
||||
option.textContent = data.gameTypes[j];
|
||||
option.value = loot.gameTypes[j];
|
||||
option.textContent = loot.gameTypes[j];
|
||||
select.appendChild(option);
|
||||
}
|
||||
|
||||
@@ -790,28 +790,28 @@ function processURLParams() {
|
||||
var gameTableBody = document.getElementById('gameTable').getElementsByTagName('tbody')[0];
|
||||
/* Add row for creating new rows. */
|
||||
setupTable(gameTableBody);
|
||||
for (var i = 0; i < data.games.length; ++i) {
|
||||
for (var i = 0; i < loot.settings.games.length; ++i) {
|
||||
var option = document.createElement('option');
|
||||
option.value = data.games[i].folder;
|
||||
option.textContent = data.games[i].name;
|
||||
option.value = loot.settings.games[i].folder;
|
||||
option.textContent = loot.settings.games[i].name;
|
||||
gameSelect.appendChild(option);
|
||||
|
||||
var li = document.createElement('li');
|
||||
li.setAttribute('data-action', 'change-game');
|
||||
li.setAttribute('data-target', data.games[i].folder);
|
||||
li.textContent = data.games[i].name;
|
||||
li.setAttribute('data-target', loot.settings.games[i].folder);
|
||||
li.textContent = loot.settings.games[i].name;
|
||||
gameMenu.appendChild(li);
|
||||
|
||||
addTableRow(gameTableBody, data.games[i]);
|
||||
addTableRow(gameTableBody, loot.settings.games[i]);
|
||||
}
|
||||
|
||||
/* Now fill in language options. */
|
||||
var settingsLangSelect = document.getElementById('languageSelect');
|
||||
var messageLangSelect = document.getElementById('messageRow').content.querySelector('.language');
|
||||
for (var i = 0; i < data.languages.length; ++i) {
|
||||
for (var i = 0; i < loot.languages.length; ++i) {
|
||||
var option = document.createElement('option');
|
||||
option.value = data.languages[i];
|
||||
option.textContent = data.languages[i];
|
||||
option.value = loot.languages[i];
|
||||
option.textContent = loot.languages[i];
|
||||
settingsLangSelect.appendChild(option);
|
||||
messageLangSelect.appendChild(option.cloneNode(true));
|
||||
}
|
||||
|
||||
@@ -955,62 +955,4 @@ var data = {
|
||||
"content": "Warning: The load order displayed in the Details tab was not applied as sorting was canceled."
|
||||
}
|
||||
],
|
||||
"games": [
|
||||
{
|
||||
"name": "TES IV: Oblivion",
|
||||
"type": "Oblivion",
|
||||
"folder": "Oblivion",
|
||||
"masterFile": "Oblivion.esm",
|
||||
"url": "https://github.com/loot/oblivion.git",
|
||||
"branch": "master",
|
||||
"path": "C:\\Oblivion",
|
||||
"registryKey": "Software\\Bethesda Softworks\\Oblivion\\Installed Path",
|
||||
},
|
||||
{
|
||||
"name": "TES V: Skyrim",
|
||||
"type": "Skyrim",
|
||||
"folder": "Skyrim",
|
||||
"masterFile": "Skyrim.esm",
|
||||
"url": "https://github.com/loot/skyrim.git",
|
||||
"branch": "master",
|
||||
"path": "C:\\Skyrim",
|
||||
"registryKey": "Software\\Bethesda Softworks\\Skyrim\\Installed Path",
|
||||
},
|
||||
{
|
||||
"name": "Fallout 3",
|
||||
"type": "Fallout3",
|
||||
"folder": "Fallout3",
|
||||
"masterFile": "Fallout3.esm",
|
||||
"url": "https://github.com/loot/fallout3.git",
|
||||
"branch": "master",
|
||||
"path": "C:\\Fallout3",
|
||||
"registryKey": "Software\\Bethesda Softworks\\Fallout3\\Installed Path",
|
||||
},
|
||||
{
|
||||
"name": "Fallout: New Vegas",
|
||||
"type": "FalloutNV",
|
||||
"folder": "FalloutNV",
|
||||
"masterFile": "FalloutNV.esm",
|
||||
"url": "https://github.com/loot/falloutnv.git",
|
||||
"branch": "master",
|
||||
"path": "C:\\FalloutNV",
|
||||
"registryKey": "Software\\Bethesda Softworks\\FalloutNV\\Installed Path",
|
||||
},
|
||||
],
|
||||
"gameTypes": [
|
||||
"Oblivion",
|
||||
"Skyrim",
|
||||
"Fallout3",
|
||||
"FalloutNV",
|
||||
],
|
||||
"languages": [
|
||||
"None Specified",
|
||||
"English",
|
||||
"Español",
|
||||
"Русский",
|
||||
"Français",
|
||||
"简体中文",
|
||||
"Polski",
|
||||
"Português do Brasil",
|
||||
],
|
||||
}
|
||||
+72
-7
@@ -25,15 +25,15 @@
|
||||
#include "app.h"
|
||||
#include "handler.h"
|
||||
|
||||
#include "../backend/globals.h"
|
||||
#include "../backend/helpers.h"
|
||||
|
||||
#include <include/cef_browser.h>
|
||||
#include <include/cef_task.h>
|
||||
#include <boost/log/trivial.hpp>
|
||||
|
||||
using namespace std;
|
||||
|
||||
namespace loot {
|
||||
|
||||
LootApp::LootApp() {}
|
||||
LootApp::LootApp(YAML::Node& settings) : _settings(settings) {}
|
||||
|
||||
CefRefPtr<CefBrowserProcessHandler> LootApp::GetBrowserProcessHandler() {
|
||||
return this;
|
||||
@@ -95,13 +95,78 @@ namespace loot {
|
||||
|
||||
// Here the initialisation values should be set.
|
||||
|
||||
// LOOT Version / Settings
|
||||
//------------------------
|
||||
|
||||
CefRefPtr<CefV8Value> lootObj = CefV8Value::CreateObject(NULL);
|
||||
|
||||
// LOOT Version
|
||||
//-------------
|
||||
|
||||
lootObj->SetValue("version", CefV8Value::CreateString(IntToString(g_version_major) + "." + IntToString(g_version_minor) + "." + IntToString(g_version_patch)), V8_PROPERTY_ATTRIBUTE_NONE);
|
||||
|
||||
// LOOT Settings
|
||||
//--------------
|
||||
|
||||
BOOST_LOG_TRIVIAL(debug) << "Setting GUI values for LOOT's settings.";
|
||||
|
||||
CefRefPtr<CefV8Value> settingsObj = CefV8Value::CreateObject(NULL);
|
||||
|
||||
if (_settings["Language"])
|
||||
settingsObj->SetValue("language", CefV8Value::CreateString(Language(_settings["Language"].as<string>()).Name()), V8_PROPERTY_ATTRIBUTE_NONE);
|
||||
|
||||
if (_settings["Update Masterlist"])
|
||||
settingsObj->SetValue("updateMasterlist", CefV8Value::CreateBool(_settings["Update Masterlist"].as<bool>()), V8_PROPERTY_ATTRIBUTE_NONE);
|
||||
|
||||
if (_settings["Debug Verbosity"])
|
||||
settingsObj->SetValue("debugVerbosity", CefV8Value::CreateInt(_settings["Debug Verbosity"].as<int>()), V8_PROPERTY_ATTRIBUTE_NONE);
|
||||
|
||||
if (_settings["Game"])
|
||||
settingsObj->SetValue("game", CefV8Value::CreateString(_settings["Game"].as<string>()), V8_PROPERTY_ATTRIBUTE_NONE);
|
||||
|
||||
vector<Game> games = GetGames(_settings);
|
||||
CefRefPtr<CefV8Value> gamesArr = CefV8Value::CreateArray(games.size());
|
||||
for (int i = 0; i < games.size(); ++i) {
|
||||
CefRefPtr<CefV8Value> gameObj = CefV8Value::CreateObject(NULL);
|
||||
|
||||
gameObj->SetValue("type", CefV8Value::CreateString(loot::Game(games[i].Id()).FolderName()), V8_PROPERTY_ATTRIBUTE_NONE);
|
||||
gameObj->SetValue("name", CefV8Value::CreateString(games[i].Name()), V8_PROPERTY_ATTRIBUTE_NONE);
|
||||
gameObj->SetValue("folder", CefV8Value::CreateString(games[i].FolderName()), V8_PROPERTY_ATTRIBUTE_NONE);
|
||||
gameObj->SetValue("masterFile", CefV8Value::CreateString(games[i].Master()), V8_PROPERTY_ATTRIBUTE_NONE);
|
||||
gameObj->SetValue("url", CefV8Value::CreateString(games[i].RepoURL()), V8_PROPERTY_ATTRIBUTE_NONE);
|
||||
gameObj->SetValue("branch", CefV8Value::CreateString(games[i].RepoBranch()), V8_PROPERTY_ATTRIBUTE_NONE);
|
||||
gameObj->SetValue("path", CefV8Value::CreateString(games[i].GamePath().string()), V8_PROPERTY_ATTRIBUTE_NONE);
|
||||
gameObj->SetValue("registryKey", CefV8Value::CreateString(games[i].RegistryKey()), V8_PROPERTY_ATTRIBUTE_NONE);
|
||||
|
||||
gamesArr->SetValue(i, gameObj);
|
||||
}
|
||||
settingsObj->SetValue("games", gamesArr, V8_PROPERTY_ATTRIBUTE_NONE);
|
||||
|
||||
lootObj->SetValue("settings", settingsObj, V8_PROPERTY_ATTRIBUTE_NONE);
|
||||
|
||||
// LOOT Game Types
|
||||
//----------------
|
||||
|
||||
BOOST_LOG_TRIVIAL(debug) << "Setting GUI values for LOOT's game types.";
|
||||
|
||||
CefRefPtr<CefV8Value> gameTypesArr = CefV8Value::CreateArray(4);
|
||||
gameTypesArr->SetValue(0, CefV8Value::CreateString(Game(Game::tes4).FolderName()));
|
||||
gameTypesArr->SetValue(1, CefV8Value::CreateString(Game(Game::tes5).FolderName()));
|
||||
gameTypesArr->SetValue(2, CefV8Value::CreateString(Game(Game::fo3).FolderName()));
|
||||
gameTypesArr->SetValue(3, CefV8Value::CreateString(Game(Game::fonv).FolderName()));
|
||||
|
||||
lootObj->SetValue("gameTypes", gameTypesArr, V8_PROPERTY_ATTRIBUTE_NONE);
|
||||
|
||||
// LOOT Languages
|
||||
//---------------
|
||||
|
||||
BOOST_LOG_TRIVIAL(debug) << "Setting GUI values for LOOT's languages.";
|
||||
|
||||
vector<string> langs = Language::Names();
|
||||
CefRefPtr<CefV8Value> langsArr = CefV8Value::CreateArray(langs.size());
|
||||
for (int i = 0; i < langs.size(); ++i) {
|
||||
langsArr->SetValue(i, CefV8Value::CreateString(langs[i]));
|
||||
}
|
||||
|
||||
lootObj->SetValue("languages", langsArr, V8_PROPERTY_ATTRIBUTE_NONE);
|
||||
|
||||
object->SetValue("loot", lootObj, V8_PROPERTY_ATTRIBUTE_NONE);
|
||||
}
|
||||
}
|
||||
+6
-1
@@ -25,6 +25,8 @@
|
||||
#ifndef __LOOT_GUI_APP__
|
||||
#define __LOOT_GUI_APP__
|
||||
|
||||
#include "../backend/game.h"
|
||||
|
||||
#include <include/cef_app.h>
|
||||
#include <include/wrapper/cef_message_router.h>
|
||||
|
||||
@@ -36,7 +38,7 @@ namespace loot {
|
||||
public CefBrowserProcessHandler,
|
||||
public CefRenderProcessHandler {
|
||||
public:
|
||||
LootApp();
|
||||
LootApp(YAML::Node& settings);
|
||||
|
||||
// Override CefApp methods.
|
||||
virtual CefRefPtr<CefBrowserProcessHandler> GetBrowserProcessHandler() OVERRIDE;
|
||||
@@ -57,6 +59,9 @@ namespace loot {
|
||||
CefRefPtr<CefFrame> frame,
|
||||
CefRefPtr<CefV8Context> context) OVERRIDE;
|
||||
|
||||
YAML::Node _settings;
|
||||
std::vector<loot::Game> _games;
|
||||
|
||||
IMPLEMENT_REFCOUNTING(LootApp);
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user