diff --git a/.gitignore b/.gitignore index f1d8a7d..03fa777 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,5 @@ Cargo.lock +*/target /target .vscode/ -**/*.rs.bk -*.glade~ diff --git a/.nvimrc b/.nvimrc deleted file mode 100644 index 4776f11..0000000 --- a/.nvimrc +++ /dev/null @@ -1 +0,0 @@ -nnoremap :make run --bin client diff --git a/Cargo.toml b/Cargo.toml index 131a6df..1913db3 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,31 +1,6 @@ -[package] -name = "opensi" -version = "0.1.0" -authors = ["barsoosayque ", "snpefk "] -edition = "2018" - -[lib] -name = "core" -path = "src/core/lib.rs" - -[[bin]] -name = "editor" -path = "src/editor/main.rs" - -[[bin]] -name = "client" -path = "src/client/main.rs" - - -[dependencies] -serde = { version = "1.0", features = [ "derive" ] } -quick-xml = { version = "0.17", features = [ "serialize" ] } -zip = "0.5.4" - -gtk = "^0.8.0" -relm = "^0.19.0" -relm-derive = "^0.19.0" -gdk = "^0.12.0" -gdk-pixbuf = "^0.8.0" - -percent-encoding = "2.1.0" \ No newline at end of file +[workspace] +members = [ + "opensi", + "opensi-client", + "opensi-editor" +] diff --git a/README.md b/README.md index e6552d0..6cc5888 100644 --- a/README.md +++ b/README.md @@ -34,8 +34,8 @@ $ sudo yum install gtk3-devel glib2-devel ```shell # Клиент -$ cargo run --bin client +$ cargo run --bin opensi-client # Редактор -$ cargo run --bin editor +$ cargo run --bin opensi-editor ``` diff --git a/opensi-client/Cargo.toml b/opensi-client/Cargo.toml new file mode 100644 index 0000000..5dfd12e --- /dev/null +++ b/opensi-client/Cargo.toml @@ -0,0 +1,10 @@ +[package] +name = "opensi-client" +version = "0.1.0" +authors = ["barsoosayque "] +edition = "2018" + +[dependencies] +opensi = { version = "*", path = "../opensi" } + +druid = "0.6.0" diff --git a/opensi-client/src/main.rs b/opensi-client/src/main.rs new file mode 100644 index 0000000..b76857f --- /dev/null +++ b/opensi-client/src/main.rs @@ -0,0 +1,12 @@ +use druid::{AppLauncher, WindowDesc, Widget, PlatformError}; +use druid::widget::Label; + +fn build_ui() -> impl Widget<()> { + Label::new("Hello world") +} + +fn main() -> Result<(), PlatformError> { + AppLauncher::with_window(WindowDesc::new(build_ui)).launch(())?; + Ok(()) +} + diff --git a/opensi-editor/Cargo.toml b/opensi-editor/Cargo.toml new file mode 100644 index 0000000..50b060c --- /dev/null +++ b/opensi-editor/Cargo.toml @@ -0,0 +1,15 @@ +[package] +name = "opensi-editor" +version = "0.1.0" +authors = ["snpefk "] +edition = "2018" + +[dependencies] +opensi = { version = "*", path = "../opensi" } + +gtk = "^0.8.0" +relm = "^0.19.0" +relm-derive = "^0.19.0" +gdk = "^0.12.0" +gdk-pixbuf = "^0.8.0" +zip = "0.5.4" diff --git a/src/editor/editor.ui b/opensi-editor/src/editor.ui similarity index 100% rename from src/editor/editor.ui rename to opensi-editor/src/editor.ui diff --git a/src/editor/main.rs b/opensi-editor/src/main.rs similarity index 99% rename from src/editor/main.rs rename to opensi-editor/src/main.rs index b8fe6be..fa43d26 100644 --- a/src/editor/main.rs +++ b/opensi-editor/src/main.rs @@ -1,6 +1,3 @@ -#[path = "../core/lib.rs"] -mod opensi; - use gtk::prelude::*; use relm::{connect, Relm, Update, Widget}; use relm_derive::Msg; @@ -327,4 +324,4 @@ pub enum Chunk { fn main() { Win::run(()).expect("Window failed to run"); -} \ No newline at end of file +} diff --git a/opensi/Cargo.toml b/opensi/Cargo.toml new file mode 100644 index 0000000..bf8a87b --- /dev/null +++ b/opensi/Cargo.toml @@ -0,0 +1,11 @@ +[package] +name = "opensi" +version = "0.1.0" +authors = ["barsoosayque ", "snpefk "] +edition = "2018" + +[dependencies] +serde = { version = "1.0", features = [ "derive" ] } +quick-xml = { version = "0.17", features = [ "serialize" ] } +zip = "0.5.4" +percent-encoding = "2.1.0" diff --git a/src/core/lib.rs b/opensi/src/lib.rs similarity index 100% rename from src/core/lib.rs rename to opensi/src/lib.rs diff --git a/resource/client.css b/resource/client.css deleted file mode 100644 index af0e8f9..0000000 --- a/resource/client.css +++ /dev/null @@ -1,42 +0,0 @@ -.main_menu { - background-image: url('main-menu.png'); - background-size: cover; -} -.header { - background-color: rgba(0, 0, 0, 0.3); -} -.profile-select:hover { - transition: 100ms linear; - background-color: rgba(0, 0, 0, 0.5); -} -.profile-select { - transition: 100ms linear; - background-color: rgba(0, 0, 0, 0); -} -.profile-list { - background-color: rgba(0, 0, 0, 0.3); - border-style: none; - outline-style: none; - box-shadow: none; -} - -label.text { - color: #f5fffc; - font-size: 16px; - font-weight: 700; -} - -button.big { - color: #f5fffc; - font-size: 24px; - text-shadow: 1px 2px rgba(0, 0, 0, 0.5); - background-image: linear-gradient(#aee5d4 20%, #5db1ad 80%); - font-weight: 800; -} -button.big:hover { - background-image: linear-gradient(#d8f1dd 20%, #9cd5bf 80%); -} -button.big:active { - background-image: linear-gradient(#9acdc2 20%, #529e9e 80%); - color: #b2d1cd; -} diff --git a/resource/default-user.png b/resource/default-user.png deleted file mode 100644 index ca532e1..0000000 Binary files a/resource/default-user.png and /dev/null differ diff --git a/resource/main-menu.png b/resource/main-menu.png deleted file mode 100644 index 0cadde6..0000000 Binary files a/resource/main-menu.png and /dev/null differ diff --git a/src/client/main.glade b/src/client/main.glade deleted file mode 100644 index a66f7a0..0000000 --- a/src/client/main.glade +++ /dev/null @@ -1,225 +0,0 @@ - - - - - - False - - - - - - 800 - 600 - True - False - vertical - - - True - False - vertical - - - 250 - True - False - True - start - start - - - True - False - True - 10 - 10 - 10 - - - True - False - gtk-cancel - - - False - True - 0 - - - - - 50 - True - False - start - 10 - 10 - 10 - 10 - vertical - - - True - False - Текущий профиль: - - - - False - True - 0 - - - - - True - False - Новый профиль - - - - False - True - 1 - - - - - False - True - 1 - - - - - - - - False - True - 0 - - - - - - False - True - 0 - - - - - True - False - - - 300 - True - False - center - center - vertical - 20 - spread - - - Играть - 200 - True - True - True - center - - - - True - True - 0 - - - - - Настройки - 200 - True - True - True - center - - - - True - True - 1 - - - - - Выход - 200 - True - True - True - center - - - - True - True - 2 - - - - - - - 250 - True - False - start - none - - - True - False - - - - - - True - 1 - - - - - True - True - 2 - - - - - - - diff --git a/src/client/main.rs b/src/client/main.rs deleted file mode 100644 index 2c30f6b..0000000 --- a/src/client/main.rs +++ /dev/null @@ -1,99 +0,0 @@ -use gtk::prelude::*; -use gtk::{ButtonExt, CssProvider, Inhibit, StyleContext, WidgetExt, Window}; -use relm::{connect, Relm, Update, Widget}; -use relm_derive::Msg; - -#[derive(Msg)] -enum Msg { - Quit, -} - -struct Model { - // -} - -struct Win { - model: Model, - window: Window, -} - -impl Update for Win { - type Model = Model; type ModelParam = (); - type Msg = Msg; - - // Return the initial model. - fn model(_: &Relm, _: ()) -> Model { - Model {} - } - - // The model may be updated when a message is received. - // Widgets may also be updated in this function. - fn update(&mut self, event: Msg) { - match event { - Msg::Quit => gtk::main_quit(), - } - } } - -impl Widget for Win { - type Root = Window; - - fn root(&self) -> Self::Root { - self.window.clone() - } - - fn init_view(&mut self) { - let provider = CssProvider::new(); - provider - .load_from_path("resource/client.css") - .expect("Failed to load CSS"); - - StyleContext::add_provider_for_screen( - &self - .window - .get_screen() - .expect("Error initializing application style"), - &provider, - gtk::STYLE_PROVIDER_PRIORITY_APPLICATION, - ); - } - - fn view(relm: &Relm, model: Self::Model) -> Self { - let source = include_str!("main.glade"); - let builder = gtk::Builder::new_from_string(source); - let window: gtk::Window = builder.get_object("client").unwrap(); - - // Connect the signal `delete_event` to send the `Quit` message. - connect!( - relm, - window, - connect_delete_event(_, _), - return (Some(Msg::Quit), Inhibit(false)) - ); - - let profile_select: gtk::Widget = builder.get_object("profile_select").unwrap(); - profile_select.connect_enter_notify_event(|widget, _| { - widget.get_style_context().set_state(gtk::StateFlags::PRELIGHT); - Inhibit(false) - }); - profile_select.connect_leave_notify_event(|widget, _| { - widget.get_style_context().set_state(gtk::StateFlags::empty()); - Inhibit(false) - }); - let profile_list_revealer: gtk::Revealer = builder.get_object("profile_list_revealer").unwrap(); - profile_select.connect_button_press_event(move |_, _| { - profile_list_revealer.set_reveal_child(!profile_list_revealer.get_reveal_child()); - Inhibit(false) - }); - - let button_exit: gtk::Button = builder.get_object("button_exit").unwrap(); - connect!(relm, button_exit, connect_clicked(_), Msg::Quit); - - window.show_all(); - - Win { model, window } - } -} - -fn main() { - Win::run(()).unwrap(); -}