Fix bugs with location mod integration.
- Connect button behavior incorrect. - Wrong value saved for host IP. - Cars stayed when disconnecting.
This commit is contained in:
1 parent
cfa388c299
commit
7ebf2556ba
2 files changed
+9
-3
No files matched your search
@@ -694,6 +694,7 @@ export function connectPlayerLocation(address, status){
|
|||||||
let started = false;
|
let started = false;
|
||||||
const endConnect = () => {
|
const endConnect = () => {
|
||||||
locationData = null;
|
locationData = null;
|
||||||
|
dynamicMarkers = [];
|
||||||
status.value = 'Connect';
|
status.value = 'Connect';
|
||||||
playerMarker.hidden = true;
|
playerMarker.hidden = true;
|
||||||
view.dynDirty = true;
|
view.dynDirty = true;
|
||||||
|
|||||||
@@ -196,9 +196,12 @@ let settingEntries = [
|
|||||||
label: 'Location Host',
|
label: 'Location Host',
|
||||||
id: 'field_locationHost',
|
id: 'field_locationHost',
|
||||||
state: 'localhost:9090',
|
state: 'localhost:9090',
|
||||||
|
placeholder: 'localhost:9090',
|
||||||
saveState: true,
|
saveState: true,
|
||||||
button: 'Wait',
|
button: 'Connect',
|
||||||
func: state =>{
|
func: state =>{
|
||||||
|
if(state == '') state = 'localhost:9090';
|
||||||
|
document.getElementById('field_locationHost').value = state;
|
||||||
let button = document.getElementById('field_locationHost').nextSibling;
|
let button = document.getElementById('field_locationHost').nextSibling;
|
||||||
if(button.value.startsWith('Connect')){
|
if(button.value.startsWith('Connect')){
|
||||||
MapData.connectPlayerLocation(state, button);
|
MapData.connectPlayerLocation(state, button);
|
||||||
@@ -368,6 +371,7 @@ function addSettingEntry(thisSetting, parent, indent=0){
|
|||||||
thisSetting.inputElement = document.createElement('input');
|
thisSetting.inputElement = document.createElement('input');
|
||||||
thisSetting.inputElement.type = 'text';
|
thisSetting.inputElement.type = 'text';
|
||||||
thisSetting.inputElement.value = thisSetting.state;
|
thisSetting.inputElement.value = thisSetting.state;
|
||||||
|
if(thisSetting.placeholder) thisSetting.inputElement.placeholder = thisSetting.placeholder;
|
||||||
if(thisSetting.button){
|
if(thisSetting.button){
|
||||||
thisSetting.buttonElement = document.createElement('input');
|
thisSetting.buttonElement = document.createElement('input');
|
||||||
thisSetting.buttonElement.type = 'button';
|
thisSetting.buttonElement.type = 'button';
|
||||||
@@ -375,7 +379,7 @@ function addSettingEntry(thisSetting, parent, indent=0){
|
|||||||
if(thisSetting.func){
|
if(thisSetting.func){
|
||||||
thisSetting.buttonElement.addEventListener('click', e => {
|
thisSetting.buttonElement.addEventListener('click', e => {
|
||||||
thisSetting.func(thisSetting.inputElement.value);
|
thisSetting.func(thisSetting.inputElement.value);
|
||||||
if(thisSetting.saveState) saveSetting(thisSetting.id, e.target.value);
|
if(thisSetting.saveState) saveSetting(thisSetting.id, thisSetting.inputElement.value);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -458,7 +462,7 @@ function resetSettingEntry(entry){
|
|||||||
}
|
}
|
||||||
|
|
||||||
function saveSetting(name, value){
|
function saveSetting(name, value){
|
||||||
//console.log(`saving 'setting_${name}=${encodeURIComponent(value)};'`);
|
//console.trace(`saving 'setting_${name}=${encodeURIComponent(value)};'`);
|
||||||
if(value == null){
|
if(value == null){
|
||||||
resetSetting(name);
|
resetSetting(name);
|
||||||
}else{
|
}else{
|
||||||
@@ -472,6 +476,7 @@ function loadSetting(name, defaultValue){
|
|||||||
if(cookie.startsWith('setting_'+name+'=')){
|
if(cookie.startsWith('setting_'+name+'=')){
|
||||||
let result = cookie.split('=');
|
let result = cookie.split('=');
|
||||||
//console.log(`Loading setting_${name}=${decodeURIComponent(result[1])}`);
|
//console.log(`Loading setting_${name}=${decodeURIComponent(result[1])}`);
|
||||||
|
if(result[1] == '') return defaultValue;
|
||||||
return autocast(decodeURIComponent(result[1]));
|
return autocast(decodeURIComponent(result[1]));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user