Minor cleanup
parent
fc728eaf0e
commit
975d2e6590
|
@ -5,10 +5,10 @@ use cgmath::Deg;
|
|||
|
||||
use crate::{handle::TextureHandle, Content};
|
||||
|
||||
use super::OutfitSpace;
|
||||
use crate::OutfitSpace;
|
||||
|
||||
pub(crate) mod syntax {
|
||||
use super::super::shared;
|
||||
use crate::part::shared;
|
||||
use serde::Deserialize;
|
||||
// Raw serde syntax structs.
|
||||
// These are never seen by code outside this crate.
|
||||
|
|
|
@ -2,12 +2,10 @@ use std::collections::HashMap;
|
|||
|
||||
use anyhow::{bail, Result};
|
||||
|
||||
use crate::{handle::TextureHandle, Content};
|
||||
|
||||
use super::OutfitSpace;
|
||||
use crate::{handle::TextureHandle, Content, OutfitSpace};
|
||||
|
||||
pub(crate) mod syntax {
|
||||
use super::super::shared;
|
||||
use crate::part::shared;
|
||||
use serde::Deserialize;
|
||||
// Raw serde syntax structs.
|
||||
// These are never seen by code outside this crate.
|
||||
|
|
|
@ -4,12 +4,10 @@ use anyhow::{bail, Result};
|
|||
use cgmath::Point2;
|
||||
use nalgebra::{point, Point};
|
||||
|
||||
use crate::{handle::TextureHandle, Content};
|
||||
|
||||
use super::OutfitSpace;
|
||||
use crate::{handle::TextureHandle, Content, OutfitSpace};
|
||||
|
||||
pub(crate) mod syntax {
|
||||
use super::super::shared;
|
||||
use crate::part::shared;
|
||||
use serde::Deserialize;
|
||||
|
||||
// Raw serde syntax structs.
|
||||
|
|
|
@ -5,8 +5,8 @@ use std::collections::{HashMap, HashSet};
|
|||
use crate::{handle::TextureHandle, util::Polar, Content};
|
||||
|
||||
pub(crate) mod syntax {
|
||||
use super::HashMap;
|
||||
use serde::Deserialize;
|
||||
use std::collections::HashMap;
|
||||
// Raw serde syntax structs.
|
||||
// These are never seen by code outside this crate.
|
||||
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
use anyhow::Result;
|
||||
use bytemuck;
|
||||
use cgmath::{Deg, EuclideanSpace, Matrix4, Point2, Vector2, Vector3};
|
||||
use galactica_content::Content;
|
||||
use std::{iter, rc::Rc};
|
||||
use wgpu;
|
||||
use winit::{
|
||||
|
@ -10,9 +9,9 @@ use winit::{
|
|||
window::Window,
|
||||
};
|
||||
|
||||
use super::{
|
||||
use crate::{
|
||||
consts::{OPENGL_TO_WGPU_MATRIX, SPRITE_INSTANCE_LIMIT, STARFIELD_INSTANCE_LIMIT},
|
||||
consts_main,
|
||||
consts_main, content,
|
||||
globaldata::{GlobalData, GlobalDataContent},
|
||||
pipeline::PipelineBuilder,
|
||||
sprite::ObjectSubSprite,
|
||||
|
@ -50,7 +49,7 @@ struct VertexBuffers {
|
|||
}
|
||||
|
||||
impl GPUState {
|
||||
pub async fn new(window: Window, ct: &Content) -> Result<Self> {
|
||||
pub async fn new(window: Window, ct: &content::Content) -> Result<Self> {
|
||||
let window_size = window.inner_size();
|
||||
let window_aspect = window_size.width as f32 / window_size.height as f32;
|
||||
|
||||
|
|
|
@ -10,6 +10,7 @@ mod vertexbuffer;
|
|||
mod consts_main;
|
||||
|
||||
use cgmath::{Point3, Vector2};
|
||||
use galactica_content as content;
|
||||
pub use gpustate::GPUState;
|
||||
pub use sprite::{AnchoredUiPosition, ObjectSprite, ObjectSubSprite, UiSprite};
|
||||
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
use std::rc::Rc;
|
||||
use wgpu;
|
||||
|
||||
use super::consts::{SHADER_MAIN_FRAGMENT, SHADER_MAIN_VERTEX};
|
||||
use super::vertexbuffer::VertexBuffer;
|
||||
use crate::consts::{SHADER_MAIN_FRAGMENT, SHADER_MAIN_VERTEX};
|
||||
use crate::vertexbuffer::VertexBuffer;
|
||||
|
||||
pub struct PipelineBuilder<'a> {
|
||||
// These are provided with new()
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
use crate::content;
|
||||
use cgmath::{Deg, Point2, Point3};
|
||||
use galactica_content::TextureHandle;
|
||||
|
||||
/// The location of a UI element, in one of a few
|
||||
/// possible coordinate systems.
|
||||
|
@ -21,7 +21,7 @@ pub enum AnchoredUiPosition {
|
|||
#[derive(Debug, Clone)]
|
||||
pub struct UiSprite {
|
||||
/// The texture to use for this sprite
|
||||
pub texture: TextureHandle,
|
||||
pub texture: content::TextureHandle,
|
||||
|
||||
/// This object's position, in logical (dpi-adjusted) pixels
|
||||
pub pos: AnchoredUiPosition,
|
||||
|
@ -38,7 +38,7 @@ pub struct UiSprite {
|
|||
#[derive(Debug, Clone)]
|
||||
pub struct ObjectSprite {
|
||||
/// The texture to use for this sprite
|
||||
pub texture: TextureHandle,
|
||||
pub texture: content::TextureHandle,
|
||||
|
||||
/// This object's center, in world coordinates.
|
||||
pub pos: Point3<f32>,
|
||||
|
@ -59,7 +59,7 @@ pub struct ObjectSprite {
|
|||
#[derive(Debug, Clone)]
|
||||
pub struct ObjectSubSprite {
|
||||
/// The sprite texture to draw
|
||||
pub texture: TextureHandle,
|
||||
pub texture: content::TextureHandle,
|
||||
|
||||
/// This object's position, in world coordinates.
|
||||
/// This is relative to this sprite's parent.
|
||||
|
|
|
@ -1,15 +1,15 @@
|
|||
use crate::content;
|
||||
use anyhow::Result;
|
||||
use galactica_content::{Content, TextureHandle};
|
||||
use image::GenericImageView;
|
||||
use std::{collections::HashMap, fs::File, io::Read, num::NonZeroU32};
|
||||
use wgpu::BindGroupLayout;
|
||||
|
||||
pub(super) struct RawTexture {
|
||||
pub(super) view: wgpu::TextureView,
|
||||
pub(crate) struct RawTexture {
|
||||
pub(crate) view: wgpu::TextureView,
|
||||
}
|
||||
|
||||
impl RawTexture {
|
||||
pub(super) fn from_bytes(
|
||||
pub(crate) fn from_bytes(
|
||||
device: &wgpu::Device,
|
||||
queue: &wgpu::Queue,
|
||||
bytes: &[u8],
|
||||
|
@ -19,7 +19,7 @@ impl RawTexture {
|
|||
Self::from_image(device, queue, &img, Some(label))
|
||||
}
|
||||
|
||||
pub(super) fn from_image(
|
||||
pub(crate) fn from_image(
|
||||
device: &wgpu::Device,
|
||||
queue: &wgpu::Queue,
|
||||
img: &image::DynamicImage,
|
||||
|
@ -76,8 +76,8 @@ pub struct Texture {
|
|||
pub struct TextureArray {
|
||||
pub bind_group: wgpu::BindGroup,
|
||||
pub bind_group_layout: BindGroupLayout,
|
||||
starfield_handle: TextureHandle,
|
||||
textures: HashMap<TextureHandle, Texture>,
|
||||
starfield_handle: content::TextureHandle,
|
||||
textures: HashMap<content::TextureHandle, Texture>,
|
||||
}
|
||||
|
||||
impl TextureArray {
|
||||
|
@ -85,14 +85,14 @@ impl TextureArray {
|
|||
*self.textures.get(&self.starfield_handle).unwrap()
|
||||
}
|
||||
|
||||
pub fn get_texture(&self, handle: TextureHandle) -> Texture {
|
||||
pub fn get_texture(&self, handle: content::TextureHandle) -> Texture {
|
||||
match self.textures.get(&handle) {
|
||||
Some(x) => *x,
|
||||
None => unreachable!("Tried to get a texture that doesn't exist"),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn new(device: &wgpu::Device, queue: &wgpu::Queue, ct: &Content) -> Result<Self> {
|
||||
pub fn new(device: &wgpu::Device, queue: &wgpu::Queue, ct: &content::Content) -> Result<Self> {
|
||||
// Load all textures
|
||||
let mut texture_data = Vec::new();
|
||||
let mut textures = HashMap::new();
|
||||
|
|
|
@ -1,13 +1,11 @@
|
|||
use cgmath::{Deg, InnerSpace, Point2};
|
||||
use galactica_content as content;
|
||||
use galactica_content::FactionHandle;
|
||||
use galactica_render::{AnchoredUiPosition, ObjectSprite, UiSprite};
|
||||
use std::time::Instant;
|
||||
use winit::event::{ElementState, MouseButton, MouseScrollDelta, TouchPhase, VirtualKeyCode};
|
||||
|
||||
use super::{camera::Camera, outfits, system::System};
|
||||
use crate::{
|
||||
consts,
|
||||
consts, content,
|
||||
inputstatus::InputStatus,
|
||||
physics::{util, Physics, ShipHandle},
|
||||
shipbehavior::{self, ShipBehavior},
|
||||
|
@ -97,14 +95,14 @@ impl Game {
|
|||
&ct.ships[0],
|
||||
o1,
|
||||
Point2 { x: 0.0, y: 0.0 },
|
||||
FactionHandle { index: 0 },
|
||||
content::FactionHandle { index: 0 },
|
||||
);
|
||||
|
||||
let h2 = physics.add_ship(
|
||||
&ct.ships[0],
|
||||
outfits::ShipOutfits::new(&ct.ships[0]),
|
||||
Point2 { x: 300.0, y: 300.0 },
|
||||
FactionHandle { index: 0 },
|
||||
content::FactionHandle { index: 0 },
|
||||
);
|
||||
|
||||
let mut o2 = outfits::ShipOutfits::new(&ct.ships[0]);
|
||||
|
@ -117,7 +115,7 @@ impl Game {
|
|||
x: -300.0,
|
||||
y: 300.0,
|
||||
},
|
||||
FactionHandle { index: 1 },
|
||||
content::FactionHandle { index: 1 },
|
||||
);
|
||||
|
||||
let mut shipbehaviors: Vec<Box<dyn ShipBehavior>> = Vec::new();
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
use cgmath::{Deg, Point3};
|
||||
use galactica_content as content;
|
||||
use galactica_render::ObjectSubSprite;
|
||||
|
||||
use crate::content;
|
||||
|
||||
/// Represents a gun attached to a specific ship at a certain gunpoint.
|
||||
#[derive(Debug)]
|
||||
pub struct ShipGun {
|
||||
|
|
|
@ -1,10 +1,9 @@
|
|||
use cgmath::{Point3, Vector2};
|
||||
use galactica_content as content;
|
||||
use galactica_render::{ObjectSprite, StarfieldStar};
|
||||
use rand::{self, Rng};
|
||||
|
||||
use super::SystemObject;
|
||||
use crate::consts;
|
||||
use crate::{consts, content};
|
||||
|
||||
pub struct System {
|
||||
pub name: String,
|
||||
|
|
|
@ -1,16 +1,16 @@
|
|||
use crate::content;
|
||||
use cgmath::{Deg, Point3};
|
||||
use galactica_content::TextureHandle;
|
||||
use galactica_render::ObjectSprite;
|
||||
|
||||
pub struct SystemObject {
|
||||
pub sprite_texture: TextureHandle,
|
||||
pub sprite_texture: content::TextureHandle,
|
||||
pub pos: Point3<f32>,
|
||||
pub size: f32,
|
||||
pub angle: Deg<f32>,
|
||||
}
|
||||
|
||||
impl SystemObject {
|
||||
pub(super) fn get_sprite(&self) -> ObjectSprite {
|
||||
pub(crate) fn get_sprite(&self) -> ObjectSprite {
|
||||
return ObjectSprite {
|
||||
texture: self.sprite_texture,
|
||||
pos: self.pos,
|
||||
|
|
|
@ -5,9 +5,10 @@ mod objects;
|
|||
mod physics;
|
||||
mod shipbehavior;
|
||||
|
||||
use std::path::PathBuf;
|
||||
pub use galactica_content as content;
|
||||
|
||||
use anyhow::Result;
|
||||
use std::path::PathBuf;
|
||||
use winit::{
|
||||
event::{Event, KeyboardInput, WindowEvent},
|
||||
event_loop::{ControlFlow, EventLoop},
|
||||
|
@ -16,7 +17,7 @@ use winit::{
|
|||
|
||||
fn main() -> Result<()> {
|
||||
// TODO: error if missing
|
||||
let content = galactica_content::Content::load_dir(
|
||||
let content = content::Content::load_dir(
|
||||
PathBuf::from(consts::CONTENT_ROOT),
|
||||
PathBuf::from(consts::TEXTURE_ROOT),
|
||||
consts::STARFIELD_TEXTURE_NAME.to_owned(),
|
||||
|
|
|
@ -1,21 +1,20 @@
|
|||
use cgmath::{Deg, InnerSpace, Point3, Vector2};
|
||||
use galactica_content::{FactionHandle, TextureHandle};
|
||||
use galactica_render::ObjectSprite;
|
||||
use rapier2d::{
|
||||
dynamics::{RigidBody, RigidBodyBuilder, RigidBodyHandle},
|
||||
geometry::{ColliderBuilder, ColliderHandle},
|
||||
};
|
||||
|
||||
use crate::physics::util;
|
||||
use crate::{content, physics::util};
|
||||
|
||||
pub struct ProjectileBuilder {
|
||||
pub rigid_body: RigidBodyBuilder,
|
||||
pub collider: ColliderBuilder,
|
||||
pub sprite_texture: TextureHandle,
|
||||
pub sprite_texture: content::TextureHandle,
|
||||
pub lifetime: f32,
|
||||
pub size: f32,
|
||||
pub damage: f32,
|
||||
pub faction: FactionHandle,
|
||||
pub faction: content::FactionHandle,
|
||||
}
|
||||
|
||||
impl ProjectileBuilder {
|
||||
|
@ -36,11 +35,11 @@ impl ProjectileBuilder {
|
|||
pub struct Projectile {
|
||||
pub rigid_body: RigidBodyHandle,
|
||||
pub collider: ColliderHandle,
|
||||
pub sprite_texture: TextureHandle,
|
||||
pub sprite_texture: content::TextureHandle,
|
||||
pub lifetime: f32,
|
||||
pub size: f32,
|
||||
pub damage: f32,
|
||||
pub faction: FactionHandle,
|
||||
pub faction: content::FactionHandle,
|
||||
}
|
||||
|
||||
impl Projectile {
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
use cgmath::{Deg, EuclideanSpace, InnerSpace, Matrix2, Rad, Vector2};
|
||||
use content::{FactionHandle, TextureHandle};
|
||||
use galactica_content as content;
|
||||
use galactica_render::ObjectSprite;
|
||||
use nalgebra::vector;
|
||||
use rand::Rng;
|
||||
|
@ -12,6 +11,7 @@ use rapier2d::{
|
|||
|
||||
use super::ProjectileBuilder;
|
||||
use crate::{
|
||||
content,
|
||||
game::outfits,
|
||||
physics::{util, ShipHandle},
|
||||
};
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
use cgmath::Point2;
|
||||
use crossbeam::channel::Receiver;
|
||||
use galactica_content as content;
|
||||
use galactica_render::ObjectSprite;
|
||||
use nalgebra::vector;
|
||||
use rapier2d::{
|
||||
|
@ -11,7 +10,7 @@ use rapier2d::{
|
|||
use std::{collections::HashMap, f32::consts::PI};
|
||||
|
||||
use super::{wrapper::Wrapper, ShipHandle};
|
||||
use crate::{game::outfits, objects};
|
||||
use crate::{content, game::outfits, objects};
|
||||
|
||||
/// Keeps track of all objects in the world that we can interact with.
|
||||
/// Also wraps our physics engine
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
use cgmath::{Deg, InnerSpace};
|
||||
use galactica_content as content;
|
||||
|
||||
use crate::{
|
||||
content,
|
||||
inputstatus::InputStatus,
|
||||
physics::{util, Physics, ShipHandle},
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue