~saiko/game

8f9cd7f4d92a8458ff01b6add41aafff7badb2a6 — 2xsaiko 1 year, 14 days ago f8119d8
Cleanup
6 files changed, 33 insertions(+), 19 deletions(-)

M data/cfg/sys/init.cfg
M src/main.rs
M src/res/mod.rs
M src/testui.rs
M src/ui/mod.rs
M src/ui/panel.rs
M data/cfg/sys/init.cfg => data/cfg/sys/init.cfg +1 -1
@@ 1,4 1,4 @@
// Set sensible engine defaults.

exec fonts
exec sys/fonts
exec autoexec
\ No newline at end of file

M src/main.rs => src/main.rs +6 -4
@@ 6,6 6,7 @@
extern crate glium;

use std::cell::RefCell;
use std::convert::TryInto;
use std::fs::{create_dir_all, File};
use std::io::Read;
use std::ops::Sub;


@@ 41,12 42,12 @@ use crate::i18n::I18n;
use crate::kb::Keyboard;
use crate::math::*;
use crate::res::{DataSource, ResourceLoader};
use crate::res::merge::MergeModeTable;
use crate::shader::ShaderManager;
use crate::ui::graphics::{Alignment, Graphics, StringDrawProps};
use crate::ui::UiHost;
use crate::ui::host::UiHost;
use crate::util::{AnySurface, Color, LogPipe};
use crate::res::merge::MergeModeTable;
use std::convert::TryInto;
use crate::testui::TestUiController;

mod cam;
mod cmd;


@@ 205,8 206,9 @@ fn start_game(env: Rc<Environment>) {
  let fr = load_fonts(&env.rl, &display, &mut sm);

  let mut ui_host = UiHost::new();
  ui_host.resize(window.width(), window.height());

//  ui_host.open_ui(TestUi::new(camera.clone(), model.clone()));
  ui_host.open_ui(TestUiController::new());

  while running.load(Ordering::Relaxed) {
    let time_start = Instant::now();

M src/res/mod.rs => src/res/mod.rs +0 -1
@@ 5,7 5,6 @@ use std::marker::PhantomPinned;
use std::path::{Component, Path, PathBuf};
use std::pin::Pin;

use itertools::Itertools;
use zip::read::ZipFile;
use zip::result::ZipError;
use zip::ZipArchive;

M src/testui.rs => src/testui.rs +23 -10
@@ 1,33 1,43 @@
use crate::ui::panel::Container;
use crate::ui::element::Button;
use crate::ui::layout::{LayoutManager, BorderLayout};
use crate::ui::controller::UiController;
use crate::ui::element::Button;
use crate::ui::graphics::Graphics;
use crate::ui::layout::{BorderLayout, LayoutManager};
use crate::ui::panel::Container;
use crate::ui::rescap::ResizeCapabilities;

ui_def! {
  impl TestUi, TestUiElements, TestUiController, TestUiAccess {
    Button => button,
    Button1 => button1,
    Button2 => button2,
    Button3 => button3,
    Button4 => button4,
  }
}

struct TestUiElements {
pub struct TestUiElements {
  button: Container<Button>,
  button1: Container<Button>,
  button2: Container<Button>,
  button3: Container<Button>,
  button4: Container<Button>,
}

struct TestUiController;
pub struct TestUiController;

impl TestUiController {
  pub fn new() -> TestUi {
    TestUi::new(TestUiController)
  }

  fn get_layout(&self) -> impl LayoutManager<TestUiElements> {
    use TestUiAccess::*;
    BorderLayout::of(
      Button,
      Button,
      Button,
      Button,
      Button1,
      Button2,
      Button3,
      Button4,
    )
  }
}


@@ 37,8 47,11 @@ impl UiController for TestUiController {

  fn create_elements(&self) -> Self::Elements {
    TestUiElements {
      button: Button::new(""),
      button1: Button::new(""),
      button: Button::new("top"),
      button1: Button::new("bottom"),
      button2: Button::new("left"),
      button3: Button::new("right"),
      button4: Button::new("center"),
    }
  }


M src/ui/mod.rs => src/ui/mod.rs +2 -2
@@ 51,7 51,7 @@ macro_rules! _ui_def_inner {

    impl $crate::ui::access::Values for $acc_struct {
      fn values() -> &'static [Self] {
        &[$acc_struct::Button, $acc_struct::Button1]
        &[$($acc_struct::$variant,)*]
      }
    }



@@ 89,7 89,7 @@ pub struct GenUi<E: UiAccess, C: UiController> {
}

impl<E: UiAccess + 'static, C: UiController<Elements=E>> GenUi<E, C> {
  fn new(controller: C) -> Self {
  pub fn new(controller: C) -> Self {
    let elements = controller.create_elements();
    Self {
      elements,

M src/ui/panel.rs => src/ui/panel.rs +1 -1
@@ 79,7 79,7 @@ impl<T: Element> Element for Container<T> {
  }

  fn get_resize_capabilities(&self, g: &Graphics) -> ResizeCapabilities {
    unimplemented!()
    self.drawable.get_resize_capabilities(g)
  }
}