chore: Add language dropdown for localization

- Added a new language dropdown component for localization
- Improved spacing and styling across multiple components
- Removed unused code and commented out debug lines
- Updated dependencies for flag icons and solid-js library.
This commit is contained in:
Walid 2023-05-04 16:16:15 +01:00
parent 2b9a2720bc
commit cbebfa86e7
Signed by: Walidoux
GPG Key ID: CCF21881FE8BEBAF
11 changed files with 114 additions and 36 deletions

View File

@ -1,3 +1,5 @@
use std::path::PathBuf;
use quickxml_to_serde::{xml_string_to_json, Config, NullValue};
use specta::specta;
@ -22,25 +24,27 @@ pub fn download_gamedata(data: &str, endpoint: GamedataEndpoints) {
}
}
/* #[specta]
#[specta]
#[tauri::command]
pub fn parse_data(
path: String,
file_name: String,
file_content: String,
path: &str,
file_name: &str,
file_content: &str,
) -> Result<(), Box<dyn std::error::Error>> {
let file_dir = PathBuf::from(&path).join(format!("{}.json", file_name));
println!("{:?}", file_dir);
// By default, output files will be overwritten. I cannot recursively remove the entire output folder
// and create it again because it just won't parse files' contents for some reason
if !exists(&Convertion::gamedata_dir()) {
/* if !exists(&Convertion::gamedata_dir()) {
create_dir_all(&Convertion::gamedata_dir())?;
}
write_file(&file_dir, file_content.as_bytes());
write_file(&file_dir, file_content.as_bytes()); */
Ok(())
} */
}
/* pub async fn convert_txt(path: &str, data: &str) -> Result<(), Box<dyn std::error::Error>> {
let mut badges: Vec<Badge> = Vec::new();

View File

@ -12,13 +12,14 @@ fn main() {
ts::export(collect_types![download_gamedata], "../src/tools/rusty.ts").unwrap();
// This is useful for custom eslint, prettier overrides at the top of the file.
// ts::export_with_cfg_with_header(
// collect_types![download_gamedata].unwrap(),
// Default::default(),
// "../src/tools/rusty.ts",
// "/* eslint-disable */\n".into(),
// )
// .unwrap();
/* ts::export_with_cfg_with_header(
collect_types![download_gamedata].unwrap(),
Default::default(),
"../src/tools/rusty.ts",
"/* eslint-disable */
\n".into(),
)
.unwrap(); */
tauri::Builder::default()
.invoke_handler(tauri::generate_handler![download_gamedata])

View File

@ -29,11 +29,42 @@ pub struct GamedataEndpoints {
pub file_name: Converters,
}
pub struct FigureData {
#[derive(Serialize, Deserialize, Type, Debug)]
pub struct FurniData {
pub floor_items: Vec<IFloorItem>,
pub wall_items: Vec<IFurni>,
}
pub struct IFloorItem {}
#[derive(Serialize, Deserialize, Type, Debug)]
pub struct IFloorItem {
dimensions: IFloorItemDimensions,
permissions: IFloorItemPermissions,
}
pub struct IFurni {}
#[derive(Serialize, Deserialize, Type, Debug)]
pub struct IFloorItemDimensions {
x: i32,
y: i32,
default_direction: i32,
}
#[derive(Serialize, Deserialize, Type, Debug)]
pub struct IFloorItemPermissions {
can_sit_on: bool,
can_lay_on: bool,
can_stand_on: bool,
}
#[derive(Serialize, Deserialize, Type, Debug)]
pub struct IFurni {
id: i32,
classname: String,
description: Option<String>,
name: Option<String>,
furni_line: Option<String>,
custom_params: Option<String>,
adurl: Option<String>,
offer_id: Option<i32>,
exclude_dynamic: bool,
special_type: i32,
}

View File

@ -1,6 +1,6 @@
use serde_json::Value;
use crate::structs::Converters;
use crate::structs::{Converters, FurniData, IFloorItem, IFurni};
pub fn debug_typeof<T>(_: &T) {
println!("{}", std::any::type_name::<T>())
@ -9,17 +9,46 @@ pub fn debug_typeof<T>(_: &T) {
pub fn convert_json(data: &str, file_name: Converters) {
let object: Value = serde_json::from_str(data).unwrap();
println!("{}", object);
match file_name {
/* Converters::FurniData => {
for (key, value) in object["wallitemtypes"]["furnitype"].as_object().unwrap() {
println!("{} {}", key, value);
Converters::FurniData => {
let mut data = FurniData {
floor_items: Vec::new(),
wall_items: Vec::new(),
};
let floor_items_result: Result<_, Vec<IFloorItem>> =
Ok(serde_json::from_value::<Vec<IFloorItem>>(
object["wallitemtypes"]["furnitype"].clone(),
));
let wall_items_result: Result<_, Vec<IFurni>> = Ok(
serde_json::from_value::<Vec<IFurni>>(object["roomitemtypes"]["furnitype"].clone()),
);
// Handle the floor_items_result and wall_items_result appropriately
match (floor_items_result, wall_items_result) {
(Ok(floor_items), Ok(wall_items)) => {
while let Ok(ref value) = wall_items {
println!("{:?}", value);
}
while let Ok(ref value) = floor_items {
println!("{:?}", value);
}
}
(Err(e), _) => {
println!("Error deserializing floor items: {:?}", e);
}
(_, Err(e)) => {
println!("Error deserializing wall items: {:?}", e);
}
}
} */
Converters::FigureData => unimplemented!(),
Converters::FigureMap => todo!(),
Converters::EffectMap => todo!(),
Converters::FurniData => todo!(),
// loop through each key value pairs (make sure your handle null exceptions)
// parse the data to the global variable above
//
}
Converters::FigureData => {}
Converters::FigureMap => {}
Converters::EffectMap => {}
}
}

View File

@ -1,14 +1,16 @@
import type { Component } from 'solid-js'
import { Downloaders, TitleBar } from './components/layout'
import { Downloaders, TitleBar, LangDropdown } from './components/layout'
const Main: Component = () => {
return (
<>
<TitleBar />
<main class='relative flex h-full w-screen flex-col items-center justify-center bg-[#242424] py-20'>
<span class='mb-20 text-white'>I would like to:</span>
<main class='relative flex h-full w-screen flex-col items-center justify-center bg-[#242424] py-20 text-white'>
<span class='mb-20'>I would like to:</span>
<LangDropdown />
<Downloaders />
</main>

View File

@ -50,10 +50,17 @@ export const Downloaders: Component = () => {
<Loader active={loading()} class='mt-10' />
<Button
value='Abort'
icon={<Image src='/icons/cross.png' />}
class='mt-6 bg-red-600 p-2 px-4 active:opacity-40'
handler={() => {}}
/>
<Button
value='Close'
icon={<Image src='/icons/cross.png' />}
class={classNames('invisible mt-6 bg-red-600 p-2 px-4 text-white opacity-0 active:opacity-40', {
class={classNames('invisible mt-6 bg-red-600 p-2 px-4 opacity-0 active:opacity-40', {
'!visible !opacity-100': !loading()
})}
handler={() => {

View File

@ -12,7 +12,7 @@ export const Popup: Component<PopupProps> = (props) => {
return (
<AnimateView
animation={Animation.fadeInOut()}
class='absolute left-0 top-0 z-20 flex h-screen w-screen flex-col items-center justify-center bg-black/40 text-white'
class='absolute left-0 top-0 z-20 flex h-screen w-screen flex-col items-center justify-center bg-black/40'
condition={props.condition}>
{props.children}
</AnimateView>

View File

@ -1,3 +1,5 @@
export * from './Downloaders'
export * from './Popup'
export * from './TitleBar'
export * from './LangDropdown'
export * from './OutSideEventHandler'

View File

@ -1,10 +1,10 @@
import type { IEffectMap, IXML } from '../types'
import type { IEffectMap } from '../types'
export class EffectMap {
public data: IEffectMap = {}
public fileName: string
constructor(XML: IXML, fileName: string) {
constructor(XML: any, fileName: string) {
this.fileName = fileName
this.parseLibrairies(XML.map.effect)

View File

@ -2,6 +2,8 @@ import { render } from 'solid-js/web'
import './styles/fonts.css'
import './styles/styles.css'
import 'flag-icons/css/flag-icons.min.css'
import App from './App'
render(() => {

View File

@ -16,6 +16,6 @@
@layer components {
.download-button {
@apply retro-text-shadow center-x-axis center-x-axis -bottom-4 z-10 h-12 w-10/12 border-2 text-xs text-white shadow-2xl transition-all hover:-translate-x-1/2 hover:scale-105 hover:duration-200 active:-translate-x-1/2 active:scale-95 active:opacity-80 active:shadow-none active:duration-75;
@apply retro-text-shadow center-x-axis center-x-axis -bottom-4 z-10 h-12 w-10/12 border-2 text-xs shadow-2xl transition-all hover:-translate-x-1/2 hover:scale-105 hover:duration-200 active:-translate-x-1/2 active:scale-95 active:opacity-80 active:shadow-none active:duration-75;
}
}