Skip to content

Commit

Permalink
Merge pull request #20 from yrenum/main
Browse files Browse the repository at this point in the history
Fixed main buttons position
  • Loading branch information
aintDatCap authored Jan 21, 2023
2 parents 6d5b41f + dccf6c8 commit 494001a
Show file tree
Hide file tree
Showing 3 changed files with 70 additions and 96 deletions.
10 changes: 4 additions & 6 deletions SOEdownload_manager/src/updater/github/releases_fetcher.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
use super::release::Releases;
use log::info;
use reqwest::header::USER_AGENT;
use reqwest::Client;

pub async fn fetch_releases(url: &str) -> Result<Releases, Box<dyn std::error::Error>> {
let user_agent = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/104.0.5112.79 Safari/537.36";

info!("Downloading latest release from {url}");
info!("User agent set to {user_agent}");

let client = Client::new();
let response = client
.get(url)
Expand All @@ -16,9 +20,3 @@ pub async fn fetch_releases(url: &str) -> Result<Releases, Box<dyn std::error::E

Ok(releases)
}

#[cfg(test)]
mod tests {
#[test]
fn test_fetcher() {}
}
3 changes: 3 additions & 0 deletions SOElauncher/src_web/css/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,9 @@ body {
.row {
display: flex;
flex-direction: row;
position:fixed;
bottom:0;
width:100%
}

footer {
Expand Down
153 changes: 63 additions & 90 deletions SOElauncher/src_web/js/index.js
Original file line number Diff line number Diff line change
@@ -1,42 +1,36 @@
const invoke = window.__TAURI__.invoke
const invoke = window.__TAURI__.invoke;

var response_container = document.getElementById("response")
var response_container = document.getElementById("response");
var settings = {
active_mods: [],
darkmode: true,
}
var darkmode = settings.darkmode;

};

invoke("get_launcher_settings").then((data) => {
settings = data;
darkmode = settings.darkmode;
settings_toggle_darkmode(null);

})


});

invoke("correct_pos").then((cor) => {
if (cor) {
setInterval(load_mods, 5000)
load_mods()
setInterval(load_mods, 5000);
load_mods();
} else {
popup("comp/fetcherr")
popup("comp/fetcherr");
}
})
});

function load_mods() {
invoke("fetch_modlist").then((modlist) => {
let htmllist = document.getElementById("modlist")
htmllist.innerHTML = " "
console.log(modlist)
console.log(modlist.length)
let htmllist = document.getElementById("modlist");
htmllist.innerHTML = " ";
console.log(modlist);
console.log(modlist.length);

for (let i = 0; i < modlist.length; i++) {
console.log("adding list")
const is_mod_on = settings.active_mods.includes(modlist[i])
const li = document.createElement("li")
console.log("adding list");
const is_mod_on = settings.active_mods.includes(modlist[i]);
const li = document.createElement("li");
li.innerHTML = `
<li>
<div class="modrow">
Expand All @@ -50,113 +44,92 @@ function load_mods() {
</button>
</div>
</li>
`
`;

htmllist.appendChild(li)
htmllist.appendChild(li);
}
console.log("done")
})
console.log("done");
});
}

var r = document.querySelector(':root');



function settings_toggle_darkmode(id) {
const r = document.querySelector(":root");



function settings_toggle_darkmode(id){


if (darkmode){
if (id != null){
document.getElementById(id).className = "popup_button red"
if (settings.darkmode) {
if (id != null) {
document.getElementById(id).className = "popup_button red";
}
r.style.setProperty('--background', 'white');
r.style.setProperty('--background_inverse', 'black');
r.style.setProperty('--mod_row', 'lightgray');



}else{
if (id != null){
document.getElementById(id).className = "popup_button green"
r.style.setProperty("--background", "white");
r.style.setProperty("--background_inverse", "black");
r.style.setProperty("--mod_row", "lightgray");
} else {
if (id != null) {
document.getElementById(id).className = "popup_button green";
}
r.style.setProperty('--background', '#272727');
r.style.setProperty('--background_inverse', 'darkgray');
r.style.setProperty('--mod_row', '#2e2e2e');



r.style.setProperty("--background", "#272727");
r.style.setProperty("--background_inverse", "darkgray");
r.style.setProperty("--mod_row", "#2e2e2e");
}


darkmode = !darkmode;


settings.darkmode = !darkmode;


settings.darkmode = !settings.darkmode;
}

function save_settings(){
function save_settings() {
console.log(settings);
invoke("save_launcher_settings", {settings: settings});
invoke("save_launcher_settings", { settings: settings });
}




function toggle_mod(buttonId) {
const button = document.getElementById(buttonId)
const mod_name = document.getElementById(buttonId + "sub").innerText
const button = document.getElementById(buttonId);
const mod_name = document.getElementById(buttonId + "sub").innerText;

const index = settings.active_mods.indexOf(mod_name)
const index = settings.active_mods.indexOf(mod_name);

if (index == -1) {
button.classList.replace("red", "green")
button.innerText = "On"
settings.active_mods.push(mod_name)
button.classList.replace("red", "green");
button.innerText = "On";
settings.active_mods.push(mod_name);
} else {
button.innerText = "Off"
button.classList.replace("green", "red")
settings.active_mods.splice(index, 1)
button.innerText = "Off";
button.classList.replace("green", "red");
settings.active_mods.splice(index, 1);
}

console.log("pt" + path)
console.log(settings.active_mods)
console.log("pt" + path);
console.log(settings.active_mods);
}



function close_popup() {
document.getElementById("portal").innerHTML = ""
document.getElementById("portal").innerHTML = "";
}

function load(component) {
return fetch(component + ".html").then((response) => response.text())
return fetch(component + ".html").then((response) => response.text());
}

function popup(strs) {
invoke("report_backend", { data: strs })
.then((response) => {
str = response
console.log("ok" + response)
load(str).then((text) => (document.getElementById("portal").innerHTML = text))
str = response;
console.log("ok" + response);
load(str).then((text) => (document.getElementById("portal").innerHTML = text));
})
.catch((error) => {
console.log("err" + error)
})
console.log("err" + error);
});
}

function open_web() {
invoke("open_web")
invoke("open_web");
}

function open_git() {
invoke("open_web_git")
invoke("open_web_git");
}

function start_game() {
invoke("start", { data: settings.active_mods })
invoke("start", { data: settings.active_mods });
}

window.__TAURI__.event.listen("tauri://window-created", function (event) {
response_container.innerText += "Got window-created event\n\n"
})
response_container.innerText += "Got window-created event\n\n";
});

0 comments on commit 494001a

Please sign in to comment.