Stability changes
This commit is contained in:
parent
2a12f70c91
commit
140700251d
@ -17,6 +17,8 @@ router.post('/create', (req, res) => {
|
||||
name,
|
||||
system
|
||||
} = req.body;
|
||||
console.log(name)
|
||||
console.log(system)
|
||||
|
||||
if(!(name && system)){
|
||||
res.json({
|
||||
|
@ -151,7 +151,7 @@ class BackendModule {
|
||||
// scope => ['campaign']
|
||||
// coses que es necessiten verificar a tots els models
|
||||
// i s'agafa de req.query
|
||||
createModelRoutes(model, scope = []){
|
||||
createModelRoutes(model, scope = ['campaign']){
|
||||
this.router.get(`/${model.name}/list`, (req, res) => {
|
||||
let query = {}
|
||||
scope.forEach(k => query[k] = req.query[k]);
|
||||
@ -183,7 +183,7 @@ class BackendModule {
|
||||
scope.forEach(k => query[k] = req.query[k]);
|
||||
query['_id'] = req.query.id;
|
||||
model.findOneAndUpdate(query, req.body.data).then(data => {
|
||||
if(req.query.fireUpdate) this.socket.emit(query['campaign'], `update-${model.name}-all`);
|
||||
this.socket.emit(query['campaign'], `update-${model.name}-all`);
|
||||
this.socket.emit(query['campaign'], `update-${model.name}`, req.query.id);
|
||||
res.json({status: 'ok'});
|
||||
})
|
||||
@ -194,7 +194,7 @@ class BackendModule {
|
||||
scope.forEach(k => query[k] = req.query[k]);
|
||||
query['_id'] = req.query.id;
|
||||
model.deleteOne(query).then(data => {
|
||||
if(req.query.fireUpdate) this.socket.emit(query['campaign'], `update-${model.name}-all`);
|
||||
this.socket.emit(query['campaign'], `update-${model.name}-all`);
|
||||
this.socket.emit(query['campaign'], `update-${model.name}`, req.query.id);
|
||||
res.json({status: 'ok'});
|
||||
});
|
||||
|
@ -2,12 +2,12 @@ import './assets/main.css'
|
||||
import './assets/prism.css'
|
||||
|
||||
import { createApp, defineComponent, reactive } from 'vue'
|
||||
import { createI18n } from 'vue-i18n'
|
||||
import i18n from '@/services/i18n'
|
||||
|
||||
import App from './App.vue'
|
||||
import router from './router'
|
||||
|
||||
import mitt from 'mitt';
|
||||
import { GetUser, GetUserSetting, LogoutUser } from './services/User'
|
||||
const emitter = mitt();
|
||||
|
||||
const app = createApp(App);
|
||||
@ -24,31 +24,6 @@ app.config.globalProperties.rollWindows = {
|
||||
console.clear();
|
||||
console.log("%cLoaded!!!", "color: #22ff22; font-size: 24px");
|
||||
|
||||
// Determinem el locale
|
||||
let locale = 'en-US';
|
||||
|
||||
let supportedLocales = ['en-US', 'es-ES', 'ca'];
|
||||
let navLocale = window.navigator.language;
|
||||
|
||||
if(supportedLocales.includes(navLocale)) locale = navLocale;
|
||||
|
||||
try {
|
||||
if(GetUser()) locale = await GetUserSetting('lang');
|
||||
} catch(ex) {
|
||||
LogoutUser();
|
||||
}
|
||||
|
||||
const i18n = createI18n({
|
||||
legacy: false,
|
||||
locale,
|
||||
fallbackLocale: 'en-US',
|
||||
messages: {
|
||||
'en-US': (await import(`./locales/en-US.json`)).default,
|
||||
'es-ES': (await import(`./locales/es-ES.json`)).default,
|
||||
'ca': (await import(`./locales/ca.json`)).default,
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
app.use(router)
|
||||
app.use(i18n);
|
||||
|
@ -8,8 +8,9 @@ import * as _Tooltip from "@/services/Tooltip"
|
||||
import * as _Windows from "@/services/Windows"
|
||||
import Server from '@/services/Server';
|
||||
import { socket } from '@/services/Socket';
|
||||
const { t } = useI18n()
|
||||
import i18n from '@/services/i18n'
|
||||
|
||||
const { t } = i18n.global
|
||||
/**
|
||||
* Class for managing the client api
|
||||
* @hideconstructor
|
||||
@ -175,7 +176,8 @@ class ClientModule {
|
||||
this.#_previewData = data;
|
||||
}
|
||||
|
||||
set onInit(init){ this.#_init = (campaign) => {
|
||||
set onInit(init){
|
||||
this.#_init = (campaign) => {
|
||||
this.#_campaign = campaign;
|
||||
this.#_router._setParam("campaign", campaign._id);
|
||||
init();
|
||||
|
@ -12,7 +12,7 @@ function LaunchGame(){
|
||||
|
||||
function ExitGame(){
|
||||
inGameRef.value = false;
|
||||
GetCampaignModule().exit();
|
||||
if(GetCampaignModule().exit) GetCampaignModule().exit();
|
||||
}
|
||||
|
||||
export {
|
||||
|
30
client/src/services/i18n.js
Normal file
30
client/src/services/i18n.js
Normal file
@ -0,0 +1,30 @@
|
||||
import { createI18n } from 'vue-i18n'
|
||||
|
||||
import { GetUser, GetUserSetting, LogoutUser } from '@/services/User'
|
||||
|
||||
// Determinem el locale
|
||||
let locale = 'en-US';
|
||||
|
||||
let supportedLocales = ['en-US', 'es-ES', 'ca'];
|
||||
let navLocale = window.navigator.language;
|
||||
|
||||
if(supportedLocales.includes(navLocale)) locale = navLocale;
|
||||
|
||||
try {
|
||||
if(GetUser()) locale = await GetUserSetting('lang');
|
||||
} catch(ex) {
|
||||
LogoutUser();
|
||||
}
|
||||
|
||||
const i18n = createI18n({
|
||||
legacy: false,
|
||||
locale,
|
||||
fallbackLocale: 'en-US',
|
||||
messages: {
|
||||
'en-US': (await import(`../locales/en-US.json`)).default,
|
||||
'es-ES': (await import(`../locales/es-ES.json`)).default,
|
||||
'ca': (await import(`../locales/ca.json`)).default,
|
||||
}
|
||||
});
|
||||
|
||||
export default i18n;
|
@ -14,9 +14,10 @@ let windowId = props.windowId;
|
||||
function DisplaySystemSelector(){
|
||||
CreateChildWindow(windowId, 'system_selector', {'done': (data) => {
|
||||
let module = GetModule(data.selected);
|
||||
console.log(module);
|
||||
selectedSystem.value = data.selected;
|
||||
selectedImage.value.src = `modules/${module.id}/icon.png`;
|
||||
systemTitle.value = module.title;
|
||||
selectedImage.value.src = `plugins/${module.id}/icon.png`;
|
||||
systemTitle.value = module.previewData.title;
|
||||
ClearWindow('system-selector');
|
||||
}});
|
||||
}
|
||||
|
@ -26,23 +26,13 @@ onMounted(() => {
|
||||
SetupHandle(id, handle);
|
||||
SetSize(id, {width: 350, height: 240});
|
||||
ResetPosition(id, "center");
|
||||
GetEmitter().on('select', (system_id) => Select(system_id))
|
||||
|
||||
console.log(system);
|
||||
});
|
||||
|
||||
function Select(system_id){
|
||||
system = system_id;
|
||||
try {
|
||||
systemSelector.value.selectedSystem = system_id;
|
||||
} catch {}
|
||||
}
|
||||
|
||||
|
||||
function NewCampaign(){
|
||||
Server().post('/campaign/create', {
|
||||
name: campaignName.value,
|
||||
system
|
||||
system: systemSelector.value.selectedSystem
|
||||
}).then((response) => {
|
||||
if(response.data.status == "error"){
|
||||
errorMessage.value = response.data.msg;
|
||||
|
@ -10,10 +10,14 @@ function Main(api){
|
||||
|
||||
let itemModel = Api.createModel("item", {
|
||||
name: { type: "String", required: true, default: "New item"},
|
||||
description: { type: "String", default: "New description" },
|
||||
type: { type: "String", required: true, default: "Item" },
|
||||
info: { type: "Object" }, // For preview only
|
||||
data: { type: "Object" }, // Advanced item
|
||||
book: { type: "ObjectId", ref: "Book"}
|
||||
icon: { type: "String" },
|
||||
rarity: { type: "String", default: "" },
|
||||
quantity: { type: "Number", default: "1" },
|
||||
weight: { type: "Number", default: "0" },
|
||||
price: { type: "Number", default: "0" },
|
||||
data: { type: "Object" }, // Advanced properties depending on item type
|
||||
});
|
||||
|
||||
let entityDataModel = Api.createModel('entitydata', {
|
||||
|
@ -58,7 +58,7 @@ function Main(Api){
|
||||
});
|
||||
|
||||
|
||||
dndModule.socket.on('update-concepts', () => {
|
||||
dndModule.socket.on('update-item-all', () => {
|
||||
FetchConcepts();
|
||||
});
|
||||
|
||||
|
@ -75,18 +75,18 @@ function ElementContext(element){
|
||||
}
|
||||
|
||||
function ElementTooltip(element){
|
||||
let descHtml = GetKey(element, 'info.description');
|
||||
let descHtml = GetKey(element, 'description');
|
||||
if(descHtml) descHtml = marked.parse(descHtml);
|
||||
else descHtml = '';
|
||||
return `<div class='document item'>
|
||||
<h2>${element.name}</h2>
|
||||
<img src='${GetKey(element, "info.icon")}'></img>
|
||||
<img src='${GetKey(element, "icon")}'></img>
|
||||
<div class='document'>${descHtml}</div>
|
||||
</div>`;
|
||||
}
|
||||
|
||||
function ElementIcon(element){
|
||||
return GetKey(element, "info.icon") ? GetKey(element, "info.icon") : 'icons/game-icons/ffffff/lorc/crossed-swords.svg'
|
||||
return GetKey(element, "icon") ? GetKey(element, "icon") : 'icons/game-icons/ffffff/lorc/crossed-swords.svg'
|
||||
}
|
||||
</script>
|
||||
|
||||
|
@ -75,18 +75,13 @@ let oldInfo;
|
||||
|
||||
function Upload(){
|
||||
let params = {id: concept.value._id};
|
||||
if(oldInfo != concept.value.info){
|
||||
params['fireUpdate'] = true;
|
||||
oldInfo = structuredClone(concept.value.info);
|
||||
}
|
||||
|
||||
dndModule.router.put('/item/update', params, {data: concept.value}).then(response => {
|
||||
// console.log(response);
|
||||
});
|
||||
}
|
||||
|
||||
function SetParam(param, value){
|
||||
SetKey(concept.value, `info.${param}`, value);
|
||||
SetKey(concept.value, `${param}`, value);
|
||||
Upload();
|
||||
}
|
||||
|
||||
@ -106,14 +101,14 @@ function InitValues(){
|
||||
let rarities = GenRarities();
|
||||
let weapon_types = GenTypes(["", "Melee", "Ranged", "Martial Melee", "Martial Ranged", "Natural", "Improvised", "Siege Weapon"]);
|
||||
|
||||
icon_selector.value.icon = GetKey(concept.value, "info.icon");
|
||||
rarity.value.innerHTML = `<span class='important ${GetKey(concept.value, "info.rarity") ? GetKey(concept.value, "info.rarity").replace(/\s+/g, '-').toLowerCase() : ""}'>${GetKey(concept.value, "info.rarity")}</span>`;
|
||||
icon_selector.value.icon = GetKey(concept.value, "icon");
|
||||
rarity.value.innerHTML = `<span class='important ${GetKey(concept.value, "rarity") ? GetKey(concept.value, "rarity").replace(/\s+/g, '-').toLowerCase() : ""}'>${GetKey(concept.value, "rarity")}</span>`;
|
||||
weaponType.value.innerHTML = `<span class='important'>${GetKey(concept.value, "info.weapon_type")}</span>`;
|
||||
description.value.text = GetKey(concept.value, "info.description");
|
||||
description.value.text = GetKey(concept.value, "description");
|
||||
properties.value.selected = GetKey(concept.value, "info.properties");
|
||||
quantity.value.Set(GetKey(concept.value, "info.quantity"));
|
||||
weight.value.Set(GetKey(concept.value, "info.weight"));
|
||||
price.value.Set(GetKey(concept.value, "info.price"));
|
||||
quantity.value.Set(GetKey(concept.value, "quantity"));
|
||||
weight.value.Set(GetKey(concept.value, "weight"));
|
||||
price.value.Set(GetKey(concept.value, "price"));
|
||||
item_type_name.value = GetKey(concept.value, "type");
|
||||
item_name.value.innerHTML = GetKey(concept.value, "name");
|
||||
|
||||
|
@ -2,15 +2,15 @@
|
||||
"id": "weapon/test_weapon",
|
||||
"value": {
|
||||
"name": "Test datagen weapon",
|
||||
"description": "Test test test",
|
||||
"icon": "icons/weapons/ammunition/shot-round-blue.webp",
|
||||
"type": "Weapon",
|
||||
"data": {},
|
||||
"info": {
|
||||
"icon": "icons/weapons/ammunition/shot-round-blue.webp",
|
||||
"rarity": "Rare",
|
||||
"quantity": "1",
|
||||
"weight": "10",
|
||||
"price": "10",
|
||||
"data": {
|
||||
"weapon_type": "Natural",
|
||||
"rarity": "Rare",
|
||||
"quantity": "1",
|
||||
"weight": "10",
|
||||
"price": "10",
|
||||
"properties": [
|
||||
"Finesse"
|
||||
]
|
||||
|
@ -2,5 +2,6 @@
|
||||
"package": "dnd-5e",
|
||||
"id": "dnd-5e-base",
|
||||
"name": "info.name",
|
||||
"desc": "info.description"
|
||||
"desc": "info.description",
|
||||
"dependencies": []
|
||||
}
|
@ -22,5 +22,6 @@
|
||||
"desc": "module.desc",
|
||||
"icon": "icon.png"
|
||||
}
|
||||
]
|
||||
],
|
||||
"dependencies": []
|
||||
}
|
Loading…
Reference in New Issue
Block a user