├── .gitignore ├── Cargo.toml ├── LICENSE.md ├── README.md ├── assets ├── avatars_sm │ ├── 01_sm.png │ ├── 02_sm.png │ ├── 03_sm.png │ ├── 04_sm.png │ ├── 05_sm.png │ ├── 06_sm.png │ ├── 07_sm.png │ ├── 08_sm.png │ ├── 09_sm.png │ ├── 10_sm.png │ ├── 11_sm.png │ ├── 12_sm.png │ ├── 13_sm.png │ ├── 14_sm.png │ ├── 15_sm.png │ ├── 16_sm.png │ ├── 17_sm.png │ ├── 18_sm.png │ ├── 19_sm.png │ ├── 20_sm.png │ ├── 21_sm.png │ ├── 22_sm.png │ ├── 23_sm.png │ ├── 24_sm.png │ ├── 25_sm.png │ ├── 26_sm.png │ ├── 27_sm.png │ ├── 28_sm.png │ ├── 29_sm.png │ ├── 30_sm.png │ ├── 31_sm.png │ ├── 32_sm.png │ ├── 33_sm.png │ ├── 34_sm.png │ ├── 35_sm.png │ ├── 36_sm.png │ ├── 37_sm.png │ ├── 38_sm.png │ ├── 39_sm.png │ ├── 40_sm.png │ ├── 41_sm.png │ ├── 42_sm.png │ ├── 43_sm.png │ ├── 44_sm.png │ ├── 45_sm.png │ ├── 46_sm.png │ ├── 47_sm.png │ ├── 48_sm.png │ ├── 49_sm.png │ ├── 50_sm.png │ ├── 51_sm.png │ ├── 52_sm.png │ ├── 53_sm.png │ ├── 54_sm.png │ ├── 55_sm.png │ ├── 56_sm.png │ ├── 57_sm.png │ ├── 58_sm.png │ ├── 59_sm.png │ ├── 60_sm.png │ ├── 61_sm.png │ ├── 62_sm.png │ ├── 63_sm.png │ ├── 64_sm.png │ ├── 65_sm.png │ ├── 66_sm.png │ ├── 67_sm.png │ ├── 68_sm.png │ ├── 69_sm.png │ ├── 70_sm.png │ ├── 71_sm.png │ ├── 72_sm.png │ ├── 73_sm.png │ └── 74_sm.png ├── enemy_fighter.png ├── enemy_fighter_sm.png ├── enemy_freighter.png ├── explosion.png ├── freighter_sm.png ├── houses.dat ├── mgfw │ ├── gui │ │ ├── button_base_b.png │ │ ├── button_base_bl.png │ │ ├── button_base_br.png │ │ ├── button_base_c.png │ │ ├── button_base_l.png │ │ ├── button_base_r.png │ │ ├── button_base_t.png │ │ ├── button_base_tl.png │ │ ├── button_base_tr.png │ │ ├── input_base_b.png │ │ ├── input_base_bl.png │ │ ├── input_base_br.png │ │ ├── input_base_c.png │ │ ├── input_base_l.png │ │ ├── input_base_r.png │ │ ├── input_base_t.png │ │ ├── input_base_tl.png │ │ ├── input_base_tr.png │ │ ├── input_selected_b.png │ │ ├── input_selected_bl.png │ │ ├── input_selected_br.png │ │ ├── input_selected_c.png │ │ ├── input_selected_l.png │ │ ├── input_selected_r.png │ │ ├── input_selected_t.png │ │ ├── input_selected_tl.png │ │ ├── input_selected_tr.png │ │ ├── panel_base_b.png │ │ ├── panel_base_bl.png │ │ ├── panel_base_br.png │ │ ├── panel_base_c.png │ │ ├── panel_base_c_test.png │ │ ├── panel_base_l.png │ │ ├── panel_base_r.png │ │ ├── panel_base_sep.png │ │ ├── panel_base_t.png │ │ ├── panel_base_tl.png │ │ ├── panel_base_tr.png │ │ ├── panel_simple_b.png │ │ ├── panel_simple_bl.png │ │ ├── panel_simple_br.png │ │ ├── panel_simple_c.png │ │ ├── panel_simple_l.png │ │ ├── panel_simple_r.png │ │ ├── panel_simple_t.png │ │ ├── panel_simple_tl.png │ │ └── panel_simple_tr.png │ ├── line_shader.fs │ ├── line_shader.vs │ ├── mgfw_64_trim.ico │ ├── poly_shader.fs │ ├── poly_shader.vs │ ├── retro_gaming_0.png │ ├── tex_shader.fs │ ├── tex_shader.vs │ └── ugui.png ├── player_fighter.png ├── player_fighter_sm.png ├── player_freighter.png ├── sel_fighter_enemy.png ├── sel_fighter_player.png ├── selector.png ├── sm-desert-planet.png ├── sm-galaxy-fade.png ├── sm-lush-planet.png ├── sm-nebula-0.png ├── sm-nebula-1.png ├── sm-nebula-2.png ├── sm-nebula-3.png ├── sm-nebula-4.png ├── sm-nebula-5.png ├── sm-ocean-planet.png ├── sm-volcano-planet.png ├── sprites.png ├── station.png ├── title.png ├── turn_order_selector.png └── world.dat ├── build.rs ├── screenshots ├── battle-combat.gif ├── galaxy.png ├── game_arch_simple.png ├── mgfw_arch_simple.png └── station.png └── src ├── game ├── enums.rs ├── game.rs ├── mod.rs ├── state.rs └── ui │ ├── battle.rs │ ├── galaxy.rs │ ├── mod.rs │ ├── planet.rs │ └── station.rs ├── main.rs └── mgfw ├── cache └── mod.rs ├── ecs ├── component_angle.rs ├── component_color.rs ├── component_easing.rs ├── component_frame.rs ├── component_physics.rs ├── component_position.rs ├── component_render.rs ├── component_render_billboard.rs ├── component_render_line_buffer.rs ├── component_render_text.rs ├── component_render_tilemap.rs ├── component_render_triangle_buffer.rs ├── component_scale.rs ├── entity.rs ├── mgui.rs ├── mod.rs ├── system_easing.rs ├── system_physics.rs ├── system_render.rs ├── ugui.rs ├── uigrid.rs └── world.rs ├── fonts ├── alagard.rs ├── mod.rs └── retro_gaming.rs ├── mod.rs └── support └── mod.rs /.gitignore: -------------------------------------------------------------------------------- 1 | /target 2 | -------------------------------------------------------------------------------- /Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "galaxion" 3 | version = "0.1.0" 4 | edition = "2021" 5 | 6 | # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html 7 | 8 | [dependencies] 9 | gl = "0.14.0" 10 | glutin = "0.26.0" 11 | takeable-option = "0.5" 12 | rand = "0.8.3" 13 | image = "0.23.14" 14 | cgmath = "0.18.0" 15 | gilrs = "0.9.0" 16 | 17 | [build-dependencies] 18 | gl_generator = "0.14" -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | [Galaxion Trade Empire](https://github.com/Syn-Nine/galaxion-trade-empire) © 2023 by [Daniel "Syn Nine" Kennedy](https://allmylinks.com/syn-nine) is licensed under [CC BY-NC-SA 4.0](http://creativecommons.org/licenses/by-nc-sa/4.0/?ref=chooser-v1) 2 | 3 | #### CC BY-NC-SA 4.0 4 | 5 | Attribution-NonCommercial-ShareAlike 4.0 International 6 | 7 | This license requires that reusers give credit to the creator. It allows reusers to distribute, remix, adapt, and build upon the material in any medium or format, for noncommercial purposes only. If others modify or adapt the material, they must license the modified material under identical terms. 8 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Galaxion Trade Empire 2 | Space Trading Game made in Rust based on the Trade Wars 2002 BBS game. 3 | 4 | This game is in public alpha and is fully playable and winnable, but is still under continued development to make it more interesting and fun. I hope to eventually make this web multiplayer. 5 | 6 | ### Feedback & Dev Log 7 | Please let me know if you find any bugs or have feedback! I have a dedicated channel for game updates and feedback on [my discord](https://discord.gg/rksRVtnF). I have a running dev log located here: [Syn9's Hideout](https://syn9.thehideoutgames.com/). 8 | 9 | ### Screenshots: 10 | ![](https://github.com/Syn-Nine/galaxion-trade-empire/blob/main/screenshots/battle-combat.gif) 11 | ![](https://github.com/Syn-Nine/galaxion-trade-empire/blob/main/screenshots/galaxy.png) 12 | ![](https://github.com/Syn-Nine/galaxion-trade-empire/blob/main/screenshots/station.png) 13 | 14 | ### How to Play: 15 | Improve your planets, explore, trade goods, build your armada, conquer other houses, repeat. 16 | 17 | Planets 18 | - Population Menu - Use this menu to determine the allocation of population to different jobs, like making food, labor work, and scientific research. 19 | - Manufacturing Menu - Use this menu to allocate manufacturing capacity to different areas. These goods can be used for trading or building fighter craft. 20 | - Research Menu - Use this menu to determine what the planet researches. This will affect the planet's production. 21 | - Cargo and Hangar Bay - Use this menu to transfer from the planet to your freighter. 22 | 23 | Stations 24 | - Trade - Use this menu to buy and sell goods at the station. 25 | - Terra Link - Use this menu to see the status of your planets. 26 | - Market Link - Use this menu to see prices at other known stations. 27 | - Nav Center - Use this menu to download new navigation maps to the local regions and other stations. 28 | - Houses - This menu shows the status of the other known royal houses in the galaxy. 29 | 30 | Galaxy View 31 | - The galaxy view allows navigation of your freighter to other planets and stations. 32 | - From this view you can also access your cargo status or attack planets. 33 | - Hold SPACE and move the mouse to pan. 34 | - Use scroll wheel to zoom. 35 | 36 | Combat 37 | - When you attack a planet, the royal house controlling the planet will attempt to defend their territory. 38 | - You can demand or offer a 10% tribute of freighter holds to end the attack early without surrender. 39 | - Surrender yields 50% of freighter holds. If the defender surrenders you take control of the planet. 40 | - Click the cell location to move/attack. The further the target, the lower probability of hit. 41 | - Hotkeys: F-move forward, SPACE-skip turn, A-attack weakest nearby enemy. 42 | - You can click the auto button to turn on auto-battle. 43 | - Landing a hit on the enemy freighter will force surrender. 44 | 45 | Capture all planets to win the game. 46 | 47 | Thanks for playing! 48 | 49 | Art Credit: 50 | - This game was made for a gamejam during the month of October 2023 and uses background images and avatars that were created at open.ai to speed up prototyping. These images are not copyrightable. All of the small sprite graphics were created by me. If I ever release the game commercially I'll make sure to replace the AI art with human made art. 51 | -------------------------------------------------------------------------------- /assets/avatars_sm/01_sm.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Syn-Nine/galaxion-trade-empire/378a32323a7546255e793843e1d1194b34e6f0ce/assets/avatars_sm/01_sm.png -------------------------------------------------------------------------------- /assets/avatars_sm/02_sm.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Syn-Nine/galaxion-trade-empire/378a32323a7546255e793843e1d1194b34e6f0ce/assets/avatars_sm/02_sm.png -------------------------------------------------------------------------------- /assets/avatars_sm/03_sm.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Syn-Nine/galaxion-trade-empire/378a32323a7546255e793843e1d1194b34e6f0ce/assets/avatars_sm/03_sm.png -------------------------------------------------------------------------------- /assets/avatars_sm/04_sm.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Syn-Nine/galaxion-trade-empire/378a32323a7546255e793843e1d1194b34e6f0ce/assets/avatars_sm/04_sm.png -------------------------------------------------------------------------------- /assets/avatars_sm/05_sm.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Syn-Nine/galaxion-trade-empire/378a32323a7546255e793843e1d1194b34e6f0ce/assets/avatars_sm/05_sm.png -------------------------------------------------------------------------------- /assets/avatars_sm/06_sm.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Syn-Nine/galaxion-trade-empire/378a32323a7546255e793843e1d1194b34e6f0ce/assets/avatars_sm/06_sm.png -------------------------------------------------------------------------------- /assets/avatars_sm/07_sm.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Syn-Nine/galaxion-trade-empire/378a32323a7546255e793843e1d1194b34e6f0ce/assets/avatars_sm/07_sm.png -------------------------------------------------------------------------------- /assets/avatars_sm/08_sm.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Syn-Nine/galaxion-trade-empire/378a32323a7546255e793843e1d1194b34e6f0ce/assets/avatars_sm/08_sm.png -------------------------------------------------------------------------------- /assets/avatars_sm/09_sm.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Syn-Nine/galaxion-trade-empire/378a32323a7546255e793843e1d1194b34e6f0ce/assets/avatars_sm/09_sm.png -------------------------------------------------------------------------------- /assets/avatars_sm/10_sm.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Syn-Nine/galaxion-trade-empire/378a32323a7546255e793843e1d1194b34e6f0ce/assets/avatars_sm/10_sm.png -------------------------------------------------------------------------------- /assets/avatars_sm/11_sm.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Syn-Nine/galaxion-trade-empire/378a32323a7546255e793843e1d1194b34e6f0ce/assets/avatars_sm/11_sm.png -------------------------------------------------------------------------------- /assets/avatars_sm/12_sm.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Syn-Nine/galaxion-trade-empire/378a32323a7546255e793843e1d1194b34e6f0ce/assets/avatars_sm/12_sm.png -------------------------------------------------------------------------------- /assets/avatars_sm/13_sm.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Syn-Nine/galaxion-trade-empire/378a32323a7546255e793843e1d1194b34e6f0ce/assets/avatars_sm/13_sm.png -------------------------------------------------------------------------------- /assets/avatars_sm/14_sm.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Syn-Nine/galaxion-trade-empire/378a32323a7546255e793843e1d1194b34e6f0ce/assets/avatars_sm/14_sm.png -------------------------------------------------------------------------------- /assets/avatars_sm/15_sm.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Syn-Nine/galaxion-trade-empire/378a32323a7546255e793843e1d1194b34e6f0ce/assets/avatars_sm/15_sm.png -------------------------------------------------------------------------------- /assets/avatars_sm/16_sm.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Syn-Nine/galaxion-trade-empire/378a32323a7546255e793843e1d1194b34e6f0ce/assets/avatars_sm/16_sm.png -------------------------------------------------------------------------------- /assets/avatars_sm/17_sm.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Syn-Nine/galaxion-trade-empire/378a32323a7546255e793843e1d1194b34e6f0ce/assets/avatars_sm/17_sm.png -------------------------------------------------------------------------------- /assets/avatars_sm/18_sm.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Syn-Nine/galaxion-trade-empire/378a32323a7546255e793843e1d1194b34e6f0ce/assets/avatars_sm/18_sm.png -------------------------------------------------------------------------------- /assets/avatars_sm/19_sm.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Syn-Nine/galaxion-trade-empire/378a32323a7546255e793843e1d1194b34e6f0ce/assets/avatars_sm/19_sm.png -------------------------------------------------------------------------------- /assets/avatars_sm/20_sm.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Syn-Nine/galaxion-trade-empire/378a32323a7546255e793843e1d1194b34e6f0ce/assets/avatars_sm/20_sm.png -------------------------------------------------------------------------------- /assets/avatars_sm/21_sm.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Syn-Nine/galaxion-trade-empire/378a32323a7546255e793843e1d1194b34e6f0ce/assets/avatars_sm/21_sm.png -------------------------------------------------------------------------------- /assets/avatars_sm/22_sm.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Syn-Nine/galaxion-trade-empire/378a32323a7546255e793843e1d1194b34e6f0ce/assets/avatars_sm/22_sm.png -------------------------------------------------------------------------------- /assets/avatars_sm/23_sm.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Syn-Nine/galaxion-trade-empire/378a32323a7546255e793843e1d1194b34e6f0ce/assets/avatars_sm/23_sm.png -------------------------------------------------------------------------------- /assets/avatars_sm/24_sm.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Syn-Nine/galaxion-trade-empire/378a32323a7546255e793843e1d1194b34e6f0ce/assets/avatars_sm/24_sm.png -------------------------------------------------------------------------------- /assets/avatars_sm/25_sm.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Syn-Nine/galaxion-trade-empire/378a32323a7546255e793843e1d1194b34e6f0ce/assets/avatars_sm/25_sm.png -------------------------------------------------------------------------------- /assets/avatars_sm/26_sm.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Syn-Nine/galaxion-trade-empire/378a32323a7546255e793843e1d1194b34e6f0ce/assets/avatars_sm/26_sm.png -------------------------------------------------------------------------------- /assets/avatars_sm/27_sm.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Syn-Nine/galaxion-trade-empire/378a32323a7546255e793843e1d1194b34e6f0ce/assets/avatars_sm/27_sm.png -------------------------------------------------------------------------------- /assets/avatars_sm/28_sm.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Syn-Nine/galaxion-trade-empire/378a32323a7546255e793843e1d1194b34e6f0ce/assets/avatars_sm/28_sm.png -------------------------------------------------------------------------------- /assets/avatars_sm/29_sm.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Syn-Nine/galaxion-trade-empire/378a32323a7546255e793843e1d1194b34e6f0ce/assets/avatars_sm/29_sm.png -------------------------------------------------------------------------------- /assets/avatars_sm/30_sm.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Syn-Nine/galaxion-trade-empire/378a32323a7546255e793843e1d1194b34e6f0ce/assets/avatars_sm/30_sm.png -------------------------------------------------------------------------------- /assets/avatars_sm/31_sm.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Syn-Nine/galaxion-trade-empire/378a32323a7546255e793843e1d1194b34e6f0ce/assets/avatars_sm/31_sm.png -------------------------------------------------------------------------------- /assets/avatars_sm/32_sm.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Syn-Nine/galaxion-trade-empire/378a32323a7546255e793843e1d1194b34e6f0ce/assets/avatars_sm/32_sm.png -------------------------------------------------------------------------------- /assets/avatars_sm/33_sm.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Syn-Nine/galaxion-trade-empire/378a32323a7546255e793843e1d1194b34e6f0ce/assets/avatars_sm/33_sm.png -------------------------------------------------------------------------------- /assets/avatars_sm/34_sm.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Syn-Nine/galaxion-trade-empire/378a32323a7546255e793843e1d1194b34e6f0ce/assets/avatars_sm/34_sm.png -------------------------------------------------------------------------------- /assets/avatars_sm/35_sm.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Syn-Nine/galaxion-trade-empire/378a32323a7546255e793843e1d1194b34e6f0ce/assets/avatars_sm/35_sm.png -------------------------------------------------------------------------------- /assets/avatars_sm/36_sm.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Syn-Nine/galaxion-trade-empire/378a32323a7546255e793843e1d1194b34e6f0ce/assets/avatars_sm/36_sm.png -------------------------------------------------------------------------------- /assets/avatars_sm/37_sm.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Syn-Nine/galaxion-trade-empire/378a32323a7546255e793843e1d1194b34e6f0ce/assets/avatars_sm/37_sm.png -------------------------------------------------------------------------------- /assets/avatars_sm/38_sm.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Syn-Nine/galaxion-trade-empire/378a32323a7546255e793843e1d1194b34e6f0ce/assets/avatars_sm/38_sm.png -------------------------------------------------------------------------------- /assets/avatars_sm/39_sm.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Syn-Nine/galaxion-trade-empire/378a32323a7546255e793843e1d1194b34e6f0ce/assets/avatars_sm/39_sm.png -------------------------------------------------------------------------------- /assets/avatars_sm/40_sm.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Syn-Nine/galaxion-trade-empire/378a32323a7546255e793843e1d1194b34e6f0ce/assets/avatars_sm/40_sm.png -------------------------------------------------------------------------------- /assets/avatars_sm/41_sm.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Syn-Nine/galaxion-trade-empire/378a32323a7546255e793843e1d1194b34e6f0ce/assets/avatars_sm/41_sm.png -------------------------------------------------------------------------------- /assets/avatars_sm/42_sm.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Syn-Nine/galaxion-trade-empire/378a32323a7546255e793843e1d1194b34e6f0ce/assets/avatars_sm/42_sm.png -------------------------------------------------------------------------------- /assets/avatars_sm/43_sm.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Syn-Nine/galaxion-trade-empire/378a32323a7546255e793843e1d1194b34e6f0ce/assets/avatars_sm/43_sm.png -------------------------------------------------------------------------------- /assets/avatars_sm/44_sm.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Syn-Nine/galaxion-trade-empire/378a32323a7546255e793843e1d1194b34e6f0ce/assets/avatars_sm/44_sm.png -------------------------------------------------------------------------------- /assets/avatars_sm/45_sm.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Syn-Nine/galaxion-trade-empire/378a32323a7546255e793843e1d1194b34e6f0ce/assets/avatars_sm/45_sm.png -------------------------------------------------------------------------------- /assets/avatars_sm/46_sm.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Syn-Nine/galaxion-trade-empire/378a32323a7546255e793843e1d1194b34e6f0ce/assets/avatars_sm/46_sm.png -------------------------------------------------------------------------------- /assets/avatars_sm/47_sm.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Syn-Nine/galaxion-trade-empire/378a32323a7546255e793843e1d1194b34e6f0ce/assets/avatars_sm/47_sm.png -------------------------------------------------------------------------------- /assets/avatars_sm/48_sm.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Syn-Nine/galaxion-trade-empire/378a32323a7546255e793843e1d1194b34e6f0ce/assets/avatars_sm/48_sm.png -------------------------------------------------------------------------------- /assets/avatars_sm/49_sm.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Syn-Nine/galaxion-trade-empire/378a32323a7546255e793843e1d1194b34e6f0ce/assets/avatars_sm/49_sm.png -------------------------------------------------------------------------------- /assets/avatars_sm/50_sm.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Syn-Nine/galaxion-trade-empire/378a32323a7546255e793843e1d1194b34e6f0ce/assets/avatars_sm/50_sm.png -------------------------------------------------------------------------------- /assets/avatars_sm/51_sm.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Syn-Nine/galaxion-trade-empire/378a32323a7546255e793843e1d1194b34e6f0ce/assets/avatars_sm/51_sm.png -------------------------------------------------------------------------------- /assets/avatars_sm/52_sm.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Syn-Nine/galaxion-trade-empire/378a32323a7546255e793843e1d1194b34e6f0ce/assets/avatars_sm/52_sm.png -------------------------------------------------------------------------------- /assets/avatars_sm/53_sm.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Syn-Nine/galaxion-trade-empire/378a32323a7546255e793843e1d1194b34e6f0ce/assets/avatars_sm/53_sm.png -------------------------------------------------------------------------------- /assets/avatars_sm/54_sm.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Syn-Nine/galaxion-trade-empire/378a32323a7546255e793843e1d1194b34e6f0ce/assets/avatars_sm/54_sm.png -------------------------------------------------------------------------------- /assets/avatars_sm/55_sm.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Syn-Nine/galaxion-trade-empire/378a32323a7546255e793843e1d1194b34e6f0ce/assets/avatars_sm/55_sm.png -------------------------------------------------------------------------------- /assets/avatars_sm/56_sm.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Syn-Nine/galaxion-trade-empire/378a32323a7546255e793843e1d1194b34e6f0ce/assets/avatars_sm/56_sm.png -------------------------------------------------------------------------------- /assets/avatars_sm/57_sm.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Syn-Nine/galaxion-trade-empire/378a32323a7546255e793843e1d1194b34e6f0ce/assets/avatars_sm/57_sm.png -------------------------------------------------------------------------------- /assets/avatars_sm/58_sm.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Syn-Nine/galaxion-trade-empire/378a32323a7546255e793843e1d1194b34e6f0ce/assets/avatars_sm/58_sm.png -------------------------------------------------------------------------------- /assets/avatars_sm/59_sm.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Syn-Nine/galaxion-trade-empire/378a32323a7546255e793843e1d1194b34e6f0ce/assets/avatars_sm/59_sm.png -------------------------------------------------------------------------------- /assets/avatars_sm/60_sm.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Syn-Nine/galaxion-trade-empire/378a32323a7546255e793843e1d1194b34e6f0ce/assets/avatars_sm/60_sm.png -------------------------------------------------------------------------------- /assets/avatars_sm/61_sm.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Syn-Nine/galaxion-trade-empire/378a32323a7546255e793843e1d1194b34e6f0ce/assets/avatars_sm/61_sm.png -------------------------------------------------------------------------------- /assets/avatars_sm/62_sm.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Syn-Nine/galaxion-trade-empire/378a32323a7546255e793843e1d1194b34e6f0ce/assets/avatars_sm/62_sm.png -------------------------------------------------------------------------------- /assets/avatars_sm/63_sm.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Syn-Nine/galaxion-trade-empire/378a32323a7546255e793843e1d1194b34e6f0ce/assets/avatars_sm/63_sm.png -------------------------------------------------------------------------------- /assets/avatars_sm/64_sm.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Syn-Nine/galaxion-trade-empire/378a32323a7546255e793843e1d1194b34e6f0ce/assets/avatars_sm/64_sm.png -------------------------------------------------------------------------------- /assets/avatars_sm/65_sm.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Syn-Nine/galaxion-trade-empire/378a32323a7546255e793843e1d1194b34e6f0ce/assets/avatars_sm/65_sm.png -------------------------------------------------------------------------------- /assets/avatars_sm/66_sm.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Syn-Nine/galaxion-trade-empire/378a32323a7546255e793843e1d1194b34e6f0ce/assets/avatars_sm/66_sm.png -------------------------------------------------------------------------------- /assets/avatars_sm/67_sm.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Syn-Nine/galaxion-trade-empire/378a32323a7546255e793843e1d1194b34e6f0ce/assets/avatars_sm/67_sm.png -------------------------------------------------------------------------------- /assets/avatars_sm/68_sm.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Syn-Nine/galaxion-trade-empire/378a32323a7546255e793843e1d1194b34e6f0ce/assets/avatars_sm/68_sm.png -------------------------------------------------------------------------------- /assets/avatars_sm/69_sm.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Syn-Nine/galaxion-trade-empire/378a32323a7546255e793843e1d1194b34e6f0ce/assets/avatars_sm/69_sm.png -------------------------------------------------------------------------------- /assets/avatars_sm/70_sm.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Syn-Nine/galaxion-trade-empire/378a32323a7546255e793843e1d1194b34e6f0ce/assets/avatars_sm/70_sm.png -------------------------------------------------------------------------------- /assets/avatars_sm/71_sm.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Syn-Nine/galaxion-trade-empire/378a32323a7546255e793843e1d1194b34e6f0ce/assets/avatars_sm/71_sm.png -------------------------------------------------------------------------------- /assets/avatars_sm/72_sm.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Syn-Nine/galaxion-trade-empire/378a32323a7546255e793843e1d1194b34e6f0ce/assets/avatars_sm/72_sm.png -------------------------------------------------------------------------------- /assets/avatars_sm/73_sm.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Syn-Nine/galaxion-trade-empire/378a32323a7546255e793843e1d1194b34e6f0ce/assets/avatars_sm/73_sm.png -------------------------------------------------------------------------------- /assets/avatars_sm/74_sm.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Syn-Nine/galaxion-trade-empire/378a32323a7546255e793843e1d1194b34e6f0ce/assets/avatars_sm/74_sm.png -------------------------------------------------------------------------------- /assets/enemy_fighter.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Syn-Nine/galaxion-trade-empire/378a32323a7546255e793843e1d1194b34e6f0ce/assets/enemy_fighter.png -------------------------------------------------------------------------------- /assets/enemy_fighter_sm.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Syn-Nine/galaxion-trade-empire/378a32323a7546255e793843e1d1194b34e6f0ce/assets/enemy_fighter_sm.png -------------------------------------------------------------------------------- /assets/enemy_freighter.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Syn-Nine/galaxion-trade-empire/378a32323a7546255e793843e1d1194b34e6f0ce/assets/enemy_freighter.png -------------------------------------------------------------------------------- /assets/explosion.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Syn-Nine/galaxion-trade-empire/378a32323a7546255e793843e1d1194b34e6f0ce/assets/explosion.png -------------------------------------------------------------------------------- /assets/freighter_sm.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Syn-Nine/galaxion-trade-empire/378a32323a7546255e793843e1d1194b34e6f0ce/assets/freighter_sm.png -------------------------------------------------------------------------------- /assets/houses.dat: -------------------------------------------------------------------------------- 1 | Aaccral 2 | Aaralnu 3 | Aauing 4 | Abboon 5 | Acimohs 6 | Acoenrt'c 7 | Adlamenasr 8 | Aeeayy 9 | Aeynh 10 | Agdaber 11 | Agra 12 | Ahrgila 13 | Ahwk 14 | Airlanca 15 | Alaraacc 16 | Ashurk 17 | Atcoi 18 | Atlogih 19 | Atpri 20 | Auffobl 21 | Azbre 22 | Baaromu 23 | Baibrt 24 | Bao 25 | Bera 26 | Biex 27 | Brae 28 | Brid 29 | Brteaca 30 | Burzdaz 31 | Cagouol 32 | Caito 33 | Caogur 34 | Carbo 35 | Cartontot 36 | C'dheina 37 | Cgloou 38 | Ciarrptllea 39 | Cirda'aln 40 | Cnidr'laa 41 | Cn'lachilih 42 | Cogulo 43 | Cooyta 44 | Copleu 45 | Crba 46 | Croeodilc 47 | Darniacl 48 | Dazburz 49 | D'uk 50 | Dhawyh 51 | D'heol 52 | Dierpp 53 | D'mlaailro 54 | D'peoarl 55 | D'ppier 56 | Druzazb 57 | Duzzarb 58 | Eacdinh 59 | Eaerbeyarl 60 | Eaeyya 61 | Ebaver 62 | Ebe 63 | Eder 64 | Eetelb 65 | Eeyaya 66 | Egael 67 | Eiv'pr 68 | Einehapt 69 | Elohd 70 | Engalr 71 | Enlamas-dar 72 | Env'ra 73 | Eohnart 74 | Ezaraba 75 | Faocl 76 | Fela 77 | Fhicn 78 | Flae 79 | Forg 80 | Gali 81 | G'doilw 82 | Gedu 83 | Georsu 84 | Gerphalea 85 | Gofotanth 86 | G'railah 87 | Haeyn 88 | Harxy 89 | Hergpaael 90 | H'kwa 91 | Hrnoet 92 | H'ronta 93 | Hxyar 94 | Iamatnr 95 | Iart 96 | Icamhos 97 | Iduker 98 | Igrallo 99 | Ivcet 100 | Ixeb 101 | Jakacl 102 | Laccraa 103 | Laeeg 104 | Laridica 105 | L'cakaj 106 | Leateb 107 | Lektse'ra 108 | Lhairag 109 | Ln'grea 110 | Loailrag 111 | Lqirrues 112 | Luettra 113 | Lwo 114 | Maarptign 115 | Marbaou 116 | Mh'laeoecn 117 | Minsat 118 | Moel 119 | Mrahrok 120 | Nabboa 121 | Nad-pa 122 | Nalfoc 123 | Naoobb 124 | Nata 125 | Natik 126 | Nhillhicca 127 | N'rew 128 | Nrma-tay 129 | N'tceacor 130 | N'trampa-gi 131 | Oanplagin 132 | Oaobban 133 | Oaraumb 134 | Oargd'n 135 | Ocoupst 136 | Odahle 137 | Odiwwa 138 | Odwidig 139 | Ognatfoth 140 | Ogucar 141 | Ohcuhg 142 | O'mile 143 | Onboba 144 | Opstuco 145 | O'rcaw 146 | O'tad 147 | O'trneh 148 | Paangir-tam 149 | Paigoln 150 | Peda-laor 151 | Pedpir 152 | Pigirmatan 153 | Plegnoian 154 | Pme'eorr 155 | Pna'ad 156 | Pnagnoil 157 | Procison 158 | Putsoco 159 | Raguoac 160 | R'bceaat 161 | R'cendiaal 162 | Reab 163 | Recba'at 164 | Resktle 165 | R'galiah 166 | Rioncross 167 | Ribbat 168 | Rilnbohl 169 | R'kash 170 | Rkjesprinlpi 171 | Rldoocice 172 | Rlusrieq 173 | Rn'tayt 174 | Robac 175 | Rohnte 176 | Romahkr 177 | R'vean 178 | Rwen 179 | Ryhxa 180 | Saruoge 181 | Siarnt'gale 182 | Snalma-dar 183 | Sotkr 184 | S'ridpeh 185 | Tarh 186 | T'coencar 187 | T'grei 188 | Thanor 189 | Theeahc 190 | Thrhsu 191 | Tiakn 192 | T'letur 193 | T'na 194 | Tnimra'a 195 | Torhn 196 | Tortoncta 197 | Toycoe 198 | Tranaami 199 | Tyarnt 200 | Tynaarma 201 | Udzrazb 202 | Ugiaan 203 | Ugnaacoa 204 | Uivcna 205 | Ulocgo 206 | Uovaang 207 | Uptocos 208 | Vode 209 | W'briaod 210 | Weelas 211 | Whdayh 212 | Wresilth 213 | Wrom 214 | Was'leea 215 | X'bei 216 | Xof 217 | Yampirel 218 | Yyeaae 219 | Zilrad 220 | -------------------------------------------------------------------------------- /assets/mgfw/gui/button_base_b.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Syn-Nine/galaxion-trade-empire/378a32323a7546255e793843e1d1194b34e6f0ce/assets/mgfw/gui/button_base_b.png -------------------------------------------------------------------------------- /assets/mgfw/gui/button_base_bl.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Syn-Nine/galaxion-trade-empire/378a32323a7546255e793843e1d1194b34e6f0ce/assets/mgfw/gui/button_base_bl.png -------------------------------------------------------------------------------- /assets/mgfw/gui/button_base_br.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Syn-Nine/galaxion-trade-empire/378a32323a7546255e793843e1d1194b34e6f0ce/assets/mgfw/gui/button_base_br.png -------------------------------------------------------------------------------- /assets/mgfw/gui/button_base_c.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Syn-Nine/galaxion-trade-empire/378a32323a7546255e793843e1d1194b34e6f0ce/assets/mgfw/gui/button_base_c.png -------------------------------------------------------------------------------- /assets/mgfw/gui/button_base_l.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Syn-Nine/galaxion-trade-empire/378a32323a7546255e793843e1d1194b34e6f0ce/assets/mgfw/gui/button_base_l.png -------------------------------------------------------------------------------- /assets/mgfw/gui/button_base_r.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Syn-Nine/galaxion-trade-empire/378a32323a7546255e793843e1d1194b34e6f0ce/assets/mgfw/gui/button_base_r.png -------------------------------------------------------------------------------- /assets/mgfw/gui/button_base_t.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Syn-Nine/galaxion-trade-empire/378a32323a7546255e793843e1d1194b34e6f0ce/assets/mgfw/gui/button_base_t.png -------------------------------------------------------------------------------- /assets/mgfw/gui/button_base_tl.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Syn-Nine/galaxion-trade-empire/378a32323a7546255e793843e1d1194b34e6f0ce/assets/mgfw/gui/button_base_tl.png -------------------------------------------------------------------------------- /assets/mgfw/gui/button_base_tr.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Syn-Nine/galaxion-trade-empire/378a32323a7546255e793843e1d1194b34e6f0ce/assets/mgfw/gui/button_base_tr.png -------------------------------------------------------------------------------- /assets/mgfw/gui/input_base_b.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Syn-Nine/galaxion-trade-empire/378a32323a7546255e793843e1d1194b34e6f0ce/assets/mgfw/gui/input_base_b.png -------------------------------------------------------------------------------- /assets/mgfw/gui/input_base_bl.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Syn-Nine/galaxion-trade-empire/378a32323a7546255e793843e1d1194b34e6f0ce/assets/mgfw/gui/input_base_bl.png -------------------------------------------------------------------------------- /assets/mgfw/gui/input_base_br.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Syn-Nine/galaxion-trade-empire/378a32323a7546255e793843e1d1194b34e6f0ce/assets/mgfw/gui/input_base_br.png -------------------------------------------------------------------------------- /assets/mgfw/gui/input_base_c.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Syn-Nine/galaxion-trade-empire/378a32323a7546255e793843e1d1194b34e6f0ce/assets/mgfw/gui/input_base_c.png -------------------------------------------------------------------------------- /assets/mgfw/gui/input_base_l.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Syn-Nine/galaxion-trade-empire/378a32323a7546255e793843e1d1194b34e6f0ce/assets/mgfw/gui/input_base_l.png -------------------------------------------------------------------------------- /assets/mgfw/gui/input_base_r.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Syn-Nine/galaxion-trade-empire/378a32323a7546255e793843e1d1194b34e6f0ce/assets/mgfw/gui/input_base_r.png -------------------------------------------------------------------------------- /assets/mgfw/gui/input_base_t.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Syn-Nine/galaxion-trade-empire/378a32323a7546255e793843e1d1194b34e6f0ce/assets/mgfw/gui/input_base_t.png -------------------------------------------------------------------------------- /assets/mgfw/gui/input_base_tl.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Syn-Nine/galaxion-trade-empire/378a32323a7546255e793843e1d1194b34e6f0ce/assets/mgfw/gui/input_base_tl.png -------------------------------------------------------------------------------- /assets/mgfw/gui/input_base_tr.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Syn-Nine/galaxion-trade-empire/378a32323a7546255e793843e1d1194b34e6f0ce/assets/mgfw/gui/input_base_tr.png -------------------------------------------------------------------------------- /assets/mgfw/gui/input_selected_b.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Syn-Nine/galaxion-trade-empire/378a32323a7546255e793843e1d1194b34e6f0ce/assets/mgfw/gui/input_selected_b.png -------------------------------------------------------------------------------- /assets/mgfw/gui/input_selected_bl.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Syn-Nine/galaxion-trade-empire/378a32323a7546255e793843e1d1194b34e6f0ce/assets/mgfw/gui/input_selected_bl.png -------------------------------------------------------------------------------- /assets/mgfw/gui/input_selected_br.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Syn-Nine/galaxion-trade-empire/378a32323a7546255e793843e1d1194b34e6f0ce/assets/mgfw/gui/input_selected_br.png -------------------------------------------------------------------------------- /assets/mgfw/gui/input_selected_c.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Syn-Nine/galaxion-trade-empire/378a32323a7546255e793843e1d1194b34e6f0ce/assets/mgfw/gui/input_selected_c.png -------------------------------------------------------------------------------- /assets/mgfw/gui/input_selected_l.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Syn-Nine/galaxion-trade-empire/378a32323a7546255e793843e1d1194b34e6f0ce/assets/mgfw/gui/input_selected_l.png -------------------------------------------------------------------------------- /assets/mgfw/gui/input_selected_r.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Syn-Nine/galaxion-trade-empire/378a32323a7546255e793843e1d1194b34e6f0ce/assets/mgfw/gui/input_selected_r.png -------------------------------------------------------------------------------- /assets/mgfw/gui/input_selected_t.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Syn-Nine/galaxion-trade-empire/378a32323a7546255e793843e1d1194b34e6f0ce/assets/mgfw/gui/input_selected_t.png -------------------------------------------------------------------------------- /assets/mgfw/gui/input_selected_tl.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Syn-Nine/galaxion-trade-empire/378a32323a7546255e793843e1d1194b34e6f0ce/assets/mgfw/gui/input_selected_tl.png -------------------------------------------------------------------------------- /assets/mgfw/gui/input_selected_tr.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Syn-Nine/galaxion-trade-empire/378a32323a7546255e793843e1d1194b34e6f0ce/assets/mgfw/gui/input_selected_tr.png -------------------------------------------------------------------------------- /assets/mgfw/gui/panel_base_b.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Syn-Nine/galaxion-trade-empire/378a32323a7546255e793843e1d1194b34e6f0ce/assets/mgfw/gui/panel_base_b.png -------------------------------------------------------------------------------- /assets/mgfw/gui/panel_base_bl.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Syn-Nine/galaxion-trade-empire/378a32323a7546255e793843e1d1194b34e6f0ce/assets/mgfw/gui/panel_base_bl.png -------------------------------------------------------------------------------- /assets/mgfw/gui/panel_base_br.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Syn-Nine/galaxion-trade-empire/378a32323a7546255e793843e1d1194b34e6f0ce/assets/mgfw/gui/panel_base_br.png -------------------------------------------------------------------------------- /assets/mgfw/gui/panel_base_c.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Syn-Nine/galaxion-trade-empire/378a32323a7546255e793843e1d1194b34e6f0ce/assets/mgfw/gui/panel_base_c.png -------------------------------------------------------------------------------- /assets/mgfw/gui/panel_base_c_test.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Syn-Nine/galaxion-trade-empire/378a32323a7546255e793843e1d1194b34e6f0ce/assets/mgfw/gui/panel_base_c_test.png -------------------------------------------------------------------------------- /assets/mgfw/gui/panel_base_l.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Syn-Nine/galaxion-trade-empire/378a32323a7546255e793843e1d1194b34e6f0ce/assets/mgfw/gui/panel_base_l.png -------------------------------------------------------------------------------- /assets/mgfw/gui/panel_base_r.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Syn-Nine/galaxion-trade-empire/378a32323a7546255e793843e1d1194b34e6f0ce/assets/mgfw/gui/panel_base_r.png -------------------------------------------------------------------------------- /assets/mgfw/gui/panel_base_sep.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Syn-Nine/galaxion-trade-empire/378a32323a7546255e793843e1d1194b34e6f0ce/assets/mgfw/gui/panel_base_sep.png -------------------------------------------------------------------------------- /assets/mgfw/gui/panel_base_t.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Syn-Nine/galaxion-trade-empire/378a32323a7546255e793843e1d1194b34e6f0ce/assets/mgfw/gui/panel_base_t.png -------------------------------------------------------------------------------- /assets/mgfw/gui/panel_base_tl.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Syn-Nine/galaxion-trade-empire/378a32323a7546255e793843e1d1194b34e6f0ce/assets/mgfw/gui/panel_base_tl.png -------------------------------------------------------------------------------- /assets/mgfw/gui/panel_base_tr.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Syn-Nine/galaxion-trade-empire/378a32323a7546255e793843e1d1194b34e6f0ce/assets/mgfw/gui/panel_base_tr.png -------------------------------------------------------------------------------- /assets/mgfw/gui/panel_simple_b.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Syn-Nine/galaxion-trade-empire/378a32323a7546255e793843e1d1194b34e6f0ce/assets/mgfw/gui/panel_simple_b.png -------------------------------------------------------------------------------- /assets/mgfw/gui/panel_simple_bl.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Syn-Nine/galaxion-trade-empire/378a32323a7546255e793843e1d1194b34e6f0ce/assets/mgfw/gui/panel_simple_bl.png -------------------------------------------------------------------------------- /assets/mgfw/gui/panel_simple_br.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Syn-Nine/galaxion-trade-empire/378a32323a7546255e793843e1d1194b34e6f0ce/assets/mgfw/gui/panel_simple_br.png -------------------------------------------------------------------------------- /assets/mgfw/gui/panel_simple_c.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Syn-Nine/galaxion-trade-empire/378a32323a7546255e793843e1d1194b34e6f0ce/assets/mgfw/gui/panel_simple_c.png -------------------------------------------------------------------------------- /assets/mgfw/gui/panel_simple_l.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Syn-Nine/galaxion-trade-empire/378a32323a7546255e793843e1d1194b34e6f0ce/assets/mgfw/gui/panel_simple_l.png -------------------------------------------------------------------------------- /assets/mgfw/gui/panel_simple_r.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Syn-Nine/galaxion-trade-empire/378a32323a7546255e793843e1d1194b34e6f0ce/assets/mgfw/gui/panel_simple_r.png -------------------------------------------------------------------------------- /assets/mgfw/gui/panel_simple_t.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Syn-Nine/galaxion-trade-empire/378a32323a7546255e793843e1d1194b34e6f0ce/assets/mgfw/gui/panel_simple_t.png -------------------------------------------------------------------------------- /assets/mgfw/gui/panel_simple_tl.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Syn-Nine/galaxion-trade-empire/378a32323a7546255e793843e1d1194b34e6f0ce/assets/mgfw/gui/panel_simple_tl.png -------------------------------------------------------------------------------- /assets/mgfw/gui/panel_simple_tr.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Syn-Nine/galaxion-trade-empire/378a32323a7546255e793843e1d1194b34e6f0ce/assets/mgfw/gui/panel_simple_tr.png -------------------------------------------------------------------------------- /assets/mgfw/line_shader.fs: -------------------------------------------------------------------------------- 1 | #version 100 2 | precision mediump float; 3 | 4 | varying vec4 v_color; 5 | uniform vec4 color_uniform; 6 | 7 | void main() { 8 | gl_FragColor = v_color * color_uniform; 9 | } -------------------------------------------------------------------------------- /assets/mgfw/line_shader.vs: -------------------------------------------------------------------------------- 1 | #version 100 2 | precision mediump float; 3 | 4 | attribute vec2 position; 5 | attribute vec4 color; 6 | 7 | varying vec4 v_color; 8 | 9 | uniform mat4 MVP; 10 | 11 | void main() { 12 | gl_Position = MVP * vec4(position, 0.0, 1.0); 13 | v_color = color; 14 | } -------------------------------------------------------------------------------- /assets/mgfw/mgfw_64_trim.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Syn-Nine/galaxion-trade-empire/378a32323a7546255e793843e1d1194b34e6f0ce/assets/mgfw/mgfw_64_trim.ico -------------------------------------------------------------------------------- /assets/mgfw/poly_shader.fs: -------------------------------------------------------------------------------- 1 | #version 100 2 | precision mediump float; 3 | 4 | varying vec4 v_color; 5 | uniform vec4 color_uniform; 6 | 7 | void main() { 8 | gl_FragColor = v_color * color_uniform; 9 | } -------------------------------------------------------------------------------- /assets/mgfw/poly_shader.vs: -------------------------------------------------------------------------------- 1 | #version 100 2 | precision mediump float; 3 | 4 | attribute vec2 position; 5 | attribute vec4 color; 6 | 7 | varying vec4 v_color; 8 | 9 | uniform mat4 MVP; 10 | 11 | void main() { 12 | gl_Position = MVP * vec4(position, 0.0, 1.0); 13 | v_color = color; 14 | } -------------------------------------------------------------------------------- /assets/mgfw/retro_gaming_0.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Syn-Nine/galaxion-trade-empire/378a32323a7546255e793843e1d1194b34e6f0ce/assets/mgfw/retro_gaming_0.png -------------------------------------------------------------------------------- /assets/mgfw/tex_shader.fs: -------------------------------------------------------------------------------- 1 | #version 130 2 | precision mediump float; 3 | 4 | varying vec2 v_uv; 5 | 6 | uniform sampler2D tex_sampler; 7 | uniform vec4 color_uniform; 8 | 9 | void main() { 10 | vec4 color = texture2D(tex_sampler, v_uv).rgba * color_uniform; 11 | 12 | gl_FragColor = vec4(1.0, 1.0, 0.0, 1.0); //color; 13 | gl_FragColor = color; 14 | } 15 | -------------------------------------------------------------------------------- /assets/mgfw/tex_shader.vs: -------------------------------------------------------------------------------- 1 | #version 130 2 | precision mediump float; 3 | 4 | attribute vec2 position; 5 | attribute vec2 uv; 6 | 7 | varying vec2 v_uv; 8 | 9 | uniform mat4 MVP; 10 | uniform int uniform_override_uv; 11 | uniform vec2 uniform_uv; 12 | uniform vec2 uniform_duv; 13 | 14 | void main() { 15 | gl_Position = MVP * vec4(position, 0.0, 1.0); 16 | 17 | /*vec2 nuv = uv; 18 | if (1 == uniform_override_uv) { 19 | if (uv.x < 1.0e-6) { 20 | nuv.x = uniform_uv.x; 21 | } 22 | else if (uv.x > 1.0 - 1.0e-6) { 23 | nuv.x = uniform_uv.x + uniform_duv.x; 24 | } 25 | if (uv.y < 1.0e-6) { 26 | nuv.y = uniform_uv.y; 27 | } 28 | else if (uv.y > 1.0 - 1.0e-6) { 29 | nuv.y = uniform_uv.y + uniform_duv.y; 30 | } 31 | } 32 | 33 | v_uv = nuv;*/ 34 | v_uv = uv; 35 | } 36 | -------------------------------------------------------------------------------- /assets/mgfw/ugui.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Syn-Nine/galaxion-trade-empire/378a32323a7546255e793843e1d1194b34e6f0ce/assets/mgfw/ugui.png -------------------------------------------------------------------------------- /assets/player_fighter.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Syn-Nine/galaxion-trade-empire/378a32323a7546255e793843e1d1194b34e6f0ce/assets/player_fighter.png -------------------------------------------------------------------------------- /assets/player_fighter_sm.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Syn-Nine/galaxion-trade-empire/378a32323a7546255e793843e1d1194b34e6f0ce/assets/player_fighter_sm.png -------------------------------------------------------------------------------- /assets/player_freighter.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Syn-Nine/galaxion-trade-empire/378a32323a7546255e793843e1d1194b34e6f0ce/assets/player_freighter.png -------------------------------------------------------------------------------- /assets/sel_fighter_enemy.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Syn-Nine/galaxion-trade-empire/378a32323a7546255e793843e1d1194b34e6f0ce/assets/sel_fighter_enemy.png -------------------------------------------------------------------------------- /assets/sel_fighter_player.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Syn-Nine/galaxion-trade-empire/378a32323a7546255e793843e1d1194b34e6f0ce/assets/sel_fighter_player.png -------------------------------------------------------------------------------- /assets/selector.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Syn-Nine/galaxion-trade-empire/378a32323a7546255e793843e1d1194b34e6f0ce/assets/selector.png -------------------------------------------------------------------------------- /assets/sm-desert-planet.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Syn-Nine/galaxion-trade-empire/378a32323a7546255e793843e1d1194b34e6f0ce/assets/sm-desert-planet.png -------------------------------------------------------------------------------- /assets/sm-galaxy-fade.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Syn-Nine/galaxion-trade-empire/378a32323a7546255e793843e1d1194b34e6f0ce/assets/sm-galaxy-fade.png -------------------------------------------------------------------------------- /assets/sm-lush-planet.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Syn-Nine/galaxion-trade-empire/378a32323a7546255e793843e1d1194b34e6f0ce/assets/sm-lush-planet.png -------------------------------------------------------------------------------- /assets/sm-nebula-0.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Syn-Nine/galaxion-trade-empire/378a32323a7546255e793843e1d1194b34e6f0ce/assets/sm-nebula-0.png -------------------------------------------------------------------------------- /assets/sm-nebula-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Syn-Nine/galaxion-trade-empire/378a32323a7546255e793843e1d1194b34e6f0ce/assets/sm-nebula-1.png -------------------------------------------------------------------------------- /assets/sm-nebula-2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Syn-Nine/galaxion-trade-empire/378a32323a7546255e793843e1d1194b34e6f0ce/assets/sm-nebula-2.png -------------------------------------------------------------------------------- /assets/sm-nebula-3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Syn-Nine/galaxion-trade-empire/378a32323a7546255e793843e1d1194b34e6f0ce/assets/sm-nebula-3.png -------------------------------------------------------------------------------- /assets/sm-nebula-4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Syn-Nine/galaxion-trade-empire/378a32323a7546255e793843e1d1194b34e6f0ce/assets/sm-nebula-4.png -------------------------------------------------------------------------------- /assets/sm-nebula-5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Syn-Nine/galaxion-trade-empire/378a32323a7546255e793843e1d1194b34e6f0ce/assets/sm-nebula-5.png -------------------------------------------------------------------------------- /assets/sm-ocean-planet.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Syn-Nine/galaxion-trade-empire/378a32323a7546255e793843e1d1194b34e6f0ce/assets/sm-ocean-planet.png -------------------------------------------------------------------------------- /assets/sm-volcano-planet.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Syn-Nine/galaxion-trade-empire/378a32323a7546255e793843e1d1194b34e6f0ce/assets/sm-volcano-planet.png -------------------------------------------------------------------------------- /assets/sprites.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Syn-Nine/galaxion-trade-empire/378a32323a7546255e793843e1d1194b34e6f0ce/assets/sprites.png -------------------------------------------------------------------------------- /assets/station.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Syn-Nine/galaxion-trade-empire/378a32323a7546255e793843e1d1194b34e6f0ce/assets/station.png -------------------------------------------------------------------------------- /assets/title.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Syn-Nine/galaxion-trade-empire/378a32323a7546255e793843e1d1194b34e6f0ce/assets/title.png -------------------------------------------------------------------------------- /assets/turn_order_selector.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Syn-Nine/galaxion-trade-empire/378a32323a7546255e793843e1d1194b34e6f0ce/assets/turn_order_selector.png -------------------------------------------------------------------------------- /assets/world.dat: -------------------------------------------------------------------------------- 1 | // entity id, component, component data 2 | //0,billboard,assets/iso-tileset.png 3 | //0,visible,true 4 | //0,position,256,256 5 | //0,scale,512,512 6 | //0,color,1.0,1.0,1.0 7 | 8 | 9 | -------------------------------------------------------------------------------- /build.rs: -------------------------------------------------------------------------------- 1 | // GL Generator from the Glutin examples 2 | use gl_generator::{Api, Fallbacks, Profile, Registry}; 3 | use std::env; 4 | use std::fs::File; 5 | use std::path::PathBuf; 6 | 7 | fn main() { 8 | let dest = PathBuf::from(&env::var("OUT_DIR").unwrap()); 9 | 10 | println!("cargo:rerun-if-changed=build.rs"); 11 | 12 | let mut file = File::create(&dest.join("gl_bindings.rs")).unwrap(); 13 | Registry::new(Api::Gl, (4, 2), Profile::Core, Fallbacks::All, []) 14 | .write_bindings(gl_generator::StructGenerator, &mut file) 15 | .unwrap(); 16 | } 17 | -------------------------------------------------------------------------------- /screenshots/battle-combat.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Syn-Nine/galaxion-trade-empire/378a32323a7546255e793843e1d1194b34e6f0ce/screenshots/battle-combat.gif -------------------------------------------------------------------------------- /screenshots/galaxy.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Syn-Nine/galaxion-trade-empire/378a32323a7546255e793843e1d1194b34e6f0ce/screenshots/galaxy.png -------------------------------------------------------------------------------- /screenshots/game_arch_simple.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Syn-Nine/galaxion-trade-empire/378a32323a7546255e793843e1d1194b34e6f0ce/screenshots/game_arch_simple.png -------------------------------------------------------------------------------- /screenshots/mgfw_arch_simple.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Syn-Nine/galaxion-trade-empire/378a32323a7546255e793843e1d1194b34e6f0ce/screenshots/mgfw_arch_simple.png -------------------------------------------------------------------------------- /screenshots/station.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Syn-Nine/galaxion-trade-empire/378a32323a7546255e793843e1d1194b34e6f0ce/screenshots/station.png -------------------------------------------------------------------------------- /src/game/enums.rs: -------------------------------------------------------------------------------- 1 | #![allow(dead_code)] 2 | 3 | pub const SCREEN_XRES: usize = 900; 4 | pub const SCREEN_XRES_HALF: usize = SCREEN_XRES / 2; 5 | pub const SCREEN_YRES: usize = 480; 6 | pub const SCREEN_YRES_HALF: usize = SCREEN_YRES / 2; 7 | 8 | pub const SPLIT_H: u8 = 0; 9 | pub const SPLIT_V: u8 = 1; 10 | 11 | 12 | // game enums 13 | 14 | pub const PLANET_CLASS_INVALID: u8 = 0; 15 | pub const PLANET_CLASS_LUSH: u8 = 1; 16 | pub const PLANET_CLASS_WATER: u8 = 2; 17 | pub const PLANET_CLASS_DESERT: u8 = 3; 18 | pub const PLANET_CLASS_VOLCANO: u8 = 4; 19 | 20 | pub const STATION_CLASS_INVALID: u8 = 0; 21 | pub const STATION_CLASS_PORT: u8 = 1; 22 | pub const STATION_CLASS_FEDERAL: u8 = 2; 23 | 24 | pub const RESEARCH_INVALID: u8 = 0; 25 | pub const RESEARCH_AGRICULTURE_I: u8 = 1; 26 | pub const RESEARCH_BIOLOGY_I: u8 = 2; 27 | pub const RESEARCH_ENERGY_I: u8 = 3; 28 | pub const RESEARCH_KNOWLEDGE_I: u8 = 4; 29 | pub const RESEARCH_MEDICINE_I: u8 = 5; 30 | pub const RESEARCH_MILITARY_I: u8 = 6; 31 | pub const RESEARCH_TECHNOLOGY_I: u8 = 7; 32 | pub const RESEARCH_AGRICULTURE_II: u8 = 8; 33 | pub const RESEARCH_BIOLOGY_II: u8 = 9; 34 | pub const RESEARCH_ENERGY_II: u8 = 10; 35 | pub const RESEARCH_KNOWLEDGE_II: u8 = 11; 36 | pub const RESEARCH_MEDICINE_II: u8 = 12; 37 | pub const RESEARCH_MILITARY_II: u8 = 13; 38 | pub const RESEARCH_TECHNOLOGY_II: u8 = 14; 39 | // 40 | pub const RESEARCH_COUNT: usize = 15; 41 | pub const ALL_RESEARCH_COMPLETE: u8 = RESEARCH_COUNT as u8; 42 | // 43 | pub const RESEARCH_NOT_STARTED: u8 = 0; 44 | pub const RESEARCH_IN_PROGRESS: u8 = 1; 45 | pub const RESEARCH_NOT_AVAILABLE: u8 = 2; 46 | pub const RESEARCH_COMPLETE: u8 = 3; 47 | -------------------------------------------------------------------------------- /src/game/game.rs: -------------------------------------------------------------------------------- 1 | use crate::mgfw; 2 | use super::ui; 3 | use super::state; 4 | 5 | //use std::fs::File; 6 | //use std::io::{self, BufRead, Write}; 7 | 8 | 9 | pub struct GameDataHeap { 10 | // WARNING: Anything below this line is not in cache! 11 | pub state_data: state::StateHeap, 12 | pub battle_data: state::BattleHeap, 13 | } 14 | 15 | impl Default for GameDataHeap { 16 | fn default() -> Self { 17 | GameDataHeap { 18 | state_data: state::StateHeap::new(), 19 | battle_data: state::BattleHeap::new(), 20 | } 21 | } 22 | } 23 | 24 | 25 | // cache data 26 | pub struct GameData { 27 | // system 28 | pub heap: *mut GameDataHeap, 29 | pub frame: u8, 30 | ready: bool, 31 | pub quit_requested: bool, 32 | // 33 | pub uidata: ui::UIData, 34 | pub state_cache: state::StateCache, 35 | pub battle_cache: state::BattleCache, 36 | } 37 | 38 | 39 | #[rustfmt::skip] 40 | pub fn initialize(cache: &mut GameData, heap: &mut GameDataHeap, world: &mut mgfw::ecs::World) { 41 | 42 | world.parse_world("assets/world.dat"); 43 | 44 | ui::initialize(cache, heap, world); 45 | state::initialize(cache, heap, world); 46 | 47 | ui::update_galaxy_zoom(cache, world); 48 | 49 | } 50 | 51 | 52 | pub fn quit_requested(cache: &mut GameData) -> bool { 53 | cache.quit_requested 54 | } 55 | 56 | pub fn shutdown(_cache: &mut GameData, heap: &mut GameDataHeap) { 57 | // deallocate and overwrite existing memory 58 | *heap = GameDataHeap::default(); 59 | 60 | // re-box and consume 61 | //let _temp = unsafe { Box::from_raw(cache.heap) }; 62 | } 63 | 64 | 65 | // this gets called by MGFW with input events 66 | #[rustfmt::skip] 67 | pub fn event(cache: &mut GameData, heap: &mut GameDataHeap, world: &mut mgfw::ecs::World, event_id: u8) -> bool { 68 | // pass through to the UI 69 | ui::event(cache, heap, world, event_id) 70 | } 71 | 72 | 73 | // this gets called by MGFW at 1200hz 74 | pub fn update(cache: &mut GameData, heap: &mut GameDataHeap, world: &mut mgfw::ecs::World) -> bool { 75 | 76 | let mut expect_blown = false; 77 | cache.frame = (cache.frame + 1) % 128; 78 | //let dt = 1.0 / 1200.0; 79 | 80 | if !cache.ready { 81 | if 127 == cache.frame { 82 | cache.ready = true; 83 | } 84 | return false; 85 | } 86 | 87 | expect_blown |= ui::update(cache, heap, world); 88 | 89 | expect_blown 90 | } 91 | 92 | 93 | -------------------------------------------------------------------------------- /src/game/mod.rs: -------------------------------------------------------------------------------- 1 | mod game; 2 | mod ui; 3 | mod state; 4 | pub mod enums; 5 | 6 | use crate::mgfw; 7 | 8 | pub struct GameWrapper { 9 | data: *mut game::GameData, 10 | // WARNING: Anything below this line is not in cache! 11 | } 12 | 13 | impl GameWrapper { 14 | #[rustfmt::skip] 15 | pub fn new(mgr: &mut mgfw::cache::CacheManager) -> GameWrapper { 16 | mgfw::log(format!("Constructing Game")); 17 | let data = mgr.allocate(std::mem::size_of::()) as *mut game::GameData; 18 | let cache: &mut game::GameData = unsafe { &mut *(data.offset(0)) }; 19 | cache.heap = Box::into_raw(Box::new(game::GameDataHeap::default())); 20 | GameWrapper { data } 21 | } 22 | 23 | pub fn initialize(&mut self, world: &mut mgfw::ecs::World) { 24 | mgfw::log(format!("Initializing Game")); 25 | game::initialize(self.get_cache_ref_mut(), self.get_heap_ref_mut(), world); 26 | } 27 | 28 | pub fn update(&mut self, world: &mut mgfw::ecs::World, _micros: u128) -> bool { 29 | game::update(self.get_cache_ref_mut(), self.get_heap_ref_mut(), world) 30 | } 31 | 32 | pub fn event(&mut self, world: &mut mgfw::ecs::World, event_id: u8) -> bool { 33 | game::event( 34 | self.get_cache_ref_mut(), 35 | self.get_heap_ref_mut(), 36 | world, 37 | event_id, 38 | ) 39 | } 40 | 41 | pub fn quit_requested(&mut self) -> bool { 42 | game::quit_requested(self.get_cache_ref_mut()) 43 | } 44 | 45 | pub fn shutdown(&mut self) { 46 | mgfw::log(format!("Shutdown Game")); 47 | game::shutdown(self.get_cache_ref_mut(), self.get_heap_ref_mut()); 48 | } 49 | 50 | fn get_cache_ref_mut(&self) -> &mut game::GameData { 51 | unsafe { &mut *(self.data.offset(0)) } 52 | } 53 | 54 | fn get_heap_ref_mut(&self) -> &mut game::GameDataHeap { 55 | unsafe { &mut *(self.get_cache_ref_mut().heap) } 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /src/game/ui/galaxy.rs: -------------------------------------------------------------------------------- 1 | use crate::{mgfw::ecs::ugui::Callback}; 2 | use std::collections::vec_deque::VecDeque; 3 | 4 | use super::*; 5 | 6 | 7 | pub fn build_galaxy_ui_popup(cache: &mut GameData, heap: &mut GameDataHeap, world: &mut mgfw::ecs::World) { 8 | 9 | if HOVER_SECTOR_INVALID == cache.uidata.curr_sector { return; } 10 | 11 | cache.uidata.is_menu_open = true; 12 | 13 | for i in 0..heap.state_data.ships.len() { 14 | if cache.uidata.curr_sector == heap.state_data.ships[i].location { 15 | build_galaxy_ui_location(cache, heap, world); 16 | return; 17 | } 18 | } 19 | 20 | build_galaxy_ui_navigate(cache, heap, world); 21 | } 22 | 23 | pub fn build_galaxy_ui_location(cache: &mut GameData, heap: &mut GameDataHeap, world: &mut mgfw::ecs::World) { 24 | 25 | cache.uidata.curr_menu = MENU_GALAXY_LOCATION; 26 | world.entity_set_visibility(cache.uidata.galaxy_map as usize, true); 27 | world.entity_set_visibility(cache.uidata.galaxy_geom as usize, true); 28 | world.entity_set_visibility(cache.uidata.galaxy_territory as usize, true); 29 | world.entity_set_visibility(cache.uidata.galaxy_hover_ent as usize, true); 30 | world.entity_set_visibility(cache.uidata.planet_menu_tilemap as usize, false); 31 | world.entity_set_visibility(cache.uidata.dim_ent as usize, true); 32 | world.ugui.clear(); 33 | // full window grid 34 | let grid = mgfw::ecs::uigrid::new(0.0, 0.0, SCREEN_XRES as f32, SCREEN_YRES as f32); 35 | 36 | let sidx = cache.uidata.curr_sector as usize; 37 | 38 | let mut ops = 3; 39 | if heap.state_data.sectors[sidx].station_class != STATION_CLASS_INVALID { ops += 2; } 40 | if heap.state_data.sectors[sidx].planet_class != PLANET_CLASS_INVALID { ops += 2; } 41 | 42 | 43 | // split for 3 primary columns 44 | let main = grid.split_vec(SPLIT_H, vec![0.42, 0.58]); 45 | let mut main = main[1].clone(); 46 | let mw = main.x1 - main.x0; 47 | main.x0 = cache.uidata.screen_hover_x + 5.0; 48 | main.x1 = main.x0 + mw; 49 | let mh = 16.0 + ops as f32 * 26.0; 50 | main.y0 = cache.uidata.screen_hover_y; 51 | main.y1 = main.y0 + mh; 52 | if main.x1 > SCREEN_XRES as f32 - 1.0 { 53 | main.x1 = SCREEN_XRES as f32 - 1.0; 54 | main.x0 = main.x1 - mw; 55 | } 56 | if main.x0 < 1.0 { 57 | main.x0 = 1.0; 58 | main.x1 = main.x0 + mw; 59 | } 60 | if main.y1 > SCREEN_YRES as f32 - 1.0 { 61 | main.y1 = SCREEN_YRES as f32 - 1.0; 62 | main.y0 = main.y1 - mh; 63 | } 64 | if main.y0 < 1.0 { 65 | main.y0 = 1.0; 66 | main.y1 = main.y0 + mh; 67 | } 68 | 69 | // planet menu 70 | let menu_tab_group = world.ugui.add(ugui::PARENT_WINDOW, ugui::tab_group(&main)); 71 | let menu_tab = world.ugui.add(menu_tab_group, ugui::tab(&format!("Sector {}", sidx)).highlight(true)); 72 | cache.uidata.menu_grid = main.clone(); 73 | 74 | // options 75 | let subgrid = main.tab_pad(); 76 | let vsplit = subgrid.split_even(SPLIT_V, ops); 77 | 78 | // add some vertical padding to the buttons 79 | let mut vsplit_pad: Vec:: = Vec::new(); 80 | for i in 0..vsplit.len() { 81 | let mut g = vsplit[i].clone(); 82 | g.y0 += 2.0; 83 | vsplit_pad.push(g); 84 | } 85 | 86 | vsplit_pad[0].y0 -= 4.0; 87 | world.ugui.add(menu_tab, ugui::label(&vsplit_pad[0], &format!("House {}", heap.state_data.house_names[heap.state_data.sectors[cache.state_cache.location as usize].house as usize])).enabled(false)); 88 | 89 | let mut idx = 1; 90 | if heap.state_data.sectors[sidx].station_class != STATION_CLASS_INVALID { 91 | vsplit_pad[idx].y0 -= 5.0; 92 | vsplit_pad[idx].y1 -= 5.0; 93 | world.ugui.add(menu_tab, ugui::label(&vsplit_pad[idx], &format!("Station")).highlight(true)); 94 | vsplit_pad[idx+1].y0 -= 9.0; 95 | vsplit_pad[idx+1].y1 -= 2.0; 96 | world.ugui.add(menu_tab, ugui::button(&vsplit_pad[idx+1], &format!("Dock")).callback(CALLBACK_GALAXY_DOCK)); 97 | idx += 2; 98 | } 99 | if heap.state_data.sectors[sidx].planet_class != PLANET_CLASS_INVALID { 100 | vsplit_pad[idx].y0 -= 5.0; 101 | vsplit_pad[idx].y1 -= 5.0; 102 | world.ugui.add(menu_tab, ugui::label(&vsplit_pad[idx], &format!("Planet")).highlight(true)); 103 | vsplit_pad[idx+1].y0 -= 9.0; 104 | vsplit_pad[idx+1].y1 -= 2.0; 105 | if state::HOUSE_PLAYER == heap.state_data.sectors[sidx].house { 106 | world.ugui.add(menu_tab, ugui::button(&vsplit_pad[idx+1], &format!("Land")).callback(CALLBACK_GALAXY_LAND)); 107 | } else { 108 | world.ugui.add(menu_tab, ugui::button(&vsplit_pad[idx+1], &format!("Attack")).callback(CALLBACK_LAUNCH_BATTLE));//CALLBACK_GALAXY_CLAIM)); 109 | } 110 | idx += 2; 111 | } 112 | vsplit_pad[idx].y0 -= 5.0; 113 | vsplit_pad[idx].y1 -= 5.0; 114 | world.ugui.add(menu_tab, ugui::label(&vsplit_pad[idx], &format!("Freighter")).highlight(true)); 115 | vsplit_pad[idx+1].y0 -= 9.0; 116 | world.ugui.add(menu_tab, ugui::button(&vsplit_pad[idx+1], &format!("Status")).callback(CALLBACK_GALAXY_STATS)); 117 | 118 | // 119 | build_galaxy_ui_year(cache, world); 120 | build_galaxy_ui_quit(cache, world); 121 | 122 | } 123 | 124 | 125 | pub fn build_galaxy_ui_navigate(cache: &mut GameData, heap: &mut GameDataHeap, world: &mut mgfw::ecs::World) { 126 | 127 | cache.uidata.curr_menu = MENU_GALAXY_NAVIGATE; 128 | world.entity_set_visibility(cache.uidata.galaxy_map as usize, true); 129 | world.entity_set_visibility(cache.uidata.galaxy_geom as usize, true); 130 | world.entity_set_visibility(cache.uidata.galaxy_territory as usize, true); 131 | world.entity_set_visibility(cache.uidata.galaxy_hover_ent as usize, true); 132 | world.entity_set_visibility(cache.uidata.planet_menu_tilemap as usize, false); 133 | world.entity_set_visibility(cache.uidata.dim_ent as usize, true); 134 | world.ugui.clear(); 135 | // full window grid 136 | let grid = mgfw::ecs::uigrid::new(0.0, 0.0, SCREEN_XRES as f32, SCREEN_YRES as f32); 137 | 138 | // split for 3 primary columns 139 | let main = grid.split_vec(SPLIT_H, vec![0.42, 0.58]); 140 | let mut main = main[1].clone(); 141 | let mw = main.x1 - main.x0; 142 | main.x0 = cache.uidata.screen_hover_x + 5.0; 143 | main.x1 = main.x0 + mw; 144 | let mh = 80.0; 145 | main.y0 = cache.uidata.screen_hover_y; 146 | main.y1 = main.y0 + mh; 147 | 148 | if main.x1 > SCREEN_XRES as f32 - 1.0 { 149 | main.x1 = SCREEN_XRES as f32 - 1.0; 150 | main.x0 = main.x1 - mw; 151 | } 152 | if main.x0 < 0.0 { 153 | main.x0 = 0.0; 154 | main.x1 = main.x0 + mw; 155 | } 156 | if main.y1 > SCREEN_YRES as f32 - 1.0 { 157 | main.y1 = SCREEN_YRES as f32 - 1.0; 158 | main.y0 = main.y1 - mh; 159 | } 160 | if main.y0 < 0.0 { 161 | main.y0 = 0.0; 162 | main.y1 = main.y0 + mh; 163 | } 164 | 165 | // planet menu 166 | let menu_tab_group = world.ugui.add(ugui::PARENT_WINDOW, ugui::tab_group(&main)); 167 | let menu_tab = world.ugui.add(menu_tab_group, ugui::tab(&format!("Sector {}", cache.uidata.curr_sector)).highlight(true)); 168 | cache.uidata.menu_grid = main.clone(); 169 | 170 | // build nav path 171 | let path = state::find_path(heap, cache.state_cache.location as usize, cache.uidata.curr_sector as usize, false); 172 | heap.state_data.ships[0].nav_deque = VecDeque::new(); 173 | if 1 < path.len() { 174 | for i in 0..path.len()-1 { 175 | heap.state_data.ships[0].nav_deque.push_front(path[i]); 176 | } 177 | } 178 | 179 | // options 180 | let subgrid = main.tab_pad().split(SPLIT_V, 0.4); 181 | 182 | world.ugui.add(menu_tab, ugui::label(&subgrid[0], &format!("House {}", heap.state_data.house_names[heap.state_data.sectors[cache.uidata.curr_sector as usize].house as usize])).enabled(false)); 183 | 184 | world.ugui.add(menu_tab, ugui::button(&subgrid[1], &format!("Navigate")).callback_i1(CALLBACK_GALAXY_NAVIGATE, cache.uidata.curr_sector as i32, path.len() as i32 - 1)); 185 | 186 | // path geometry 187 | let c1 = mgfw::ecs::Color::new(1.0, 0.0, 1.0, 1.0); 188 | 189 | let mut pdata: Vec = Vec::new(); 190 | let mut cdata: Vec = Vec::new(); 191 | 192 | for i in 0..(path.len()-1) { 193 | let idx0 = path[i]; 194 | let idx1 = path[i + 1]; 195 | let x0 = heap.state_data.sectors[idx0].x; 196 | let y0 = heap.state_data.sectors[idx0].y - 0.5; 197 | let x1 = heap.state_data.sectors[idx1].x; 198 | let y1 = heap.state_data.sectors[idx1].y - 0.5; 199 | add_connection(&mut pdata, &mut cdata, x0, y0, x1, y1, &c1); 200 | } 201 | 202 | for i in 0..pdata.len() { 203 | pdata[i].x = pdata[i].x / 960.0; 204 | pdata[i].y = pdata[i].y / 540.0; 205 | } 206 | 207 | world.entity_set_line_buffer(cache.uidata.galaxy_path as usize, &pdata, &cdata); 208 | world.entity_set_visibility(cache.uidata.galaxy_path as usize, true); 209 | update_galaxy_zoom(cache, world); 210 | 211 | // 212 | build_galaxy_ui_year(cache, world); 213 | build_galaxy_ui_quit(cache, world); 214 | 215 | } 216 | 217 | 218 | pub fn build_galaxy_ui_year(cache: &mut GameData, world: &mut mgfw::ecs::World) { 219 | 220 | let grid = mgfw::ecs::uigrid::new(0.0, 0.0, 100.0, 25.0); 221 | let panel = world.ugui.add(ugui::PARENT_WINDOW, ugui::panel(&grid)); 222 | let grid = grid.pad(); 223 | let hsplit = grid.split(SPLIT_H, 0.4); 224 | world.ugui.add(panel, ugui::label(&hsplit[0], &format!("Year:")).halign(HALIGN_LEFT)); 225 | cache.uidata.galaxy_ui_year = world.ugui.add(panel, ugui::label(&hsplit[1], &format!("{} ", cache.state_cache.year)).halign(HALIGN_RIGHT)) as u8; 226 | 227 | } 228 | 229 | pub fn build_galaxy_ui_quit(cache: &mut GameData, world: &mut mgfw::ecs::World) { 230 | 231 | let grid = mgfw::ecs::uigrid::new(SCREEN_XRES as f32 - 100.0, 0.0, 100.0, 25.0); 232 | world.ugui.add(ugui::PARENT_WINDOW, ugui::button(&grid, &format!("Quit Game")).callback(CALLBACK_QUIT_GAME_POPUP)); 233 | } 234 | 235 | pub fn build_galaxy_ui_quit_confirm(cache: &mut GameData, world: &mut mgfw::ecs::World) { 236 | 237 | cache.uidata.curr_menu = MENU_QUIT_CONFIRM; 238 | world.entity_set_visibility(cache.uidata.dim_ent as usize, true); 239 | world.ugui.clear(); 240 | 241 | // diplomacy menu 242 | let grid = mgfw::ecs::uigrid::new(0.0, 0.0, SCREEN_XRES as f32, SCREEN_YRES as f32); 243 | let main = grid.split_vec(SPLIT_H, vec![0.35, 0.65]); 244 | 245 | let vsplit = main[1].split_vec(SPLIT_V, vec![0.4, 0.6]); 246 | let menu_tab_group = world.ugui.add(ugui::PARENT_WINDOW, ugui::tab_group(&vsplit[1])); 247 | let menu_tab = world.ugui.add(menu_tab_group, ugui::tab(&format!("Quit Game")).highlight(true)); 248 | cache.uidata.menu_grid = vsplit[1].clone(); 249 | 250 | let subgrid = vsplit[1].tab_pad().pad(); 251 | 252 | let mut vsplit = subgrid.split_even(SPLIT_V, 3); 253 | world.ugui.add(menu_tab, ugui::label(&vsplit[0], &format!("Are you sure you want to quit?")).highlight(true)); 254 | 255 | vsplit[2].y0 -= 12.0; 256 | let mut hsplit = vsplit[2].split_even(SPLIT_H, 2); 257 | hsplit[0].x1 -= 1.0; 258 | hsplit[1].x0 += 1.0; 259 | world.ugui.add(menu_tab, ugui::button(&hsplit[0], &format!("Cancel")).callback(CALLBACK_QUIT_GAME_POPUP_CANCEL)); 260 | world.ugui.add(menu_tab, ugui::button(&hsplit[1], &format!("Quit Game")).callback(CALLBACK_QUIT_GAME)); 261 | 262 | cache.uidata.is_menu_open = true; 263 | 264 | } 265 | 266 | 267 | pub fn build_galaxy_ui_freighter_status(cache: &mut GameData, heap: &mut GameDataHeap, world: &mut mgfw::ecs::World) { 268 | 269 | cache.uidata.curr_menu = MENU_GALAXY_FREIGHTER_STATUS; 270 | //world.entity_set_visibility(cache.uidata.dim_ent as usize, false); 271 | world.ugui.clear(); 272 | // full window grid 273 | let grid = mgfw::ecs::uigrid::new(0.0, 0.0, SCREEN_XRES as f32, SCREEN_YRES as f32); 274 | 275 | // split for 3 primary columns 276 | let main = grid.split_vec(SPLIT_H, vec![0.35, 0.65]); 277 | 278 | let vsplit = main[1].split_vec(SPLIT_V, vec![0.22, 0.78]); 279 | 280 | // planet menu 281 | let menu_tab_group = world.ugui.add(ugui::PARENT_WINDOW, ugui::tab_group(&vsplit[1])); 282 | let menu_tab = world.ugui.add(menu_tab_group, ugui::tab(&format!("Freighter Status")).highlight(true)); 283 | cache.uidata.menu_grid = vsplit[1].clone(); 284 | 285 | // options 286 | let mut subsplit = vsplit[1].tab_pad().pad().split_even(SPLIT_V, 13); 287 | 288 | world.ugui.add(menu_tab, ugui::label(&subsplit[0], &format!("Status of Ship Cargo Holds")).highlight(true)); 289 | 290 | // top half 291 | let hsplit = subsplit[1].split_even(SPLIT_H, 3); 292 | world.ugui.add(menu_tab, ugui::label(&hsplit[0], &format!("Cargo:")).halign(HALIGN_LEFT).highlight(true)); 293 | world.ugui.add(menu_tab, ugui::label(&hsplit[1], &format!("Qty:")).halign(HALIGN_RIGHT).highlight(true)); 294 | world.ugui.add(menu_tab, ugui::label(&hsplit[2], &format!("Holds:")).halign(HALIGN_RIGHT).highlight(true)); 295 | 296 | let hold_colonists = heap.state_data.ships[0].hold_colonists; 297 | let hold_bios = heap.state_data.ships[0].hold_bios; 298 | let hold_fuel = heap.state_data.ships[0].hold_fuel; 299 | let hold_ice = heap.state_data.ships[0].hold_ice; 300 | let hold_mach = heap.state_data.ships[0].hold_mach; 301 | let hold_meds = heap.state_data.ships[0].hold_meds; 302 | // 303 | let ratio_colonists = 0.005; 304 | let ratio_bios = 0.003; 305 | let ratio_ice = 0.004; 306 | let ratio_fuel = 0.002; 307 | let ratio_mach = 0.003; 308 | let ratio_meds = 0.001; 309 | 310 | let hold_tot = hold_colonists as f32 * ratio_colonists + hold_bios as f32 * ratio_bios + hold_fuel as f32 * ratio_fuel + hold_ice as f32 * ratio_ice + hold_mach as f32 * ratio_mach + hold_meds as f32 * ratio_meds; 311 | 312 | // 313 | let hsplit = subsplit[2].split_even(SPLIT_H, 3); 314 | world.ugui.add(menu_tab, ugui::label(&hsplit[0], &format!("Colonists")).halign(HALIGN_LEFT)); 315 | world.ugui.add(menu_tab, ugui::label(&hsplit[1], &format!("{}", hold_colonists)).halign(HALIGN_RIGHT)) as u8; 316 | world.ugui.add(menu_tab, ugui::label(&hsplit[2], &format!("{:.2}", hold_colonists as f32 * ratio_colonists)).halign(HALIGN_RIGHT)) as u8; 317 | // 318 | let hsplit = subsplit[3].split_even(SPLIT_H, 3); 319 | world.ugui.add(menu_tab, ugui::label(&hsplit[0], &format!("Biologics")).halign(HALIGN_LEFT)); 320 | world.ugui.add(menu_tab, ugui::label(&hsplit[1], &format!("{}", hold_bios)).halign(HALIGN_RIGHT)) as u8; 321 | world.ugui.add(menu_tab, ugui::label(&hsplit[2], &format!("{:.2}", hold_bios as f32 * ratio_bios)).halign(HALIGN_RIGHT)) as u8; 322 | // 323 | let hsplit = subsplit[4].split_even(SPLIT_H, 3); 324 | world.ugui.add(menu_tab, ugui::label(&hsplit[0], &format!("Fuel")).halign(HALIGN_LEFT)); 325 | world.ugui.add(menu_tab, ugui::label(&hsplit[1], &format!("{}", hold_fuel)).halign(HALIGN_RIGHT)) as u8; 326 | world.ugui.add(menu_tab, ugui::label(&hsplit[2], &format!("{:.2}", hold_fuel as f32 * ratio_fuel)).halign(HALIGN_RIGHT)) as u8; 327 | // 328 | let hsplit = subsplit[5].split_even(SPLIT_H, 3); 329 | world.ugui.add(menu_tab, ugui::label(&hsplit[0], &format!("Ice")).halign(HALIGN_LEFT)); 330 | world.ugui.add(menu_tab, ugui::label(&hsplit[1], &format!("{}", hold_ice)).halign(HALIGN_RIGHT)) as u8; 331 | world.ugui.add(menu_tab, ugui::label(&hsplit[2], &format!("{:.2}", hold_ice as f32 * ratio_ice)).halign(HALIGN_RIGHT)) as u8; 332 | // 333 | let hsplit = subsplit[6].split_even(SPLIT_H, 3); 334 | world.ugui.add(menu_tab, ugui::label(&hsplit[0], &format!("Machinery")).halign(HALIGN_LEFT)); 335 | world.ugui.add(menu_tab, ugui::label(&hsplit[1], &format!("{}", hold_mach)).halign(HALIGN_RIGHT)) as u8; 336 | world.ugui.add(menu_tab, ugui::label(&hsplit[2], &format!("{:.2}", hold_mach as f32 * ratio_mach)).halign(HALIGN_RIGHT)) as u8; 337 | // 338 | let hsplit = subsplit[7].split_even(SPLIT_H, 3); 339 | world.ugui.add(menu_tab, ugui::label(&hsplit[0], &format!("Medicine")).halign(HALIGN_LEFT)); 340 | world.ugui.add(menu_tab, ugui::label(&hsplit[1], &format!("{}", hold_meds)).halign(HALIGN_RIGHT)) as u8; 341 | world.ugui.add(menu_tab, ugui::label(&hsplit[2], &format!("{:.2}", hold_meds as f32 * ratio_meds)).halign(HALIGN_RIGHT)) as u8; 342 | // 343 | world.ugui.add(menu_tab, ugui::label(&subsplit[8], &format!("Total: {:.2}/{}", hold_tot, heap.state_data.ships[0].holds)).halign(HALIGN_RIGHT)) as u8; 344 | 345 | let hsplit = subsplit[9].split_even(SPLIT_H, 2); 346 | world.ugui.add(menu_tab, ugui::label(&hsplit[0], &format!("Cash on Hand:")).halign(HALIGN_LEFT).highlight(true)); 347 | world.ugui.add(menu_tab, ugui::label(&hsplit[1], &format!("{}", get_cash_string(cache.state_cache.cash))).halign(HALIGN_RIGHT).highlight(true)); 348 | 349 | let hsplit = subsplit[10].split_even(SPLIT_H, 2); 350 | world.ugui.add(menu_tab, ugui::label(&hsplit[0], &format!("Fighters in Hangar:")).halign(HALIGN_LEFT).highlight(true)); 351 | world.ugui.add(menu_tab, ugui::label(&hsplit[1], &format!("{}", heap.state_data.ships[0].fighters)).halign(HALIGN_RIGHT).highlight(true)); 352 | 353 | subsplit[12].y0 = subsplit[12].y1 - 22.0; 354 | world.ugui.add(menu_tab, ugui::button(&subsplit[12], &format!("Close")).callback(CALLBACK_GALAXY_CLOSE_STATS)); 355 | 356 | cache.uidata.is_menu_open = true; 357 | 358 | } 359 | 360 | 361 | pub fn check_callback_galaxy(cache: &mut GameData, heap: &mut GameDataHeap, world: &mut mgfw::ecs::World, c: &Callback) -> bool { 362 | match c.id { 363 | CALLBACK_GALAXY_LAND => build_planet_ui_main(cache, heap, world), 364 | CALLBACK_GALAXY_DOCK => build_station_ui_main(cache, heap, world), 365 | CALLBACK_GALAXY_STATS => build_galaxy_ui_freighter_status(cache, heap, world), 366 | CALLBACK_GALAXY_CLOSE_STATS => { 367 | world.ugui.clear(); 368 | build_galaxy_ui_year(cache, world); 369 | build_galaxy_ui_quit(cache, world); 370 | cache.uidata.is_menu_open = false; 371 | world.entity_set_visibility(cache.uidata.dim_ent as usize, false); 372 | cache.uidata.curr_menu = MENU_NONE; 373 | } 374 | CALLBACK_GALAXY_NAVIGATE => { 375 | heap.state_data.ships[0].animating = true; 376 | heap.state_data.ships[0].animating_ratio = 0.0; 377 | world.entity_set_visibility(cache.uidata.dim_ent as usize, false); 378 | world.ugui.clear(); 379 | build_galaxy_ui_year(cache, world); 380 | build_galaxy_ui_quit(cache, world); 381 | /*/ 382 | state::game_step(cache, heap, world, c.idata1); 383 | cache.state_cache.location = c.idata0 as u8; 384 | heap.state_data.ships[0].location = cache.state_cache.location; 385 | world.entity_set_visibility(cache.uidata.dim_ent as usize, false); 386 | world.entity_set_visibility(cache.uidata.galaxy_path as usize, false); 387 | build_galaxy_ui_popup(cache, heap, world);*/ 388 | } 389 | CALLBACK_LAUNCH_BATTLE => { 390 | build_battle_ui_base(cache, heap, world); 391 | battle_launch(cache, heap, world); 392 | } 393 | CALLBACK_QUIT_GAME_POPUP => { 394 | build_galaxy_ui_quit_confirm(cache, world); 395 | } 396 | CALLBACK_QUIT_GAME_POPUP_CANCEL => { 397 | world.ugui.clear(); 398 | build_galaxy_ui_year(cache, world); 399 | build_galaxy_ui_quit(cache, world); 400 | cache.uidata.is_menu_open = false; 401 | world.entity_set_visibility(cache.uidata.dim_ent as usize, false); 402 | cache.uidata.curr_menu = MENU_NONE; 403 | } 404 | _ => return false, 405 | } 406 | true 407 | } 408 | 409 | pub fn update(cache: &mut GameData, heap: &mut GameDataHeap, world: &mut mgfw::ecs::World) { 410 | 411 | if !heap.state_data.ships[0].animating { 412 | for i in 0..heap.state_data.ships.len() { 413 | let e = cache.uidata.galaxy_ship_entities as usize + i; 414 | world.entity_set_visibility(e, true); 415 | let idx = heap.state_data.ships[i].location as usize; 416 | let gx = heap.state_data.sectors[idx].x; 417 | let gy = heap.state_data.sectors[idx].y; 418 | let (sx, sy) = get_galaxy_to_screen_xy(cache, world, gx, gy); 419 | world.entity_set_position_xy(e, sx, sy); 420 | } 421 | 422 | } else { 423 | 424 | // update animations 425 | let mut delta = (1.0 - heap.state_data.ships[0].animating_ratio) * 0.008; 426 | if delta < 0.001 { delta = 0.001; } 427 | 428 | let base_r = heap.state_data.ships[0].animating_ratio; 429 | heap.state_data.ships[0].animating_ratio = heap.state_data.ships[0].animating_ratio + delta; 430 | let r = heap.state_data.ships[0].animating_ratio; 431 | 432 | let idx = heap.state_data.ships[0].location as usize; 433 | let gx = heap.state_data.sectors[idx].x; 434 | let gy = heap.state_data.sectors[idx].y; 435 | let (sx0, sy0) = get_galaxy_to_screen_xy(cache, world, gx, gy); 436 | 437 | let idx = heap.state_data.ships[0].nav_deque[0]; 438 | let gx = heap.state_data.sectors[idx].x; 439 | let gy = heap.state_data.sectors[idx].y; 440 | let (sx1, sy1) = get_galaxy_to_screen_xy(cache, world, gx, gy); 441 | 442 | let sx = sx0 + (sx1 - sx0) * r; 443 | let sy = sy0 + (sy1 - sy0) * r; 444 | let e = cache.uidata.galaxy_ship_entities as usize + 0; 445 | world.entity_set_position_xy(e, sx, sy); 446 | 447 | /*let psx = (sx0 + (sx1 - sx0) * base_r) - SCREEN_XRES_HALF as f32; 448 | let psy = (sy0 + (sy1 - sy0) * base_r) - SCREEN_YRES_HALF as f32; 449 | let qsx = (sx0 + (sx1 - sx0) * r) - SCREEN_XRES_HALF as f32; 450 | let qsy = (sy0 + (sy1 - sy0) * r) - SCREEN_YRES_HALF as f32; 451 | let pmag = psx * psx + psy * psy; 452 | let qmag = qsx * qsx + qsy * qsy; 453 | 454 | if qmag > pmag { 455 | let z = get_cam_zoom_z(cache); 456 | let dx = (sx1 - sx0) * (r - base_r) / z; 457 | let dy = (sy1 - sy0) * (r - base_r) / z; 458 | cache.uidata.zoom_cam_x += dx * 0.5; 459 | cache.uidata.zoom_cam_y += dy * 0.5; 460 | update_galaxy_zoom(cache, world); 461 | }*/ 462 | 463 | 464 | /*let mut alpha = r; 465 | if 1.0 < alpha { alpha = 1.0; } 466 | world.entity_set_alpha(e, alpha);*/ 467 | 468 | if (1.0 - r) < 0.01 { 469 | state::game_step(cache, heap, world, 1); 470 | world.ugui.set_text(cache.uidata.galaxy_ui_year as usize, &format!("{}", cache.state_cache.year)); 471 | world.ugui.force_reconstruct(cache.uidata.galaxy_ui_year as usize); 472 | 473 | cache.state_cache.location = idx as u8; 474 | heap.state_data.ships[0].nav_deque.pop_front(); 475 | heap.state_data.ships[0].location = cache.state_cache.location; 476 | heap.state_data.ships[0].animating_ratio = 0.0; 477 | //world.entity_set_alpha(e, 1.0); 478 | 479 | if heap.state_data.ships[0].nav_deque.is_empty() { 480 | heap.state_data.ships[0].animating = false; 481 | world.entity_set_visibility(cache.uidata.galaxy_path as usize, false); 482 | build_galaxy_ui_popup(cache, heap, world); 483 | } 484 | } 485 | } 486 | 487 | } -------------------------------------------------------------------------------- /src/main.rs: -------------------------------------------------------------------------------- 1 | mod game; 2 | mod mgfw; 3 | 4 | const TITLE: &str = "Galaxion Trade Empire v0.1"; 5 | const XRES: i32 = game::enums::SCREEN_XRES as i32; 6 | const YRES: i32 = game::enums::SCREEN_YRES as i32; 7 | 8 | 9 | fn main() { 10 | let el = glutin::event_loop::EventLoop::new(); 11 | let mut core = mgfw::Core::new(TITLE, XRES, YRES, &el); 12 | 13 | el.run(move |event, _, control_flow| { 14 | core.check_events(&event); 15 | if core.ready_to_quit() { 16 | *control_flow = glutin::event_loop::ControlFlow::Exit; 17 | } 18 | }); 19 | } 20 | -------------------------------------------------------------------------------- /src/mgfw/cache/mod.rs: -------------------------------------------------------------------------------- 1 | const CACHE_SZ: usize = 64 * 1024 * 2; 2 | 3 | use super::log; 4 | 5 | struct CacheManagerHeader { 6 | start: usize, 7 | loading: i32, 8 | } 9 | 10 | pub struct CacheManager { 11 | data: std::boxed::Box<[u8; CACHE_SZ]>, 12 | // WARNING: Anything below this line is not in cache! 13 | } 14 | 15 | #[allow(dead_code)] 16 | impl CacheManager { 17 | pub fn new() -> CacheManager { 18 | log(format!("Constructing CacheManager")); 19 | let mut data = Box::new([0; CACHE_SZ]); 20 | let header = unsafe { &mut *(data.as_mut_ptr().offset(0) as *mut CacheManagerHeader) }; 21 | header.start = std::mem::size_of::(); 22 | 23 | if cfg!(debug_assertions) { 24 | // artificially pre-load cache in debug mode 25 | header.start += 1024; 26 | } 27 | 28 | CacheManager { data } 29 | } 30 | 31 | pub fn allocate(&mut self, sz_bytes: usize) -> *mut u8 { 32 | unsafe { 33 | let header = &mut *(self.data.as_mut_ptr().offset(0) as *mut CacheManagerHeader); 34 | if !(header.start + sz_bytes <= CACHE_SZ) { 35 | log(format!( 36 | "WARNING: Attempting to allocate cache past size limit" 37 | )); 38 | } 39 | assert!(header.start + sz_bytes <= CACHE_SZ); 40 | 41 | let ret = self.data.as_mut_ptr().offset(header.start as isize) as *mut u8; 42 | header.start += sz_bytes; 43 | log(format!("CacheManager: Allocated {} bytes", sz_bytes)); 44 | 45 | header.loading = (header.start as f32 * 100.0 / CACHE_SZ as f32) as i32; 46 | const LOAD_LIMIT_PERCENT: i32 = 80; 47 | if LOAD_LIMIT_PERCENT < header.loading { 48 | log(format!( 49 | "WARNING: Cache Loading {} Bytes, ({}%) exceeds Load Limit ({}%)", 50 | header.start, header.loading, LOAD_LIMIT_PERCENT 51 | )); 52 | } 53 | 54 | ret 55 | } 56 | } 57 | 58 | pub fn print_loading(&mut self) { 59 | let header = unsafe { &*(self.data.as_ptr().offset(0) as *const CacheManagerHeader) }; 60 | log(format!( 61 | "Cache Loading: {} Bytes, {}%", 62 | header.start, header.loading 63 | )); 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /src/mgfw/ecs/component_angle.rs: -------------------------------------------------------------------------------- 1 | use super::*; 2 | use crate::mgfw::log; 3 | 4 | #[derive(Debug, Copy, Clone)] 5 | pub struct Angle { 6 | pub x: f32, 7 | } 8 | 9 | pub struct AngleComponentManager { 10 | data: *mut Angle, 11 | // WARNING: Anything below this line is not in cache! 12 | } 13 | 14 | #[allow(dead_code)] 15 | impl AngleComponentManager { 16 | pub fn new(mgr: &mut CacheManager) -> AngleComponentManager { 17 | log(format!("Constructing AngleComponentManager")); 18 | let sz_bytes = std::mem::size_of::() * ENTITY_SZ; 19 | AngleComponentManager { 20 | data: mgr.allocate(sz_bytes) as *mut Angle, 21 | } 22 | } 23 | 24 | pub fn clear(&mut self) { 25 | for i in 0..ENTITY_SZ { 26 | self.set_angle(i, 0.0); 27 | } 28 | } 29 | 30 | pub fn set_angle(&self, idx: usize, x: f32) { 31 | let pos = self.get_data_ref_mut(idx); 32 | pos.x = x; 33 | } 34 | 35 | pub fn get_angle(&self, idx: usize) -> f32 { 36 | let pos = self.get_data_ref(idx); 37 | pos.x 38 | } 39 | 40 | pub fn get_data_ref_mut(&self, idx: usize) -> &mut Angle { 41 | assert!(idx < ENTITY_SZ); 42 | unsafe { &mut *(self.data.offset(idx as isize)) } 43 | } 44 | 45 | pub fn get_data_ref(&self, idx: usize) -> &Angle { 46 | assert!(idx < ENTITY_SZ); 47 | unsafe { &*(self.data.offset(idx as isize)) } 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /src/mgfw/ecs/component_color.rs: -------------------------------------------------------------------------------- 1 | use super::*; 2 | use crate::mgfw::log; 3 | 4 | #[derive(Debug, Copy, Clone)] 5 | pub struct Color { 6 | pub r: f32, 7 | pub g: f32, 8 | pub b: f32, 9 | pub a: f32, 10 | } 11 | 12 | impl Default for Color { 13 | fn default() -> Self { 14 | Color { r: 1.0, g: 1.0, b: 1.0, a: 1.0 } 15 | } 16 | } 17 | 18 | 19 | impl Color { 20 | pub fn new(r: f32, g: f32, b: f32, a: f32) -> Color { 21 | Color {r, g, b, a} 22 | } 23 | } 24 | 25 | pub struct ColorComponentManager { 26 | data: *mut Color, 27 | // WARNING: Anything below this line is not in cache! 28 | } 29 | 30 | #[allow(dead_code)] 31 | impl ColorComponentManager { 32 | pub fn new(mgr: &mut CacheManager) -> ColorComponentManager { 33 | log(format!("Constructing ColorComponentManager")); 34 | let sz_bytes = std::mem::size_of::() * ENTITY_SZ; 35 | let data = mgr.allocate(sz_bytes) as *mut Color; 36 | 37 | // default init colors to opaque white 38 | for i in 0..ENTITY_SZ { 39 | let p = unsafe { &mut *(data.offset(i as isize)) }; 40 | p.r = 1.0; 41 | p.g = 1.0; 42 | p.b = 1.0; 43 | p.a = 1.0; 44 | } 45 | 46 | ColorComponentManager { data } 47 | } 48 | 49 | pub fn clear(&mut self) { 50 | for i in 0..ENTITY_SZ { 51 | self.set_color_rgba(i, 1.0, 1.0, 1.0, 1.0); 52 | } 53 | } 54 | 55 | pub fn set_color(&self, idx: usize, color: Color) { 56 | self.set_color_rgba(idx, color.r, color.g, color.b, color.a); 57 | } 58 | 59 | pub fn set_color_rgba(&self, idx: usize, r: f32, g: f32, b: f32, a: f32) { 60 | let clr = self.get_data_ref_mut(idx); 61 | clr.r = r; 62 | clr.g = g; 63 | clr.b = b; 64 | clr.a = a; 65 | } 66 | 67 | pub fn get_color(&self, idx: usize) -> Color { 68 | self.get_data_ref(idx).clone() 69 | } 70 | 71 | pub fn set_alpha(&self, idx: usize, alpha: f32) { 72 | let clr = self.get_data_ref_mut(idx); 73 | clr.a = alpha; 74 | } 75 | 76 | pub fn get_alpha(&self, idx: usize) -> f32 { 77 | self.get_data_ref(idx).a 78 | } 79 | 80 | fn get_data_ref_mut(&self, idx: usize) -> &mut Color { 81 | assert!(idx < ENTITY_SZ); 82 | unsafe { &mut *(self.data.offset(idx as isize)) } 83 | } 84 | 85 | fn get_data_ref(&self, idx: usize) -> &Color { 86 | assert!(idx < ENTITY_SZ); 87 | unsafe { &*(self.data.offset(idx as isize)) } 88 | } 89 | } 90 | -------------------------------------------------------------------------------- /src/mgfw/ecs/component_easing.rs: -------------------------------------------------------------------------------- 1 | use super::*; 2 | use crate::mgfw::log; 3 | 4 | #[derive(Debug, Copy, Clone)] 5 | pub struct Ease { 6 | pub end: f32, 7 | pub dxdt: f32, 8 | pub entity: u8, 9 | pub variable: u8, 10 | } 11 | 12 | #[derive(Copy, Clone)] 13 | pub struct EasingIdSpan { 14 | pub first: usize, 15 | pub last: usize, 16 | } 17 | 18 | const EASING_SZ: usize = 96; 19 | const EASING_VAR_INACTIVE: u8 = 0; 20 | pub const EASING_VAR_ALPHA: u8 = 1; 21 | 22 | pub struct EasingComponentManager { 23 | data: *mut Ease, 24 | // WARNING: Anything below this line is not in cache! 25 | cursor: usize, // current insertion cursor 26 | span: EasingIdSpan, 27 | } 28 | 29 | #[allow(dead_code)] 30 | impl EasingComponentManager { 31 | pub fn new(mgr: &mut CacheManager) -> EasingComponentManager { 32 | log(format!("Constructing EasingComponentManager")); 33 | let sz_bytes = std::mem::size_of::() * EASING_SZ; 34 | EasingComponentManager { 35 | data: mgr.allocate(sz_bytes) as *mut Ease, 36 | cursor: 0, 37 | span: EasingIdSpan { 38 | first: EASING_SZ - 1, 39 | last: 0, 40 | }, 41 | } 42 | } 43 | 44 | pub fn clear(&mut self) { 45 | // to do 46 | } 47 | 48 | fn slot_open(&self, idx: usize) -> bool { 49 | EASING_VAR_INACTIVE == self.get_data_ref(idx).variable 50 | } 51 | 52 | fn find_existing(&self, entity: usize, variable: u8) -> usize { 53 | for idx in self.span.first..=self.span.last { 54 | let data = self.get_data_ref(idx); 55 | if data.entity == entity as u8 && data.variable == variable { 56 | return idx; 57 | } 58 | } 59 | EASING_SZ 60 | } 61 | 62 | fn add_ease(&mut self, entity: usize, start: f32, end: f32, dt: f32, variable: u8) { 63 | let dxdt = (end - start) / dt; 64 | 65 | let existing = self.find_existing(entity, variable); 66 | if EASING_SZ > existing { 67 | self.cursor = existing; 68 | self.get_data_ref_mut(self.cursor).variable = EASING_VAR_INACTIVE; 69 | } else { 70 | // find first non-active ease 71 | for _i in 0..EASING_SZ { 72 | if self.slot_open(self.cursor) { 73 | break; 74 | } 75 | self.cursor = (self.cursor + 1) % EASING_SZ; // wrap around 76 | } 77 | } 78 | 79 | if !self.slot_open(self.cursor) { 80 | log(format!( 81 | "WARNING: EasingComponentManager: Ran out of available easing slots!" 82 | )); 83 | assert!(false); // make sure we actually found an open slot 84 | } 85 | 86 | let data = self.get_data_ref_mut(self.cursor); 87 | data.end = end; 88 | data.entity = entity as u8; 89 | data.variable = variable; 90 | data.dxdt = dxdt; 91 | 92 | // lazy span update 93 | if self.cursor < self.span.first { 94 | self.span.first = self.cursor; 95 | } 96 | if self.cursor > self.span.last { 97 | self.span.last = self.cursor; 98 | } 99 | } 100 | 101 | pub fn set_alpha_ease(&mut self, idx: usize, start: f32, end: f32, dt: f32) { 102 | self.add_ease(idx, start, end, dt, EASING_VAR_ALPHA); 103 | } 104 | 105 | pub fn deactivate(&mut self, idx: usize) { 106 | self.get_data_ref_mut(idx).variable = EASING_VAR_INACTIVE; 107 | 108 | // check if span can be updated 109 | if idx == self.span.first || idx == self.span.last { 110 | self.update_span(); 111 | } 112 | } 113 | 114 | fn update_span(&mut self) { 115 | self.span = EasingIdSpan { 116 | first: EASING_SZ - 1, 117 | last: 0, 118 | }; 119 | for idx in 0..EASING_SZ { 120 | if EASING_VAR_INACTIVE != self.get_data_ref(idx).variable { 121 | if idx < self.span.first { 122 | self.span.first = idx; 123 | } 124 | if idx > self.span.last { 125 | self.span.last = idx; 126 | } 127 | } 128 | } 129 | } 130 | 131 | pub fn get_id_span(&self) -> EasingIdSpan { 132 | self.span 133 | } 134 | 135 | fn get_data_ref_mut(&self, idx: usize) -> &mut Ease { 136 | assert!(idx < EASING_SZ); 137 | unsafe { &mut *(self.data.offset(idx as isize)) } 138 | } 139 | 140 | pub fn get_data_ref(&self, idx: usize) -> &Ease { 141 | assert!(idx < EASING_SZ); 142 | unsafe { &*(self.data.offset(idx as isize)) } 143 | } 144 | } 145 | -------------------------------------------------------------------------------- /src/mgfw/ecs/component_frame.rs: -------------------------------------------------------------------------------- 1 | use super::*; 2 | use crate::mgfw::log; 3 | 4 | #[derive(Debug, Copy, Clone)] 5 | pub struct Frame { 6 | pub frame: u16, 7 | } 8 | 9 | pub struct FrameComponentManager { 10 | data: *mut Frame, 11 | // WARNING: Anything below this line is not in cache! 12 | } 13 | 14 | #[allow(dead_code)] 15 | impl FrameComponentManager { 16 | pub fn new(mgr: &mut CacheManager) -> FrameComponentManager { 17 | log(format!("Constructing FrameComponentManager")); 18 | let sz_bytes = std::mem::size_of::() * ENTITY_SZ; 19 | FrameComponentManager { 20 | data: mgr.allocate(sz_bytes) as *mut Frame, 21 | } 22 | } 23 | 24 | pub fn clear(&mut self) { 25 | for i in 0..ENTITY_SZ { 26 | self.set_frame(i, 0); 27 | } 28 | } 29 | 30 | pub fn set_frame(&self, idx: usize, frame: u16) { 31 | let d = self.get_data_ref_mut(idx); 32 | d.frame = frame; 33 | } 34 | 35 | pub fn get_frame(&self, idx: usize) -> u16 { 36 | let d = self.get_data_ref(idx); 37 | d.frame 38 | } 39 | 40 | pub fn get_data_ref_mut(&self, idx: usize) -> &mut Frame { 41 | assert!(idx < ENTITY_SZ); 42 | unsafe { &mut *(self.data.offset(idx as isize)) } 43 | } 44 | 45 | pub fn get_data_ref(&self, idx: usize) -> &Frame { 46 | assert!(idx < ENTITY_SZ); 47 | unsafe { &*(self.data.offset(idx as isize)) } 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /src/mgfw/ecs/component_physics.rs: -------------------------------------------------------------------------------- 1 | use super::*; 2 | use crate::mgfw::log; 3 | 4 | #[derive(Debug, Copy, Clone)] 5 | pub struct Velocity { 6 | pub x: f32, 7 | pub y: f32, 8 | } 9 | 10 | #[derive(Debug, Copy, Clone)] 11 | pub struct Acceleration { 12 | pub x: f32, 13 | pub y: f32, 14 | } 15 | 16 | pub struct PhysicsComponentManagerData { 17 | pub velocity: Velocity, 18 | pub acceleration: Acceleration, 19 | pub angular_velocity: f32, 20 | } 21 | 22 | pub struct PhysicsComponentManager { 23 | data: *mut PhysicsComponentManagerData, 24 | // WARNING: Anything below this line is not in cache! 25 | } 26 | 27 | #[allow(dead_code)] 28 | impl PhysicsComponentManager { 29 | pub fn new(mgr: &mut CacheManager) -> PhysicsComponentManager { 30 | log(format!("Constructing PhysicsComponentManager")); 31 | let sz_bytes = std::mem::size_of::() * ENTITY_SZ; 32 | PhysicsComponentManager { 33 | data: mgr.allocate(sz_bytes) as *mut PhysicsComponentManagerData, 34 | } 35 | } 36 | 37 | pub fn clear(&mut self) { 38 | for i in 0..ENTITY_SZ { 39 | self.set_acceleration(i, 0.0, 0.0); 40 | self.set_velocity(i, 0.0, 0.0); 41 | self.set_angular_velocity(i, 0.0); 42 | } 43 | } 44 | 45 | pub fn get_velocity(&self, idx: usize) -> Velocity { 46 | let data = self.get_data_ref(idx); 47 | data.velocity.clone() 48 | } 49 | 50 | pub fn get_acceleration(&self, idx: usize) -> Acceleration { 51 | let data = self.get_data_ref(idx); 52 | data.acceleration.clone() 53 | } 54 | 55 | pub fn get_angular_velocity(&self, idx: usize) -> f32 { 56 | let data = self.get_data_ref(idx); 57 | data.angular_velocity 58 | } 59 | 60 | pub fn set_angular_velocity(&self, idx: usize, val: f32) { 61 | let data = self.get_data_ref_mut(idx); 62 | data.angular_velocity = val; 63 | } 64 | 65 | pub fn set_velocity(&self, idx: usize, x: f32, y: f32) { 66 | let data = self.get_data_ref_mut(idx); 67 | data.velocity.x = x; 68 | data.velocity.y = y; 69 | } 70 | 71 | pub fn set_acceleration(&self, idx: usize, x: f32, y: f32) { 72 | let data = self.get_data_ref_mut(idx); 73 | data.acceleration.x = x; 74 | data.acceleration.y = y; 75 | } 76 | 77 | pub fn get_data_ref_mut(&self, idx: usize) -> &mut PhysicsComponentManagerData { 78 | assert!(idx < ENTITY_SZ); 79 | unsafe { &mut *(self.data.offset(idx as isize)) } 80 | } 81 | 82 | pub fn get_data_ref(&self, idx: usize) -> &PhysicsComponentManagerData { 83 | assert!(idx < ENTITY_SZ); 84 | unsafe { &*(self.data.offset(idx as isize)) } 85 | } 86 | } 87 | -------------------------------------------------------------------------------- /src/mgfw/ecs/component_position.rs: -------------------------------------------------------------------------------- 1 | use super::*; 2 | use crate::mgfw::log; 3 | 4 | #[derive(Debug, Copy, Clone)] 5 | pub struct Position { 6 | pub x: f32, 7 | pub y: f32, 8 | } 9 | 10 | impl Position { 11 | pub fn new(x: f32, y: f32) -> Position { 12 | Position { 13 | x, 14 | y, 15 | } 16 | } 17 | } 18 | 19 | pub struct PositionComponentManager { 20 | data: *mut Position, 21 | // WARNING: Anything below this line is not in cache! 22 | } 23 | 24 | #[allow(dead_code)] 25 | impl PositionComponentManager { 26 | pub fn new(mgr: &mut CacheManager) -> PositionComponentManager { 27 | log(format!("Constructing PositionComponentManager")); 28 | let sz_bytes = std::mem::size_of::() * ENTITY_SZ; 29 | PositionComponentManager { 30 | data: mgr.allocate(sz_bytes) as *mut Position, 31 | } 32 | } 33 | 34 | pub fn clear(&mut self) { 35 | for i in 0..ENTITY_SZ { 36 | self.set_position(i, 0.0, 0.0); 37 | } 38 | } 39 | 40 | pub fn set_position(&self, idx: usize, x: f32, y: f32) { 41 | let pos = self.get_data_ref_mut(idx); 42 | pos.x = x; 43 | pos.y = y; 44 | } 45 | 46 | pub fn get_position(&self, idx: usize) -> Position { 47 | let pos = self.get_data_ref(idx); 48 | pos.clone() 49 | } 50 | 51 | pub fn get_data_ref_mut(&self, idx: usize) -> &mut Position { 52 | assert!(idx < ENTITY_SZ); 53 | unsafe { &mut *(self.data.offset(idx as isize)) } 54 | } 55 | 56 | pub fn get_data_ref(&self, idx: usize) -> &Position { 57 | assert!(idx < ENTITY_SZ); 58 | unsafe { &*(self.data.offset(idx as isize)) } 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /src/mgfw/ecs/component_render.rs: -------------------------------------------------------------------------------- 1 | use super::*; 2 | use crate::mgfw::log; 3 | 4 | pub const RENDER_TYPE_INVALID: u8 = 0; 5 | pub const RENDER_TYPE_TEXT: u8 = 1; 6 | pub const RENDER_TYPE_LINE_BUFFER: u8 = 2; 7 | pub const RENDER_TYPE_TRIANGLE_BUFFER: u8 = 3; 8 | pub const RENDER_TYPE_BILLBOARD: u8 = 4; 9 | pub const RENDER_TYPE_TILEMAP: u8 = 5; 10 | 11 | struct RenderComponentManagerData { 12 | render_type: u8, 13 | } 14 | 15 | pub struct RenderComponentManager { 16 | data: *mut RenderComponentManagerData, 17 | // WARNING: Anything below this line is not in cache! 18 | } 19 | 20 | #[allow(dead_code)] 21 | impl RenderComponentManager { 22 | pub fn new(mgr: &mut CacheManager) -> RenderComponentManager { 23 | log(format!("Constructing RenderComponentManager")); 24 | // allocate system memory in cache 25 | let sz_bytes = std::mem::size_of::() * ENTITY_SZ; 26 | let data = mgr.allocate(sz_bytes) as *mut RenderComponentManagerData; 27 | 28 | RenderComponentManager { data } 29 | } 30 | 31 | pub fn clear(&mut self) { 32 | for i in 0..ENTITY_SZ { 33 | self.set_type(i, RENDER_TYPE_INVALID); 34 | } 35 | } 36 | 37 | pub fn set_type(&mut self, idx: usize, render_type: u8) { 38 | self.get_data_ref_mut(idx).render_type = render_type; 39 | } 40 | 41 | pub fn get_type(&self, idx: usize) -> u8 { 42 | self.get_data_ref(idx).render_type 43 | } 44 | 45 | pub fn has_type(&self, idx: usize, render_type: u8) -> bool { 46 | self.get_data_ref(idx).render_type == render_type 47 | } 48 | 49 | fn get_data_ref_mut(&self, idx: usize) -> &mut RenderComponentManagerData { 50 | assert!(idx < ENTITY_SZ); 51 | unsafe { &mut *(self.data.offset(idx as isize)) } 52 | } 53 | 54 | fn get_data_ref(&self, idx: usize) -> &RenderComponentManagerData { 55 | assert!(idx < ENTITY_SZ); 56 | unsafe { &*(self.data.offset(idx as isize)) } 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /src/mgfw/ecs/component_render_billboard.rs: -------------------------------------------------------------------------------- 1 | use super::*; 2 | use crate::mgfw::log; 3 | use std::collections::HashMap; 4 | 5 | struct BillboardRenderComponentManagerData { 6 | texture: u16, 7 | constructed: bool, 8 | reconstruct_needed: bool, 9 | load_image_needed: bool, 10 | } 11 | 12 | pub struct BillboardRenderComponentManager { 13 | cache_data: *mut BillboardRenderComponentManagerData, 14 | // WARNING: Anything below this line is not in cache! 15 | texture_files: std::boxed::Box>, 16 | texture_handles: std::boxed::Box>, 17 | } 18 | 19 | #[allow(dead_code)] 20 | impl BillboardRenderComponentManager { 21 | pub fn new(mgr: &mut CacheManager) -> BillboardRenderComponentManager { 22 | log(format!("Constructing BillboardRenderComponentManager")); 23 | 24 | let fdata: HashMap = HashMap::new(); 25 | let hdata: HashMap = HashMap::new(); 26 | 27 | // allocate system memory in cache 28 | let sz_bytes = std::mem::size_of::() * ENTITY_SZ; 29 | let cache_data = mgr.allocate(sz_bytes) as *mut BillboardRenderComponentManagerData; 30 | 31 | BillboardRenderComponentManager { 32 | texture_files: Box::new(fdata), 33 | texture_handles: Box::new(hdata), 34 | cache_data, 35 | } 36 | } 37 | 38 | pub fn clear(&mut self) { 39 | for i in 0..ENTITY_SZ { 40 | self.get_data_ref_mut(i).constructed = false; 41 | } 42 | } 43 | 44 | pub fn set_image(&mut self, idx: usize, image: String) { 45 | let cache_data = self.get_data_ref_mut(idx); 46 | cache_data.load_image_needed = true; 47 | cache_data.reconstruct_needed = true; 48 | cache_data.constructed = false; 49 | self.texture_files.insert(idx, image); 50 | } 51 | 52 | pub fn get_image(&self, idx: usize) -> String { 53 | self.texture_files.get(&idx).unwrap().to_string() 54 | } 55 | 56 | pub fn is_constructed(&self, idx: usize) -> bool { 57 | self.get_data_ref(idx).constructed 58 | } 59 | 60 | pub fn reconstruct(&self, idx: usize) -> bool { 61 | self.get_data_ref(idx).reconstruct_needed 62 | } 63 | 64 | pub fn load_image_needed(&self, idx: usize) -> bool { 65 | self.get_data_ref(idx).load_image_needed 66 | } 67 | 68 | pub fn load_image(&mut self, idx: usize, gl: &Gl) { 69 | if self.get_data_ref(idx).load_image_needed { 70 | let filename = self.texture_files.get(&idx).unwrap().to_string(); 71 | let handle: u32 = match self.texture_handles.contains_key(&filename) { 72 | true => *self.texture_handles.get(&filename).unwrap(), 73 | false => { 74 | let h = gl.load_texture(&filename); 75 | self.texture_handles.insert(filename, h); 76 | h 77 | } 78 | }; 79 | 80 | self.get_data_ref_mut(idx).texture = handle as u16; 81 | self.get_data_ref_mut(idx).load_image_needed = false; 82 | } 83 | } 84 | 85 | pub fn construct(&mut self, idx: usize, gl: &Gl, vao: u32, vbo: u32) { 86 | self.load_image(idx, gl); 87 | 88 | let mut vertex_data: Vec = Vec::new(); 89 | 90 | vertex_data.extend_from_slice(&[-0.5, -0.5]); // pos 91 | vertex_data.extend_from_slice(&[0.0, 0.0]); // uv 92 | 93 | vertex_data.extend_from_slice(&[-0.5, 0.5]); // pos 94 | vertex_data.extend_from_slice(&[0.0, 1.0]); // uv 95 | 96 | vertex_data.extend_from_slice(&[0.5, 0.5]); // pos 97 | vertex_data.extend_from_slice(&[1.0, 1.0]); // uv 98 | 99 | vertex_data.extend_from_slice(&[-0.5, -0.5]); // pos 100 | vertex_data.extend_from_slice(&[0.0, 0.0]); // uv 101 | 102 | vertex_data.extend_from_slice(&[0.5, 0.5]); // pos 103 | vertex_data.extend_from_slice(&[1.0, 1.0]); // uv 104 | 105 | vertex_data.extend_from_slice(&[0.5, -0.5]); // pos 106 | vertex_data.extend_from_slice(&[1.0, 0.0]); // uv 107 | 108 | gl.buffer_billboard_data(vao, vbo, vertex_data.as_ptr() as *const _); 109 | 110 | let cache_data = self.get_data_ref_mut(idx); 111 | cache_data.reconstruct_needed = false; 112 | cache_data.constructed = true; 113 | } 114 | 115 | pub fn get_tex_handle(&self, idx: usize) -> u16 { 116 | self.get_data_ref(idx).texture 117 | } 118 | 119 | fn get_data_ref_mut(&self, idx: usize) -> &mut BillboardRenderComponentManagerData { 120 | assert!(idx < ENTITY_SZ); 121 | unsafe { &mut *(self.cache_data.offset(idx as isize)) } 122 | } 123 | 124 | fn get_data_ref(&self, idx: usize) -> &BillboardRenderComponentManagerData { 125 | assert!(idx < ENTITY_SZ); 126 | unsafe { &*(self.cache_data.offset(idx as isize)) } 127 | } 128 | } 129 | -------------------------------------------------------------------------------- /src/mgfw/ecs/component_render_line_buffer.rs: -------------------------------------------------------------------------------- 1 | use super::*; 2 | use crate::mgfw::log; 3 | 4 | struct LineBuffer { 5 | // WARNING: Anything below this line is not in cache! 6 | pnts: Vec, 7 | clrs: Vec, 8 | } 9 | 10 | struct LineRenderComponentManagerData { 11 | num_lines: u16, 12 | constructed: bool, 13 | reconstruct_needed: bool, 14 | } 15 | 16 | pub struct LineRenderComponentManager { 17 | cache_data: *mut LineRenderComponentManagerData, 18 | // WARNING: Anything below this line is not in cache! 19 | data: std::boxed::Box>, 20 | } 21 | 22 | #[allow(dead_code)] 23 | impl LineRenderComponentManager { 24 | pub fn new(mgr: &mut CacheManager) -> LineRenderComponentManager { 25 | log(format!("Constructing LineRenderComponentManager")); 26 | 27 | let mut data: Vec = Vec::new(); 28 | for _i in 0..ENTITY_SZ { 29 | data.push(LineBuffer { 30 | pnts: Vec::new(), 31 | clrs: Vec::new(), 32 | }); 33 | } 34 | 35 | // allocate system memory in cache 36 | let sz_bytes = std::mem::size_of::() * ENTITY_SZ; 37 | let cache_data = mgr.allocate(sz_bytes) as *mut LineRenderComponentManagerData; 38 | 39 | LineRenderComponentManager { 40 | data: Box::new(data), 41 | cache_data, 42 | } 43 | } 44 | 45 | pub fn clear(&mut self) { 46 | 47 | } 48 | 49 | pub fn set_line_buffer(&mut self, idx: usize, pnts: &Vec, clrs: &Vec) { 50 | self.get_data_ref_mut(idx).reconstruct_needed = true; 51 | self.data[idx].pnts = pnts.clone(); 52 | self.data[idx].clrs = clrs.clone(); 53 | } 54 | 55 | pub fn is_constructed(&self, idx: usize) -> bool { 56 | self.get_data_ref(idx).constructed 57 | } 58 | 59 | pub fn reconstruct(&self, idx: usize) -> bool { 60 | self.get_data_ref(idx).reconstruct_needed 61 | } 62 | 63 | pub fn construct(&self, idx: usize, gl: &Gl, vao: u32, vbo: u32) { 64 | let cache_data = self.get_data_ref_mut(idx); 65 | 66 | let pnts = &self.data[idx].pnts; 67 | let clrs = &self.data[idx].clrs; 68 | 69 | let num_lines = pnts.len() / 2; 70 | 71 | let mut vertex_data: Vec = Vec::new(); 72 | 73 | for i in 0..pnts.len() { 74 | vertex_data.push(pnts[i].x); 75 | vertex_data.push(pnts[i].y); 76 | vertex_data.push(clrs[i].r); 77 | vertex_data.push(clrs[i].g); 78 | vertex_data.push(clrs[i].b); 79 | vertex_data.push(clrs[i].a); 80 | } 81 | 82 | let data_ptr = vertex_data.as_ptr() as *const _; 83 | gl.buffer_line_data(vao, vbo, num_lines, data_ptr); 84 | 85 | cache_data.reconstruct_needed = false; 86 | cache_data.constructed = true; 87 | cache_data.num_lines = num_lines as u16; 88 | } 89 | 90 | pub fn get_num_lines(&self, idx: usize) -> usize { 91 | self.get_data_ref(idx).num_lines as usize 92 | } 93 | 94 | fn get_data_ref_mut(&self, idx: usize) -> &mut LineRenderComponentManagerData { 95 | assert!(idx < ENTITY_SZ); 96 | unsafe { &mut *(self.cache_data.offset(idx as isize)) } 97 | } 98 | 99 | fn get_data_ref(&self, idx: usize) -> &LineRenderComponentManagerData { 100 | assert!(idx < ENTITY_SZ); 101 | unsafe { &*(self.cache_data.offset(idx as isize)) } 102 | } 103 | } 104 | -------------------------------------------------------------------------------- /src/mgfw/ecs/component_render_text.rs: -------------------------------------------------------------------------------- 1 | use super::*; 2 | use crate::mgfw::log; 3 | 4 | struct Text { 5 | // WARNING: Anything below this line is not in cache! 6 | text: String, 7 | } 8 | 9 | struct TextRenderComponentManagerData { 10 | width: u16, 11 | num_chars: u16, 12 | constructed: bool, 13 | reconstruct_needed: bool, 14 | } 15 | 16 | pub struct TextRenderComponentManager { 17 | cache_data: *mut TextRenderComponentManagerData, 18 | // WARNING: Anything below this line is not in cache! 19 | data: std::boxed::Box>, 20 | font: std::boxed::Box, 21 | } 22 | 23 | #[allow(dead_code)] 24 | impl TextRenderComponentManager { 25 | pub fn new(mgr: &mut CacheManager) -> TextRenderComponentManager { 26 | log(format!("Constructing TextRenderComponentManager")); 27 | 28 | let mut data: Vec = Vec::new(); 29 | for _i in 0..ENTITY_SZ { 30 | data.push(Text { 31 | text: String::new(), 32 | }); 33 | } 34 | 35 | // allocate system memory in cache 36 | let sz_bytes = std::mem::size_of::() * ENTITY_SZ; 37 | let cache_data = mgr.allocate(sz_bytes) as *mut TextRenderComponentManagerData; 38 | 39 | TextRenderComponentManager { 40 | data: Box::new(data), 41 | font: Box::new(fonts::retro_gaming::Font::new()), 42 | cache_data, 43 | } 44 | } 45 | 46 | pub fn clear(&mut self) { 47 | 48 | } 49 | 50 | pub fn set_text(&mut self, idx: usize, text: String) { 51 | self.get_data_ref_mut(idx).reconstruct_needed = true; 52 | self.data[idx].text = text; 53 | } 54 | 55 | pub fn is_constructed(&self, idx: usize) -> bool { 56 | self.get_data_ref(idx).constructed 57 | } 58 | 59 | pub fn reconstruct(&self, idx: usize) -> bool { 60 | self.get_data_ref(idx).reconstruct_needed 61 | } 62 | 63 | // potential cache miss 64 | fn recalc_width(&self, idx: usize) { 65 | let cache_data = self.get_data_ref_mut(idx); 66 | 67 | let bytes = self.data[idx].text.as_bytes(); 68 | let mut basex: f32 = 0.0; 69 | 70 | for i in 0..bytes.len() { 71 | let idx = bytes[i] as u16; 72 | let data = self.font.data[&idx]; 73 | let advance = data[6] as f32; 74 | basex += advance; 75 | } 76 | 77 | cache_data.width = basex as u16; 78 | } 79 | 80 | // probable cache miss 81 | pub fn construct(&self, idx: usize, gl: &Gl, vao: u32, vbo: u32) { 82 | let cache_data = self.get_data_ref_mut(idx); 83 | 84 | /*println!("{}, {}", self.font.scale_w, self.font.scale_h); 85 | println!("{:?}", self.font.page_files); 86 | println!("{:?}", self.font.data[&('t' as u16)]); 87 | println!("{:?}", self.data[idx].text); 88 | let bytes = self.data[idx].text.as_bytes(); 89 | for i in 0..bytes.len() { 90 | let idx = bytes[i] as u16; 91 | println!("{:?} {:?}", bytes, self.font.data[&idx]); 92 | }*/ 93 | 94 | let ww = 256.0; 95 | let hh = 64.0; 96 | let mut vertex_data: Vec = Vec::new(); 97 | 98 | let bytes = self.data[idx].text.as_bytes(); 99 | let num_chars = bytes.len(); 100 | 101 | let mut basex: f32 = 0.0; 102 | 103 | for i in 0..num_chars { 104 | let idx = bytes[i] as u16; 105 | 106 | let data = self.font.data[&idx]; 107 | let dx = data[0] as f32 / ww; 108 | let dy = data[1] as f32 / hh; 109 | let dw = data[2] as f32; 110 | let dh = data[3] as f32; 111 | let dwt = dw as f32 / ww; 112 | let dht = dh as f32 / hh; 113 | let dxoff = data[4] as f32; 114 | let dyoff = data[5] as f32; 115 | let advance = data[6] as f32; 116 | 117 | let p0 = [basex + 0.0 + dxoff, 0.0 + dyoff, dx, dy]; 118 | let p1 = [basex + 0.0 + dxoff, dh + dyoff, dx, dy + dht]; 119 | let p2 = [basex + dw + dxoff, dh + dyoff, dx + dwt, dy + dht]; 120 | let p3 = [basex + dw + dxoff, 0.0 + dyoff, dx + dwt, dy]; 121 | 122 | for i in 0..4 { 123 | vertex_data.push(p0[i]); 124 | } 125 | for i in 0..4 { 126 | vertex_data.push(p1[i]); 127 | } 128 | for i in 0..4 { 129 | vertex_data.push(p2[i]); 130 | } 131 | for i in 0..4 { 132 | vertex_data.push(p0[i]); 133 | } 134 | for i in 0..4 { 135 | vertex_data.push(p2[i]); 136 | } 137 | for i in 0..4 { 138 | vertex_data.push(p3[i]); 139 | } 140 | 141 | basex += advance; 142 | } 143 | 144 | let data_ptr = vertex_data.as_ptr() as *const _; 145 | gl.buffer_font_data(vao, vbo, num_chars as i32, data_ptr); 146 | 147 | cache_data.reconstruct_needed = false; 148 | cache_data.constructed = true; 149 | cache_data.num_chars = num_chars as u16; 150 | cache_data.width = basex as u16; 151 | } 152 | 153 | pub fn get_length(&self, idx: usize) -> usize { 154 | self.get_data_ref(idx).num_chars as usize 155 | } 156 | 157 | pub fn get_width(&self, idx: usize) -> usize { 158 | if self.reconstruct(idx) { 159 | // force recalc if hasn't happened on its own yet 160 | self.recalc_width(idx); 161 | } 162 | self.get_data_ref(idx).width as usize 163 | } 164 | 165 | fn get_data_ref_mut(&self, idx: usize) -> &mut TextRenderComponentManagerData { 166 | assert!(idx < ENTITY_SZ); 167 | unsafe { &mut *(self.cache_data.offset(idx as isize)) } 168 | } 169 | 170 | fn get_data_ref(&self, idx: usize) -> &TextRenderComponentManagerData { 171 | assert!(idx < ENTITY_SZ); 172 | unsafe { &*(self.cache_data.offset(idx as isize)) } 173 | } 174 | } 175 | -------------------------------------------------------------------------------- /src/mgfw/ecs/component_render_tilemap.rs: -------------------------------------------------------------------------------- 1 | #![allow(dead_code)] 2 | 3 | use super::*; 4 | use crate::mgfw::log; 5 | 6 | struct TilesetBuffer { 7 | // WARNING: Anything below this line is not in cache! 8 | image_width: usize, 9 | image_height: usize, 10 | tile_width: usize, 11 | tile_height: usize, 12 | span: usize, 13 | count: usize, 14 | } 15 | 16 | const MUTATION_NONE: u8 = 0; 17 | const MUTATION_FLIP_HORIZ: u8 = 1; 18 | const MUTATION_FLIP_VERT: u8 = 2; 19 | const MUTATION_ROTATE_CW: u8 = 3; 20 | const MUTATION_ROTATE_CCW: u8 = 4; 21 | const MUTATION_ROTATE_180: u8 = 5; 22 | 23 | const TILEMAP_MODE_NORMAL: u8 = 0; 24 | const TILEMAP_MODE_ISOMETRIC: u8 = 1; 25 | 26 | struct TileMutation { 27 | cell: usize, 28 | mutation: u8, 29 | } 30 | 31 | struct TilemapBuffer { 32 | // WARNING: Anything below this line is not in cache! 33 | data: Vec, 34 | mutations: Vec, 35 | } 36 | 37 | struct TilemapRenderComponentManagerData { 38 | columns: usize, 39 | rows: usize, 40 | constructed: bool, 41 | reconstruct_needed: bool, 42 | tileset: usize, 43 | num_tiles: u16, 44 | tile_mode: u8, 45 | } 46 | 47 | pub struct TilemapRenderComponentManager { 48 | cache_data: *mut TilemapRenderComponentManagerData, 49 | // WARNING: Anything below this line is not in cache! 50 | tileset: std::boxed::Box>, 51 | tilemap: std::boxed::Box>, 52 | } 53 | 54 | #[allow(dead_code)] 55 | impl TilemapRenderComponentManager { 56 | pub fn new(mgr: &mut CacheManager) -> TilemapRenderComponentManager { 57 | log(format!("Constructing TilemapRenderComponentManager")); 58 | 59 | let mut tileset: Vec = Vec::new(); 60 | let mut tilemap: Vec = Vec::new(); 61 | for _i in 0..ENTITY_SZ { 62 | tileset.push(TilesetBuffer { 63 | tile_width: 16, 64 | tile_height: 16, 65 | image_width: 320, 66 | image_height: 240, 67 | span: 16, 68 | count: 1, 69 | }); 70 | tilemap.push(TilemapBuffer { data: Vec::new(), mutations: Vec::new() }); 71 | } 72 | 73 | // allocate system memory in cache 74 | let sz_bytes = std::mem::size_of::() * ENTITY_SZ; 75 | let cache_data = mgr.allocate(sz_bytes) as *mut TilemapRenderComponentManagerData; 76 | 77 | TilemapRenderComponentManager { 78 | tileset: Box::new(tileset), 79 | tilemap: Box::new(tilemap), 80 | cache_data, 81 | } 82 | } 83 | 84 | pub fn clear(&mut self) { 85 | 86 | } 87 | 88 | pub fn set_tileset( 89 | &mut self, 90 | idx: usize, 91 | image_width: usize, 92 | image_height: usize, 93 | tile_width: usize, 94 | tile_height: usize, 95 | ) { 96 | self.tileset[idx].image_width = image_width; 97 | self.tileset[idx].image_height = image_height; 98 | self.tileset[idx].tile_width = tile_width; 99 | self.tileset[idx].tile_height = tile_height; 100 | 101 | self.tileset[idx].span = (image_width - (image_width % tile_width)) / tile_width; 102 | self.tileset[idx].count = 103 | self.tileset[idx].span * (image_height - (image_height % tile_height)) / tile_height; 104 | 105 | println!( 106 | "tileset {},{},{}", 107 | idx, self.tileset[idx].span, self.tileset[idx].count 108 | ); 109 | } 110 | 111 | pub fn set_tilemap(&mut self, idx: usize, tileset_idx: usize, columns: usize, data: &Vec) { 112 | let cache_data = self.get_data_ref_mut(idx); 113 | cache_data.reconstruct_needed = true; 114 | cache_data.columns = columns; 115 | cache_data.tileset = tileset_idx; 116 | cache_data.tile_mode = TILEMAP_MODE_NORMAL; 117 | let n = data.len(); 118 | assert!(0 != columns); 119 | assert!(0 != n); 120 | assert!(0 == n % columns); 121 | cache_data.rows = (n - (n % columns)) / columns; 122 | assert!(data.len() == cache_data.rows * cache_data.columns); 123 | self.tilemap[idx].data = data.clone(); 124 | self.tilemap[idx].mutations.clear(); 125 | } 126 | 127 | pub fn set_iso_tilemap(&mut self, idx: usize, tileset_idx: usize, columns: usize, data: &Vec) { 128 | self.set_tilemap(idx, tileset_idx, columns, data); 129 | self.get_data_ref_mut(idx).tile_mode = TILEMAP_MODE_ISOMETRIC; 130 | } 131 | 132 | pub fn cell_flip_horizontal(&mut self, idx: usize, cell: usize) { 133 | self.cell_mutate(idx, cell, MUTATION_FLIP_HORIZ); 134 | } 135 | 136 | pub fn cell_flip_vertical(&mut self, idx: usize, cell: usize) { 137 | self.cell_mutate(idx, cell, MUTATION_FLIP_VERT); 138 | } 139 | 140 | pub fn cell_rotate_cw(&mut self, idx: usize, cell: usize) { 141 | self.cell_mutate(idx, cell, MUTATION_ROTATE_CW); 142 | } 143 | 144 | pub fn cell_rotate_ccw(&mut self, idx: usize, cell: usize) { 145 | self.cell_mutate(idx, cell, MUTATION_ROTATE_CCW); 146 | } 147 | 148 | pub fn cell_rotate_180(&mut self, idx: usize, cell: usize) { 149 | self.cell_mutate(idx, cell, MUTATION_ROTATE_180); 150 | } 151 | 152 | fn cell_mutate(&mut self, idx: usize, cell: usize, mutation: u8) { 153 | let cache_data = self.get_data_ref_mut(idx); 154 | cache_data.reconstruct_needed = true; 155 | assert!(cell < cache_data.rows * cache_data.columns); 156 | cache_data.reconstruct_needed = true; 157 | self.tilemap[idx].mutations.push(TileMutation { cell, mutation }); 158 | } 159 | 160 | pub fn is_constructed(&self, idx: usize) -> bool { 161 | self.get_data_ref(idx).constructed 162 | } 163 | 164 | pub fn reconstruct(&self, idx: usize) -> bool { 165 | self.get_data_ref(idx).reconstruct_needed 166 | } 167 | 168 | pub fn get_tileset_idx(&self, idx: usize) -> usize { 169 | self.get_data_ref(idx).tileset 170 | } 171 | 172 | pub fn get_num_tiles(&self, idx: usize) -> usize { 173 | self.get_data_ref(idx).num_tiles as usize 174 | } 175 | 176 | pub fn construct(&self, idx: usize, gl: &Gl, vao: u32, vbo: u32) { 177 | let cache_data = self.get_data_ref_mut(idx); 178 | let cols = cache_data.columns; 179 | 180 | let mut vertex_data: Vec = Vec::new(); 181 | 182 | let map = &self.tilemap[idx].data; 183 | 184 | let mut num_tiles: usize = 0; 185 | 186 | let tileset = &self.tileset[cache_data.tileset]; 187 | let uscale = tileset.tile_width as f32 / tileset.image_width as f32; 188 | let vscale = tileset.tile_height as f32 / tileset.image_height as f32; 189 | let usub = uscale * 0.0; //(0.2 / tileset.tile_width as f32); 190 | let vsub = uscale * 0.0; //(0.2 / tileset.tile_height as f32); 191 | 192 | for i in 0..map.len() { 193 | let t0 = map[i] as usize; 194 | if EMPTY_TILE == t0 as u16 || tileset.count < t0 { 195 | continue; 196 | } 197 | let t0 = t0 - 1; 198 | 199 | let u0 = (t0 % tileset.span) as f32 * uscale + usub; 200 | let v0 = ((t0 - (t0 % tileset.span)) / tileset.span) as f32 * vscale + vsub; 201 | let u1 = u0 + uscale - usub; 202 | let v1 = v0 + vscale - vsub; 203 | 204 | let mut x0 = (i % cols) as f32; 205 | let mut y0 = 1.0 * (((i - (i % cols)) / cols) as f32); 206 | 207 | if TILEMAP_MODE_ISOMETRIC == cache_data.tile_mode { 208 | let xp = x0 - y0; 209 | let yp = 0.5 * x0 + 0.5 * y0; 210 | 211 | x0 = xp * 0.5 - 0.5; 212 | y0 = yp * 0.5 - 0.75; 213 | } 214 | 215 | let x1 = x0 + 1.0; 216 | let y1 = y0 + 1.0; 217 | 218 | vertex_data.push(x0); 219 | vertex_data.push(y0); 220 | vertex_data.push(u0); 221 | vertex_data.push(v0); 222 | vertex_data.push(x0); 223 | vertex_data.push(y1); 224 | vertex_data.push(u0); 225 | vertex_data.push(v1); 226 | vertex_data.push(x1); 227 | vertex_data.push(y1); 228 | vertex_data.push(u1); 229 | vertex_data.push(v1); 230 | 231 | vertex_data.push(x0); 232 | vertex_data.push(y0); 233 | vertex_data.push(u0); 234 | vertex_data.push(v0); 235 | vertex_data.push(x1); 236 | vertex_data.push(y1); 237 | vertex_data.push(u1); 238 | vertex_data.push(v1); 239 | vertex_data.push(x1); 240 | vertex_data.push(y0); 241 | vertex_data.push(u1); 242 | vertex_data.push(v0); 243 | 244 | num_tiles += 1; 245 | } 246 | 247 | // perform mutations 248 | let mutations = &self.tilemap[idx].mutations; 249 | 250 | for i in 0..mutations.len() { 251 | let cell = mutations[i].cell; 252 | let vidx = cell * 24; 253 | let u0 = vertex_data[vidx + 2]; 254 | let v0 = vertex_data[vidx + 3]; 255 | let u1 = vertex_data[vidx + 10]; 256 | let v1 = vertex_data[vidx + 11]; 257 | 258 | match mutations[i].mutation { 259 | MUTATION_FLIP_HORIZ => { 260 | vertex_data[vidx + 2] = u1; 261 | vertex_data[vidx + 6] = u1; 262 | vertex_data[vidx + 10] = u0; 263 | 264 | vertex_data[vidx + 14] = u1; 265 | vertex_data[vidx + 18] = u0; 266 | vertex_data[vidx + 22] = u0; 267 | }, 268 | MUTATION_ROTATE_CW => { 269 | vertex_data[vidx + 2] = u0; 270 | vertex_data[vidx + 3] = v1; 271 | vertex_data[vidx + 6] = u1; 272 | vertex_data[vidx + 7] = v1; 273 | vertex_data[vidx + 10] = u1; 274 | vertex_data[vidx + 11] = v0; 275 | 276 | vertex_data[vidx + 14] = u0; 277 | vertex_data[vidx + 15] = v1; 278 | vertex_data[vidx + 18] = u1; 279 | vertex_data[vidx + 19] = v0; 280 | vertex_data[vidx + 22] = u0; 281 | vertex_data[vidx + 23] = v0; 282 | }, 283 | MUTATION_ROTATE_180 => { 284 | vertex_data[vidx + 2] = u1; 285 | vertex_data[vidx + 3] = v1; 286 | vertex_data[vidx + 6] = u1; 287 | vertex_data[vidx + 7] = v0; 288 | vertex_data[vidx + 10] = u0; 289 | vertex_data[vidx + 11] = v0; 290 | 291 | vertex_data[vidx + 14] = u1; 292 | vertex_data[vidx + 15] = v1; 293 | vertex_data[vidx + 18] = u0; 294 | vertex_data[vidx + 19] = v0; 295 | vertex_data[vidx + 22] = u0; 296 | vertex_data[vidx + 23] = v1; 297 | }, 298 | _ => (), 299 | } 300 | } 301 | 302 | let data_ptr = vertex_data.as_ptr() as *const _; 303 | gl.buffer_tilemap_data(vao, vbo, num_tiles, data_ptr); 304 | 305 | cache_data.reconstruct_needed = false; 306 | cache_data.constructed = true; 307 | cache_data.num_tiles = num_tiles as u16; 308 | //println!("Constructing tilemap {}", idx); 309 | } 310 | 311 | fn get_data_ref_mut(&self, idx: usize) -> &mut TilemapRenderComponentManagerData { 312 | assert!(idx < ENTITY_SZ); 313 | unsafe { &mut *(self.cache_data.offset(idx as isize)) } 314 | } 315 | 316 | fn get_data_ref(&self, idx: usize) -> &TilemapRenderComponentManagerData { 317 | assert!(idx < ENTITY_SZ); 318 | unsafe { &*(self.cache_data.offset(idx as isize)) } 319 | } 320 | } 321 | -------------------------------------------------------------------------------- /src/mgfw/ecs/component_render_triangle_buffer.rs: -------------------------------------------------------------------------------- 1 | use super::*; 2 | use crate::mgfw::log; 3 | 4 | struct TriangleBuffer { 5 | // WARNING: Anything below this line is not in cache! 6 | pnts: Vec, 7 | clrs: Vec, 8 | } 9 | 10 | struct TriangleRenderComponentManagerData { 11 | num_triangles: u16, 12 | constructed: bool, 13 | reconstruct_needed: bool, 14 | } 15 | 16 | pub struct TriangleRenderComponentManager { 17 | cache_data: *mut TriangleRenderComponentManagerData, 18 | // WARNING: Anything below this line is not in cache! 19 | data: std::boxed::Box>, 20 | } 21 | 22 | #[allow(dead_code)] 23 | impl TriangleRenderComponentManager { 24 | pub fn new(mgr: &mut CacheManager) -> TriangleRenderComponentManager { 25 | log(format!("Constructing TriangleRenderComponentManager")); 26 | 27 | let mut data: Vec = Vec::new(); 28 | for _i in 0..ENTITY_SZ { 29 | data.push(TriangleBuffer { 30 | pnts: Vec::new(), 31 | clrs: Vec::new(), 32 | }); 33 | } 34 | 35 | // allocate system memory in cache 36 | let sz_bytes = std::mem::size_of::() * ENTITY_SZ; 37 | let cache_data = mgr.allocate(sz_bytes) as *mut TriangleRenderComponentManagerData; 38 | 39 | TriangleRenderComponentManager { 40 | data: Box::new(data), 41 | cache_data, 42 | } 43 | } 44 | 45 | pub fn clear(&mut self) { 46 | 47 | } 48 | 49 | pub fn set_triangle_buffer(&mut self, idx: usize, pnts: &Vec, clrs: &Vec) { 50 | self.get_data_ref_mut(idx).reconstruct_needed = true; 51 | self.data[idx].pnts = pnts.clone(); 52 | self.data[idx].clrs = clrs.clone(); 53 | } 54 | 55 | pub fn is_constructed(&self, idx: usize) -> bool { 56 | self.get_data_ref(idx).constructed 57 | } 58 | 59 | pub fn reconstruct(&self, idx: usize) -> bool { 60 | self.get_data_ref(idx).reconstruct_needed 61 | } 62 | 63 | pub fn construct(&self, idx: usize, gl: &Gl, vao: u32, vbo: u32) { 64 | let cache_data = self.get_data_ref_mut(idx); 65 | 66 | let pnts = &self.data[idx].pnts; 67 | let clrs = &self.data[idx].clrs; 68 | 69 | let num_triangles = pnts.len() / 3; 70 | 71 | let mut vertex_data: Vec = Vec::new(); 72 | 73 | for i in 0..pnts.len() { 74 | vertex_data.push(pnts[i].x); 75 | vertex_data.push(pnts[i].y); 76 | vertex_data.push(clrs[i].r); 77 | vertex_data.push(clrs[i].g); 78 | vertex_data.push(clrs[i].b); 79 | vertex_data.push(clrs[i].a); 80 | } 81 | 82 | let data_ptr = vertex_data.as_ptr() as *const _; 83 | gl.buffer_triangle_data(vao, vbo, num_triangles, data_ptr); 84 | 85 | cache_data.reconstruct_needed = false; 86 | cache_data.constructed = true; 87 | cache_data.num_triangles = num_triangles as u16; 88 | } 89 | 90 | pub fn get_num_triangles(&self, idx: usize) -> usize { 91 | self.get_data_ref(idx).num_triangles as usize 92 | } 93 | 94 | fn get_data_ref_mut(&self, idx: usize) -> &mut TriangleRenderComponentManagerData { 95 | assert!(idx < ENTITY_SZ); 96 | unsafe { &mut *(self.cache_data.offset(idx as isize)) } 97 | } 98 | 99 | fn get_data_ref(&self, idx: usize) -> &TriangleRenderComponentManagerData { 100 | assert!(idx < ENTITY_SZ); 101 | unsafe { &*(self.cache_data.offset(idx as isize)) } 102 | } 103 | } 104 | -------------------------------------------------------------------------------- /src/mgfw/ecs/component_scale.rs: -------------------------------------------------------------------------------- 1 | use super::*; 2 | use crate::mgfw::log; 3 | 4 | #[derive(Debug, Copy, Clone)] 5 | pub struct Scale { 6 | pub x: f32, 7 | pub y: f32, 8 | } 9 | 10 | pub struct ScaleComponentManager { 11 | data: *mut Scale, 12 | // WARNING: Anything below this line is not in cache! 13 | } 14 | 15 | #[allow(dead_code)] 16 | impl ScaleComponentManager { 17 | pub fn new(mgr: &mut CacheManager) -> ScaleComponentManager { 18 | log(format!("Constructing ScaleComponentManager")); 19 | let sz_bytes = std::mem::size_of::() * ENTITY_SZ; 20 | ScaleComponentManager { 21 | data: mgr.allocate(sz_bytes) as *mut Scale, 22 | } 23 | } 24 | 25 | pub fn clear(&mut self) { 26 | for i in 0..ENTITY_SZ { 27 | self.set_scale(i, 0.0, 0.0); 28 | } 29 | } 30 | 31 | pub fn set_scale(&self, idx: usize, x: f32, y: f32) { 32 | let scale = self.get_data_ref_mut(idx); 33 | scale.x = x; 34 | scale.y = y; 35 | } 36 | 37 | pub fn get_scale(&self, idx: usize) -> Scale { 38 | let scale = self.get_data_ref(idx); 39 | scale.clone() 40 | } 41 | 42 | pub fn get_data_ref_mut(&self, idx: usize) -> &mut Scale { 43 | assert!(idx < ENTITY_SZ); 44 | unsafe { &mut *(self.data.offset(idx as isize)) } 45 | } 46 | 47 | pub fn get_data_ref(&self, idx: usize) -> &Scale { 48 | assert!(idx < ENTITY_SZ); 49 | unsafe { &*(self.data.offset(idx as isize)) } 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /src/mgfw/ecs/entity.rs: -------------------------------------------------------------------------------- 1 | use super::*; 2 | use crate::mgfw::log; 3 | 4 | pub const ENTITY_SZ: usize = 256; // limit to 256 5 | 6 | #[derive(Copy, Clone)] 7 | pub struct EntityIdSpan { 8 | pub first: usize, 9 | pub last: usize, 10 | } 11 | 12 | struct Entity { 13 | components: u32, 14 | } 15 | 16 | pub struct EntityRegistry { 17 | data: *mut Entity, 18 | // WARNING: Anything below this line is not in cache! 19 | cursor: usize, // current insertion cursor 20 | span: EntityIdSpan, 21 | } 22 | 23 | #[allow(dead_code)] 24 | impl EntityRegistry { 25 | pub fn new(mgr: &mut CacheManager) -> EntityRegistry { 26 | log(format!("Constructing EntityRegistry")); 27 | let sz_bytes = std::mem::size_of::() * ENTITY_SZ; 28 | EntityRegistry { 29 | data: mgr.allocate(sz_bytes) as *mut Entity, 30 | cursor: 0, 31 | span: EntityIdSpan { 32 | first: ENTITY_SZ - 1, 33 | last: 0, 34 | }, 35 | } 36 | } 37 | 38 | pub fn clear(&mut self) { 39 | self.cursor = 0; 40 | self.span = EntityIdSpan { first: ENTITY_SZ - 1, last: 0 }; 41 | for i in 0..ENTITY_SZ { 42 | self.get_data_ref_mut(i).components = 0; 43 | } 44 | } 45 | 46 | pub fn add(&mut self) -> usize { 47 | // find first non-active entity 48 | for _i in 0..ENTITY_SZ { 49 | if !self.has_component(self.cursor, COMPONENT_ACTIVE) { 50 | break; 51 | } 52 | self.cursor = (self.cursor + 1) % ENTITY_SZ; // wrap around 53 | } 54 | 55 | if self.has_component(self.cursor, COMPONENT_ACTIVE) { 56 | log(format!( 57 | "WARNING: EntityRegistry: Ran out of available entity slots!" 58 | )); 59 | assert!(false); // make sure we actually found an open slot 60 | } 61 | self.add_component(self.cursor, COMPONENT_ACTIVE); // set to used 62 | self.cursor 63 | } 64 | 65 | pub fn add_component(&mut self, idx: usize, component: u32) { 66 | let entity = self.get_data_ref_mut(idx); 67 | entity.components |= component; 68 | 69 | // lazy span update 70 | if idx < self.span.first { 71 | self.span.first = idx; 72 | } 73 | if idx > self.span.last { 74 | self.span.last = idx; 75 | } 76 | } 77 | 78 | pub fn has_component(&self, idx: usize, component: u32) -> bool { 79 | let entity = self.get_data_ref(idx); 80 | (entity.components & component) == component 81 | } 82 | 83 | pub fn set_active(&mut self, idx: usize, val: bool) { 84 | self.overwrite_component(idx, COMPONENT_VISIBLE, val); 85 | } 86 | 87 | pub fn is_active(&self, idx: usize) -> bool { 88 | return self.has_component(idx, COMPONENT_ACTIVE); 89 | } 90 | 91 | pub fn set_visibility(&mut self, idx: usize, val: bool) { 92 | self.overwrite_component(idx, COMPONENT_VISIBLE, val); 93 | } 94 | 95 | pub fn is_visible(&self, idx: usize) -> bool { 96 | return self.has_component(idx, COMPONENT_VISIBLE); 97 | } 98 | 99 | pub fn clear_component(&mut self, idx: usize, component: u32) { 100 | let entity = self.get_data_ref_mut(idx); 101 | entity.components &= !component; 102 | 103 | // check if span can be updated 104 | if COMPONENT_ACTIVE == component && (idx == self.span.first || idx == self.span.last) { 105 | self.update_span(); 106 | } 107 | } 108 | 109 | pub fn overwrite_component(&mut self, idx: usize, component: u32, val: bool) { 110 | self.clear_component(idx, component); 111 | if val { 112 | self.add_component(idx, component); 113 | } 114 | } 115 | 116 | pub fn get_id_span(&self) -> EntityIdSpan { 117 | self.span 118 | } 119 | 120 | fn update_span(&mut self) { 121 | self.span = EntityIdSpan { 122 | first: ENTITY_SZ - 1, 123 | last: 0, 124 | }; 125 | for idx in 0..ENTITY_SZ { 126 | if self.has_component(idx, COMPONENT_ACTIVE) { 127 | if idx < self.span.first { 128 | self.span.first = idx; 129 | } 130 | if idx > self.span.last { 131 | self.span.last = idx; 132 | } 133 | } 134 | } 135 | } 136 | 137 | fn get_data_ref_mut(&self, idx: usize) -> &mut Entity { 138 | assert!(idx < ENTITY_SZ); 139 | unsafe { &mut *(self.data.offset(idx as isize)) } 140 | } 141 | 142 | fn get_data_ref(&self, idx: usize) -> &Entity { 143 | assert!(idx < ENTITY_SZ); 144 | unsafe { &*(self.data.offset(idx as isize)) } 145 | } 146 | } 147 | -------------------------------------------------------------------------------- /src/mgfw/ecs/mod.rs: -------------------------------------------------------------------------------- 1 | #![allow(dead_code)] 2 | 3 | pub mod component_angle; 4 | pub mod component_color; 5 | pub mod component_easing; 6 | pub mod component_frame; 7 | pub mod component_physics; 8 | pub mod component_position; 9 | pub mod component_render; 10 | pub mod component_render_billboard; 11 | pub mod component_render_line_buffer; 12 | pub mod component_render_text; 13 | pub mod component_render_tilemap; 14 | pub mod component_render_triangle_buffer; 15 | pub mod component_scale; 16 | pub mod entity; 17 | pub mod system_easing; 18 | pub mod system_physics; 19 | pub mod system_render; 20 | pub mod mgui; 21 | pub mod world; 22 | pub mod ugui; 23 | pub mod uigrid; 24 | 25 | use entity::*; 26 | use mgui::*; 27 | use ugui::*; 28 | use uigrid::*; 29 | pub use world::*; 30 | 31 | pub use component_angle::*; 32 | pub use component_color::*; 33 | use component_easing::*; 34 | use component_frame::*; 35 | pub use component_physics::*; 36 | pub use component_position::*; 37 | use component_render::*; 38 | use component_render_billboard::*; 39 | use component_render_line_buffer::*; 40 | use component_render_text::*; 41 | pub use component_render_tilemap::*; 42 | use component_render_triangle_buffer::*; 43 | pub use component_scale::*; 44 | 45 | pub use system_easing::*; 46 | pub use system_physics::*; 47 | pub use system_render::*; 48 | 49 | use super::cache::CacheManager; 50 | use super::fonts; 51 | use super::support::Gl; 52 | 53 | pub const COMPONENT_ACTIVE: u32 = 1 << 0; 54 | pub const COMPONENT_POSITION: u32 = 1 << 1; 55 | pub const COMPONENT_RENDER: u32 = 1 << 2; 56 | pub const COMPONENT_VISIBLE: u32 = 1 << 3; 57 | pub const COMPONENT_PHYSICS: u32 = 1 << 4; 58 | pub const COMPONENT_ANGLE: u32 = 1 << 5; 59 | pub const COMPONENT_SCALE: u32 = 1 << 6; 60 | pub const COMPONENT_COLOR: u32 = 1 << 7; 61 | pub const COMPONENT_FRAME: u32 = 1 << 8; 62 | pub const EMPTY_TILE: u16 = 0; 63 | -------------------------------------------------------------------------------- /src/mgfw/ecs/system_easing.rs: -------------------------------------------------------------------------------- 1 | use super::*; 2 | use crate::mgfw::log; 3 | 4 | struct EasingSystemData { 5 | _temp: usize, 6 | } 7 | 8 | pub struct EasingSystem { 9 | data: *mut EasingSystemData, 10 | // WARNING: Anything below this line is not in cache! 11 | frame: usize, 12 | } 13 | 14 | #[allow(dead_code)] 15 | impl EasingSystem { 16 | pub fn new(mgr: &mut CacheManager) -> EasingSystem { 17 | log(format!("Constructing EasingSystem")); 18 | // allocate system memory in cache 19 | let sz_bytes = std::mem::size_of::(); 20 | let data = mgr.allocate(sz_bytes) as *mut EasingSystemData; 21 | 22 | EasingSystem { data, frame: 0 } 23 | } 24 | 25 | pub fn update(&mut self, world: &mut World, micros: u128) -> bool { 26 | let expect_blown = false; 27 | 28 | //let ecm = world.get_manager_easing(); 29 | let span = world.get_manager_easing().get_id_span(); 30 | let dt = micros as f32 * 1.0e-6; 31 | 32 | for e in span.first..=span.last { 33 | let data = world.get_manager_easing().get_data_ref(e).clone(); 34 | match data.variable { 35 | EASING_VAR_ALPHA => { 36 | let cur = world.entity_get_alpha(data.entity as usize); 37 | let mut upd = ease(cur, data.dxdt, dt); 38 | let err = (data.end - upd) / data.dxdt; 39 | if 0.0 > err { 40 | upd = data.end; 41 | world.easing_disable(e); 42 | } 43 | world.entity_set_alpha(data.entity as usize, upd); 44 | } 45 | _ => (), 46 | } 47 | } 48 | 49 | self.frame += 1; 50 | expect_blown 51 | } 52 | 53 | fn get_data_ref_mut(&self) -> &mut EasingSystemData { 54 | unsafe { &mut *(self.data.offset(0)) } 55 | } 56 | 57 | fn get_data_ref(&self) -> &EasingSystemData { 58 | unsafe { &*(self.data.offset(0)) } 59 | } 60 | } 61 | 62 | fn ease(current: f32, dxdt: f32, dt: f32) -> f32 { 63 | current + dxdt * dt 64 | } 65 | -------------------------------------------------------------------------------- /src/mgfw/ecs/system_physics.rs: -------------------------------------------------------------------------------- 1 | use super::*; 2 | use crate::mgfw::log; 3 | 4 | struct PhysicsSystemData { 5 | frame: usize, 6 | } 7 | 8 | pub struct PhysicsSystem { 9 | data: *mut PhysicsSystemData, 10 | // WARNING: Anything below this line is not in cache! 11 | } 12 | 13 | #[allow(dead_code)] 14 | impl PhysicsSystem { 15 | pub fn new(mgr: &mut CacheManager) -> PhysicsSystem { 16 | log(format!("Constructing PhysicsSystem")); 17 | // allocate system memory in cache 18 | let sz_bytes = std::mem::size_of::(); 19 | let data = mgr.allocate(sz_bytes) as *mut PhysicsSystemData; 20 | 21 | PhysicsSystem { data } 22 | } 23 | 24 | fn skip_entity(&self, idx: usize, world: &World) -> bool { 25 | let ent = world.get_entities(); 26 | if !ent.is_active(idx) || !ent.has_component(idx, COMPONENT_PHYSICS) { 27 | return true; 28 | } 29 | false 30 | } 31 | 32 | pub fn update(&mut self, world: &mut World, micros: u128) -> bool { 33 | let expect_blown = false; 34 | let data = self.get_data_ref_mut(); 35 | let ent = world.get_entities(); 36 | let pcm = world.get_manager_position(); 37 | let acm = world.get_manager_angle(); 38 | let phcm = world.get_manager_physics(); 39 | 40 | let span = ent.get_id_span(); 41 | for i in span.first..=span.last { 42 | if self.skip_entity(i, world) { 43 | continue; 44 | } 45 | 46 | // Amortize workload 47 | match data.frame % 2 { 48 | // priority 1 49 | 0 => { 50 | let dt = micros as f32 * 1.0e-6 * 2.0; // 150hz 51 | let accel = phcm.get_acceleration(i); 52 | let mut vel = phcm.get_velocity(i); 53 | let mut pos = pcm.get_position(i); 54 | 55 | pos.x += vel.x * dt; 56 | pos.y += vel.y * dt; 57 | vel.x += accel.x * dt; 58 | vel.y += accel.y * dt; 59 | 60 | pcm.set_position(i, pos.x, pos.y); 61 | phcm.set_velocity(i, vel.x, vel.y); 62 | 63 | let avel = phcm.get_angular_velocity(i); 64 | let mut ang = acm.get_angle(i); 65 | 66 | ang += avel * dt; 67 | acm.set_angle(i, ang); 68 | } 69 | 70 | // priority 2 71 | 1 => (), 72 | 73 | // 74 | _ => (), 75 | } 76 | } 77 | data.frame += 1; 78 | expect_blown 79 | } 80 | 81 | fn get_data_ref_mut(&self) -> &mut PhysicsSystemData { 82 | unsafe { &mut *(self.data.offset(0)) } 83 | } 84 | 85 | fn get_data_ref(&self) -> &PhysicsSystemData { 86 | unsafe { &*(self.data.offset(0)) } 87 | } 88 | } 89 | -------------------------------------------------------------------------------- /src/mgfw/ecs/system_render.rs: -------------------------------------------------------------------------------- 1 | use super::*; 2 | use crate::mgfw::log; 3 | 4 | struct RenderSystemData { 5 | vao_pri: u32, 6 | vbo_pri: u32, 7 | } 8 | 9 | pub struct RenderSystem { 10 | data: *mut RenderSystemData, 11 | // WARNING: Anything below this line is not in cache! 12 | frame: usize, 13 | screen_vao: u32, 14 | } 15 | 16 | #[allow(dead_code)] 17 | impl RenderSystem { 18 | pub fn new(mgr: &mut CacheManager, gl: &Gl) -> RenderSystem { 19 | log(format!("Constructing RenderSystem")); 20 | // allocate system memory in cache 21 | let sz_bytes = std::mem::size_of::() * ENTITY_SZ; 22 | let data = mgr.allocate(sz_bytes) as *mut RenderSystemData; 23 | 24 | // screen quad VAO 25 | let screen_vao: u32 = gl.gen_vao(); 26 | let screen_vbo: u32 = gl.gen_vbo(); 27 | 28 | let mut vertex_data: Vec = Vec::new(); 29 | 30 | let w: f32 = 1.0; 31 | 32 | vertex_data.extend_from_slice(&[-w, -w]); // pos 33 | vertex_data.extend_from_slice(&[0.0, 0.0]); // uv 34 | 35 | vertex_data.extend_from_slice(&[-w, w]); // pos 36 | vertex_data.extend_from_slice(&[0.0, 1.0]); // uv 37 | 38 | vertex_data.extend_from_slice(&[w, w]); // pos 39 | vertex_data.extend_from_slice(&[1.0, 1.0]); // uv 40 | 41 | vertex_data.extend_from_slice(&[-w, -w]); // pos 42 | vertex_data.extend_from_slice(&[0.0, 0.0]); // uv 43 | 44 | vertex_data.extend_from_slice(&[w, w]); // pos 45 | vertex_data.extend_from_slice(&[1.0, 1.0]); // uv 46 | 47 | vertex_data.extend_from_slice(&[w, -w]); // pos 48 | vertex_data.extend_from_slice(&[1.0, 0.0]); // uv 49 | 50 | gl.buffer_billboard_data(screen_vao, screen_vbo, vertex_data.as_ptr() as *const _); 51 | 52 | let ret = RenderSystem { 53 | data, 54 | frame: 0, 55 | screen_vao, 56 | }; 57 | 58 | // pre-generate a VAO/VBO for each entity 59 | for i in 0..ENTITY_SZ { 60 | let d = ret.get_data_ref_mut(i); 61 | d.vao_pri = gl.gen_vao(); 62 | d.vbo_pri = gl.gen_vbo(); 63 | } 64 | ret 65 | } 66 | 67 | fn skip_entity(&self, idx: usize, world: &World) -> bool { 68 | let ent = world.get_entities(); 69 | let rcm = world.get_manager_render(); 70 | if !ent.is_active(idx) 71 | || !ent.has_component(idx, COMPONENT_RENDER) 72 | || rcm.has_type(idx, RENDER_TYPE_INVALID) 73 | { 74 | return true; 75 | } 76 | false 77 | } 78 | 79 | pub fn update(&mut self, gl: &Gl, world: &mut World) -> bool { 80 | let mut expect_blown = false; 81 | 82 | let span = world.get_entities().get_id_span(); 83 | for i in span.first..=span.last { 84 | if self.skip_entity(i, world) { 85 | continue; 86 | } 87 | 88 | expect_blown |= self.update_vbo(i, gl, world); 89 | 90 | //// to do - figure out why this doesn't work correctly 91 | /*// Amortize workload 92 | match self.frame % 2 { 93 | // priority 1 94 | 0 => (), 95 | 96 | // priority 2 97 | 1 => { 98 | //expect_blown |= self.update_vbo(i, gl, world); 99 | if expect_blown { 100 | //break; 101 | } // don't update all VBOs every frame 102 | } 103 | _ => (), 104 | }*/ 105 | } 106 | self.frame += 1; 107 | expect_blown 108 | } 109 | 110 | // WARNING: Expect Blown 111 | fn update_vbo(&self, idx: usize, gl: &Gl, world: &mut World) -> bool { 112 | let mut expect_blown = false; 113 | 114 | // Update Text VBOs 115 | match world.get_manager_render().get_type(idx) { 116 | RENDER_TYPE_LINE_BUFFER => { 117 | if world.get_manager_line().reconstruct(idx) { 118 | let dat = self.get_data_ref(idx); 119 | world.line_buffer_construct(idx, gl, dat.vao_pri, dat.vbo_pri); 120 | expect_blown = true; 121 | } 122 | } 123 | RENDER_TYPE_TRIANGLE_BUFFER => { 124 | if world.get_manager_triangle().reconstruct(idx) { 125 | let dat = self.get_data_ref(idx); 126 | world.triangle_buffer_construct(idx, gl, dat.vao_pri, dat.vbo_pri); 127 | expect_blown = true; 128 | } 129 | } 130 | RENDER_TYPE_TEXT => { 131 | if world.get_manager_text().reconstruct(idx) { 132 | let dat = self.get_data_ref(idx); 133 | world.text_construct(idx, gl, dat.vao_pri, dat.vbo_pri); 134 | expect_blown = true; 135 | } 136 | } 137 | RENDER_TYPE_BILLBOARD => { 138 | if world.get_manager_billboard().reconstruct(idx) { 139 | let dat = self.get_data_ref(idx); 140 | world.billboard_construct(idx, gl, dat.vao_pri, dat.vbo_pri); 141 | expect_blown = true; 142 | } 143 | } 144 | RENDER_TYPE_TILEMAP => { 145 | if world.get_manager_tilemap().reconstruct(idx) { 146 | let tileset = world.tilemap_get_tileset_idx(idx); 147 | world.billboard_load_image(tileset, gl); 148 | let dat = self.get_data_ref(idx); 149 | world.tilemap_construct(idx, gl, dat.vao_pri, dat.vbo_pri); 150 | expect_blown = true; 151 | } 152 | } 153 | _ => (), 154 | } 155 | expect_blown 156 | } 157 | 158 | pub fn render(&self, gl: &Gl, world: &mut World, start_time: std::time::Instant) { 159 | let pcm = world.get_manager_position(); 160 | let scm = world.get_manager_scale(); 161 | let acm = world.get_manager_angle(); 162 | let fcm = world.get_manager_frame(); 163 | let phcm = world.get_manager_physics(); 164 | let rcm = world.get_manager_render(); 165 | let tcm = world.get_manager_text(); 166 | let bbcm = world.get_manager_billboard(); 167 | let tmcm = world.get_manager_tilemap(); 168 | let lcm = world.get_manager_line(); 169 | let trm = world.get_manager_triangle(); 170 | let ent = world.get_entities(); 171 | 172 | // draw game entities 173 | gl.bind_framebuffer(); 174 | if world.ugui.is_constructed() { 175 | gl.clear_frame(); 176 | 177 | let span = ent.get_id_span(); 178 | for i in span.first..=span.last { 179 | if !ent.is_visible(i) || self.skip_entity(i, world) { 180 | continue; 181 | } 182 | let color = world.entity_get_color(i); 183 | 184 | let mut angle = 0.0 as f32; 185 | if ent.has_component(i, COMPONENT_ANGLE) { 186 | angle = acm.get_angle(i); 187 | } 188 | 189 | let mut scale = Scale { x: 1.0, y: 1.0 }; 190 | if ent.has_component(i, COMPONENT_SCALE) { 191 | scale = scm.get_scale(i); 192 | } 193 | 194 | let dt = std::time::Instant::now() 195 | .duration_since(start_time) 196 | .as_micros() as f32 197 | * 1.0e-6; 198 | 199 | match rcm.get_type(i) { 200 | RENDER_TYPE_LINE_BUFFER => { 201 | if lcm.is_constructed(i) { 202 | let vao = self.get_data_ref(i).vao_pri; 203 | let pos = pcm.get_data_ref(i); 204 | let phys = phcm.get_data_ref(i); 205 | gl.draw_lines( 206 | pos.x + phys.velocity.x * dt, 207 | pos.y + phys.velocity.y * dt, 208 | angle, 209 | scale.x, 210 | scale.y, 211 | vao, 212 | lcm.get_num_lines(i), 213 | color, 214 | ); 215 | } 216 | } 217 | RENDER_TYPE_TRIANGLE_BUFFER => { 218 | if trm.is_constructed(i) { 219 | let vao = self.get_data_ref(i).vao_pri; 220 | let pos = pcm.get_data_ref(i); 221 | let phys = phcm.get_data_ref(i); 222 | gl.draw_triangles( 223 | pos.x + phys.velocity.x * dt, 224 | pos.y + phys.velocity.y * dt, 225 | angle, 226 | scale.x, 227 | scale.y, 228 | vao, 229 | trm.get_num_triangles(i), 230 | color, 231 | ); 232 | } 233 | } 234 | RENDER_TYPE_TEXT => { 235 | if tcm.is_constructed(i) && !tcm.reconstruct(i) { 236 | let vao = self.get_data_ref(i).vao_pri; 237 | let pos = pcm.get_data_ref(i); 238 | let phys = phcm.get_data_ref(i); 239 | gl.draw_text( 240 | pos.x + phys.velocity.x * dt, 241 | pos.y + phys.velocity.y * dt, 242 | angle, 243 | scale.x, 244 | scale.y, 245 | vao, 246 | tcm.get_length(i) as i32, 247 | color, 248 | ); 249 | } 250 | } 251 | RENDER_TYPE_BILLBOARD => { 252 | if bbcm.is_constructed(i) { 253 | let vao = self.get_data_ref(i).vao_pri; 254 | let pos = pcm.get_data_ref(i); 255 | let phys = phcm.get_data_ref(i); 256 | 257 | let mut framed = false; 258 | let mut u = 0.0 as f32; 259 | let mut v = 0.0 as f32; 260 | let mut du = 1.0 as f32; 261 | let mut dv = 1.0 as f32; 262 | if ent.has_component(i, COMPONENT_FRAME) { 263 | framed = true; 264 | du = 32.0 / 128.0; 265 | dv = 32.0 / 128.0; 266 | 267 | let frame = fcm.get_frame(i); 268 | u = (frame % 4) as f32 * du; 269 | v = ((frame - (frame % 4)) / 4) as f32 * dv; 270 | } 271 | 272 | gl.draw_billboard( 273 | pos.x + phys.velocity.x * dt, 274 | pos.y + phys.velocity.y * dt, 275 | angle, 276 | scale.x, 277 | scale.y, 278 | vao, 279 | bbcm.get_tex_handle(i), 280 | color, 281 | framed, 282 | u, 283 | v, 284 | du, 285 | dv, 286 | ); 287 | } 288 | } 289 | RENDER_TYPE_TILEMAP => { 290 | if tmcm.is_constructed(i) { 291 | let vao = self.get_data_ref(i).vao_pri; 292 | let pos = pcm.get_data_ref(i); 293 | let phys = phcm.get_data_ref(i); 294 | let num_tiles = tmcm.get_num_tiles(i); 295 | let tex_handle = bbcm.get_tex_handle(tmcm.get_tileset_idx(i)); 296 | gl.draw_tilemap( 297 | (pos.x + phys.velocity.x * dt).round(), 298 | (pos.y + phys.velocity.y * dt).round(), 299 | angle, 300 | scale.x, 301 | scale.y, 302 | vao, 303 | num_tiles, 304 | tex_handle, 305 | color, 306 | ); 307 | } 308 | } 309 | 310 | _ => (), 311 | } 312 | } 313 | 314 | // draw gui 315 | if world.mgui.is_constructed() { 316 | world.mgui.render(gl); 317 | } 318 | 319 | if world.ugui.is_constructed() { 320 | world.ugui.render(gl); 321 | } 322 | } 323 | 324 | // draw framebuffer to screen 325 | gl.unbind_framebuffer(); 326 | gl.clear_frame(); 327 | 328 | gl.draw_screen_billboard( 329 | self.screen_vao, 330 | Color { 331 | r: 1.0, 332 | g: 1.0, 333 | b: 1.0, 334 | a: 1.0, 335 | }, 336 | ); 337 | } 338 | 339 | fn get_data_ref_mut(&self, idx: usize) -> &mut RenderSystemData { 340 | assert!(idx < ENTITY_SZ); 341 | unsafe { &mut *(self.data.offset(idx as isize)) } 342 | } 343 | 344 | fn get_data_ref(&self, idx: usize) -> &RenderSystemData { 345 | assert!(idx < ENTITY_SZ); 346 | unsafe { &*(self.data.offset(idx as isize)) } 347 | } 348 | } 349 | -------------------------------------------------------------------------------- /src/mgfw/ecs/uigrid.rs: -------------------------------------------------------------------------------- 1 | 2 | pub const SPLIT_H: u8 = 0; 3 | pub const SPLIT_V: u8 = 1; 4 | 5 | #[derive(Clone)] 6 | pub struct UIgrid { 7 | pub x0: f32, 8 | pub y0: f32, 9 | pub x1: f32, 10 | pub y1: f32, 11 | pub pad: i8, 12 | } 13 | 14 | pub fn new(x0: f32, y0: f32, w0: f32, h0: f32) -> UIgrid { 15 | UIgrid { 16 | x0, 17 | y0, 18 | x1: x0 + w0, 19 | y1: y0 + h0, 20 | pad: 4, 21 | } 22 | } 23 | 24 | impl UIgrid { 25 | pub fn clone(self: &Self) -> UIgrid { 26 | UIgrid { 27 | x0: self.x0, 28 | y0: self.y0, 29 | x1: self.x1, 30 | y1: self.y1, 31 | pad: self.pad, 32 | } 33 | } 34 | 35 | pub fn split_vec(self: &Self, dir: u8, v: Vec) -> Vec { 36 | let mut ret: Vec = Vec::new(); 37 | 38 | if SPLIT_V == dir { 39 | let dy = self.y1 - self.y0; 40 | let mut ug: UIgrid = self.clone(); 41 | let y0 = ug.y0; 42 | for i in 0..v.len() { 43 | ug.y1 = y0 + v[i] * dy; 44 | ret.push(ug.clone()); 45 | ug.y0 = ug.y1; 46 | } 47 | ug.y1 = self.y1; 48 | ret.push(ug); 49 | } 50 | else if SPLIT_H == dir { 51 | let dx = self.x1 - self.x0; 52 | let mut ug: UIgrid = self.clone(); 53 | let x0 = ug.x0; 54 | for i in 0..v.len() { 55 | ug.x1 = x0 + v[i] * dx; 56 | ret.push(ug.clone()); 57 | ug.x0 = ug.x1; 58 | } 59 | ug.x1 = self.x1; 60 | ret.push(ug); 61 | } 62 | 63 | ret 64 | } 65 | 66 | pub fn split_even(self: &Self, dir: u8, qty: i32) -> Vec { 67 | let mut v: Vec = Vec::new(); 68 | let delta = 1.0 / qty as f32; 69 | for i in 1..qty { 70 | v.push(delta * i as f32); 71 | } 72 | self.split_vec(dir, v) 73 | } 74 | 75 | pub fn split(self: &Self, dir: u8, loc: f32) -> Vec { 76 | let mut ret: Vec = Vec::new(); 77 | 78 | if SPLIT_V == dir { 79 | let dy = self.y1 - self.y0; 80 | let mut ug: UIgrid = self.clone(); 81 | ug.y1 = ug.y0 + loc * dy; 82 | ret.push(ug.clone()); 83 | ug.y0 = ug.y1; 84 | ug.y1 = self.y1; 85 | ret.push(ug); 86 | } 87 | else if SPLIT_H == dir { 88 | let dx = self.x1 - self.x0; 89 | let mut ug: UIgrid = self.clone(); 90 | ug.x1 = ug.x0 + loc * dx; 91 | ret.push(ug.clone()); 92 | ug.x0 = ug.x1; 93 | ug.x1 = self.x1; 94 | ret.push(ug); 95 | } 96 | 97 | ret 98 | } 99 | 100 | pub fn pad(self: &Self) -> UIgrid { 101 | UIgrid { 102 | x0: self.x0 + self.pad as f32, 103 | y0: self.y0 + self.pad as f32, 104 | x1: self.x1 - self.pad as f32, 105 | y1: self.y1 - self.pad as f32, 106 | pad: self.pad, 107 | } 108 | } 109 | 110 | pub fn scroll_pad(self: &Self) -> UIgrid { 111 | UIgrid { 112 | x0: self.x0 + self.pad as f32, 113 | y0: self.y0 + self.pad as f32, 114 | x1: self.x1 - self.pad as f32 - 5.0, 115 | y1: self.y1 - self.pad as f32 - 5.0, 116 | pad: self.pad, 117 | } 118 | } 119 | 120 | pub fn tab_pad(self: &Self) -> UIgrid { 121 | UIgrid { 122 | x0: self.x0 + self.pad as f32, 123 | y0: self.y0 + self.pad as f32 + 16.0, 124 | x1: self.x1 - self.pad as f32, 125 | y1: self.y1 - self.pad as f32, 126 | pad: self.pad, 127 | } 128 | } 129 | 130 | pub fn is_inside(self: &Self, x: i32, y: i32) -> bool { 131 | (x > self.x0.floor() as i32) && 132 | (x < self.x1.floor() as i32) && 133 | (y > self.y0.floor() as i32) && 134 | (y < self.y1.floor() as i32) 135 | } 136 | 137 | } 138 | -------------------------------------------------------------------------------- /src/mgfw/ecs/world.rs: -------------------------------------------------------------------------------- 1 | use crate::mgfw::log; 2 | use rand; 3 | use rand::prelude::*; 4 | use std::fs::File; 5 | use std::io::{self, BufRead}; 6 | use std::ops::Range; 7 | 8 | use super::*; 9 | 10 | pub struct World { 11 | // WARNING: Anything below this line is not in cache! 12 | ent: std::boxed::Box, 13 | pcm: std::boxed::Box, 14 | scm: std::boxed::Box, 15 | acm: std::boxed::Box, 16 | phcm: std::boxed::Box, 17 | rcm: std::boxed::Box, 18 | tcm: std::boxed::Box, 19 | bbcm: std::boxed::Box, 20 | tmcm: std::boxed::Box, 21 | lcm: std::boxed::Box, 22 | trm: std::boxed::Box, 23 | ccm: std::boxed::Box, 24 | ecm: std::boxed::Box, 25 | fcm: std::boxed::Box, 26 | pub mouse_x: i32, 27 | pub mouse_y: i32, 28 | pub gamepad_x: f32, 29 | pub gamepad_y: f32, 30 | rng: ThreadRng, 31 | pub mgui: std::boxed::Box, 32 | pub ugui: std::boxed::Box, 33 | } 34 | 35 | #[allow(dead_code)] 36 | impl World { 37 | pub fn new(cache: &mut CacheManager) -> World { 38 | log(format!("Constructing World")); 39 | World { 40 | ent: Box::new(EntityRegistry::new(cache)), 41 | pcm: Box::new(PositionComponentManager::new(cache)), 42 | scm: Box::new(ScaleComponentManager::new(cache)), 43 | acm: Box::new(AngleComponentManager::new(cache)), 44 | phcm: Box::new(PhysicsComponentManager::new(cache)), 45 | rcm: Box::new(RenderComponentManager::new(cache)), 46 | tcm: Box::new(TextRenderComponentManager::new(cache)), 47 | bbcm: Box::new(BillboardRenderComponentManager::new(cache)), 48 | tmcm: Box::new(TilemapRenderComponentManager::new(cache)), 49 | lcm: Box::new(LineRenderComponentManager::new(cache)), 50 | trm: Box::new(TriangleRenderComponentManager::new(cache)), 51 | ccm: Box::new(ColorComponentManager::new(cache)), 52 | ecm: Box::new(EasingComponentManager::new(cache)), 53 | fcm: Box::new(FrameComponentManager::new(cache)), 54 | mouse_x: 0, 55 | mouse_y: 0, 56 | gamepad_x: 0.0, 57 | gamepad_y: 0.0, 58 | rng: rand::thread_rng(), 59 | mgui: Box::new(Mgui::new()), 60 | ugui: Box::new(Ugui::new()), 61 | } 62 | } 63 | 64 | pub fn clear(&mut self) { 65 | self.ent.clear(); 66 | self.pcm.clear(); 67 | self.scm.clear(); 68 | self.acm.clear(); 69 | self.phcm.clear(); 70 | self.rcm.clear(); 71 | self.tcm.clear(); 72 | self.bbcm.clear(); 73 | self.tmcm.clear(); 74 | self.lcm.clear(); 75 | self.trm.clear(); 76 | self.ccm.clear(); 77 | self.ecm.clear(); 78 | self.fcm.clear(); 79 | } 80 | 81 | pub fn rnd(&mut self) -> f32 { 82 | self.rng.gen() 83 | } 84 | 85 | pub fn rnd_range( 86 | &mut self, 87 | range: Range, 88 | ) -> T { 89 | if range.start == range.end { return range.start; } 90 | self.rng.gen_range(range) 91 | } 92 | 93 | pub fn new_entity(&mut self) -> usize { 94 | self.ent.add() 95 | } 96 | 97 | pub fn entity_add_component(&mut self, idx: usize, component: u32) { 98 | self.ent.add_component(idx, component); 99 | } 100 | 101 | pub fn entity_get_angle(&mut self, idx: usize) -> f32 { 102 | self.acm.get_angle(idx) 103 | } 104 | 105 | pub fn entity_set_angle(&mut self, idx: usize, angle: f32) { 106 | self.acm.set_angle(idx, angle); 107 | self.ent.add_component(idx, COMPONENT_ANGLE); 108 | } 109 | 110 | pub fn entity_set_color(&mut self, idx: usize, color: Color) { 111 | self.ccm.set_color(idx, color); 112 | self.ent.add_component(idx, COMPONENT_COLOR); 113 | } 114 | 115 | pub fn entity_set_color_rgba(&mut self, idx: usize, r: f32, g: f32, b: f32, a: f32) { 116 | self.ccm.set_color_rgba(idx, r, g, b, a); 117 | self.ent.add_component(idx, COMPONENT_COLOR); 118 | } 119 | 120 | pub fn entity_get_color(&self, idx: usize) -> Color { 121 | self.ccm.get_color(idx) 122 | } 123 | 124 | pub fn entity_set_alpha(&mut self, idx: usize, alpha: f32) { 125 | self.ccm.set_alpha(idx, alpha); 126 | self.ent.add_component(idx, COMPONENT_COLOR); 127 | } 128 | 129 | pub fn entity_set_alpha_ease(&mut self, idx: usize, start: f32, end: f32, dt: f32) { 130 | self.entity_set_alpha(idx, start); 131 | self.ecm.set_alpha_ease(idx, start, end, dt); 132 | self.ent.add_component(idx, COMPONENT_COLOR); 133 | } 134 | 135 | pub fn entity_get_alpha(&self, idx: usize) -> f32 { 136 | self.ccm.get_alpha(idx) 137 | } 138 | pub fn entity_get_frame(&mut self, idx: usize) -> u16 { 139 | self.fcm.get_frame(idx) 140 | } 141 | 142 | pub fn entity_set_frame(&mut self, idx: usize, frame: u16) { 143 | self.fcm.set_frame(idx, frame); 144 | self.ent.add_component(idx, COMPONENT_FRAME); 145 | } 146 | 147 | pub fn entity_get_position(&self, idx: usize) -> Position { 148 | self.pcm.get_position(idx) 149 | } 150 | 151 | pub fn entity_set_position(&mut self, idx: usize, pos: Position) { 152 | self.pcm.set_position(idx, pos.x, pos.y); 153 | self.ent.add_component(idx, COMPONENT_POSITION); 154 | } 155 | 156 | pub fn entity_set_position_xy(&mut self, idx: usize, x: f32, y: f32) { 157 | self.pcm.set_position(idx, x, y); 158 | self.ent.add_component(idx, COMPONENT_POSITION); 159 | } 160 | 161 | pub fn entity_get_scale(&mut self, idx: usize) -> Scale { 162 | self.scm.get_scale(idx) 163 | } 164 | 165 | pub fn entity_set_scale(&mut self, idx: usize, pos: Scale) { 166 | self.scm.set_scale(idx, pos.x, pos.y); 167 | self.ent.add_component(idx, COMPONENT_SCALE); 168 | } 169 | 170 | pub fn entity_set_scale_xy(&mut self, idx: usize, x: f32, y: f32) { 171 | self.scm.set_scale(idx, x, y); 172 | self.ent.add_component(idx, COMPONENT_SCALE); 173 | } 174 | 175 | pub fn entity_get_velocity(&mut self, idx: usize) -> Velocity { 176 | self.phcm.get_velocity(idx) 177 | } 178 | 179 | pub fn entity_get_acceleration(&mut self, idx: usize) -> Acceleration { 180 | self.phcm.get_acceleration(idx) 181 | } 182 | 183 | pub fn entity_get_angular_velocity(&mut self, idx: usize) -> f32 { 184 | self.phcm.get_angular_velocity(idx) 185 | } 186 | pub fn entity_set_angular_velocity(&mut self, idx: usize, vel: f32) { 187 | self.phcm.set_angular_velocity(idx, vel); 188 | self.ent.add_component(idx, COMPONENT_ANGLE); 189 | self.ent.add_component(idx, COMPONENT_PHYSICS); 190 | } 191 | 192 | pub fn entity_set_velocity(&mut self, idx: usize, vel: Velocity) { 193 | self.phcm.set_velocity(idx, vel.x, vel.y); 194 | self.ent.add_component(idx, COMPONENT_POSITION); 195 | self.ent.add_component(idx, COMPONENT_PHYSICS); 196 | } 197 | 198 | pub fn entity_set_velocity_xy(&mut self, idx: usize, x: f32, y: f32) { 199 | self.phcm.set_velocity(idx, x, y); 200 | self.ent.add_component(idx, COMPONENT_POSITION); 201 | self.ent.add_component(idx, COMPONENT_PHYSICS); 202 | } 203 | 204 | pub fn entity_set_acceleration(&mut self, idx: usize, accel: Acceleration) { 205 | self.phcm.set_acceleration(idx, accel.x, accel.y); 206 | self.ent.add_component(idx, COMPONENT_POSITION); 207 | self.ent.add_component(idx, COMPONENT_PHYSICS); 208 | } 209 | 210 | pub fn entity_set_acceleration_xy(&mut self, idx: usize, x: f32, y: f32) { 211 | self.phcm.set_acceleration(idx, x, y); 212 | self.ent.add_component(idx, COMPONENT_POSITION); 213 | self.ent.add_component(idx, COMPONENT_PHYSICS); 214 | } 215 | 216 | pub fn entity_set_text(&mut self, idx: usize, text: String) { 217 | self.tcm.set_text(idx, text); 218 | self.ent.add_component(idx, COMPONENT_RENDER); 219 | self.rcm.set_type(idx, RENDER_TYPE_TEXT); 220 | } 221 | 222 | pub fn entity_set_billboard(&mut self, idx: usize, image: String) { 223 | self.bbcm.set_image(idx, image); 224 | self.ent.add_component(idx, COMPONENT_RENDER); 225 | self.rcm.set_type(idx, RENDER_TYPE_BILLBOARD); 226 | } 227 | 228 | pub fn entity_get_billboard(&self, idx: usize) -> String { 229 | self.bbcm.get_image(idx) 230 | } 231 | 232 | pub fn entity_set_tileset( 233 | &mut self, 234 | idx: usize, 235 | image: String, 236 | image_width: usize, 237 | image_height: usize, 238 | tile_width: usize, 239 | tile_height: usize, 240 | ) { 241 | self.bbcm.set_image(idx, image); 242 | self.tmcm 243 | .set_tileset(idx, image_width, image_height, tile_width, tile_height); 244 | self.ent.add_component(idx, COMPONENT_RENDER); 245 | self.rcm.set_type(idx, RENDER_TYPE_BILLBOARD); 246 | } 247 | 248 | pub fn entity_set_tilemap( 249 | &mut self, 250 | idx: usize, 251 | tileset_idx: usize, 252 | columns: usize, 253 | data: &Vec, 254 | ) { 255 | if 0 == columns { return; } 256 | self.tmcm.set_tilemap(idx, tileset_idx, columns, data); 257 | self.ent.add_component(idx, COMPONENT_RENDER); 258 | self.rcm.set_type(idx, RENDER_TYPE_TILEMAP); 259 | } 260 | 261 | pub fn entity_set_iso_tilemap( 262 | &mut self, 263 | idx: usize, 264 | tileset_idx: usize, 265 | columns: usize, 266 | data: &Vec, 267 | ) { 268 | if 0 == columns { return; } 269 | self.tmcm.set_iso_tilemap(idx, tileset_idx, columns, data); 270 | self.ent.add_component(idx, COMPONENT_RENDER); 271 | self.rcm.set_type(idx, RENDER_TYPE_TILEMAP); 272 | } 273 | 274 | pub fn tilemap_cell_flip_horizontal( 275 | &mut self, 276 | idx: usize, 277 | cell: usize, 278 | ) { 279 | self.tmcm.cell_flip_horizontal(idx, cell); 280 | } 281 | 282 | pub fn tilemap_cell_flip_vertical( 283 | &mut self, 284 | idx: usize, 285 | cell: usize, 286 | ) { 287 | self.tmcm.cell_flip_vertical(idx, cell); 288 | } 289 | 290 | pub fn tilemap_cell_rotate_cw( 291 | &mut self, 292 | idx: usize, 293 | cell: usize, 294 | ) { 295 | self.tmcm.cell_rotate_cw(idx, cell); 296 | } 297 | 298 | pub fn tilemap_cell_rotate_ccw( 299 | &mut self, 300 | idx: usize, 301 | cell: usize, 302 | ) { 303 | self.tmcm.cell_rotate_ccw(idx, cell); 304 | } 305 | 306 | pub fn tilemap_cell_rotate_180( 307 | &mut self, 308 | idx: usize, 309 | cell: usize, 310 | ) { 311 | self.tmcm.cell_rotate_180(idx, cell); 312 | } 313 | 314 | pub fn entity_set_line_buffer(&mut self, idx: usize, pnts: &Vec, clrs: &Vec) { 315 | self.lcm.set_line_buffer(idx, pnts, clrs); 316 | self.ent.add_component(idx, COMPONENT_RENDER); 317 | self.rcm.set_type(idx, RENDER_TYPE_LINE_BUFFER); 318 | } 319 | 320 | pub fn entity_set_triangle_buffer( 321 | &mut self, 322 | idx: usize, 323 | pnts: &Vec, 324 | clrs: &Vec, 325 | ) { 326 | self.trm.set_triangle_buffer(idx, pnts, clrs); 327 | self.ent.add_component(idx, COMPONENT_RENDER); 328 | self.rcm.set_type(idx, RENDER_TYPE_TRIANGLE_BUFFER); 329 | } 330 | 331 | pub fn entity_set_active(&mut self, idx: usize, val: bool) { 332 | self.ent.set_active(idx, val); 333 | } 334 | 335 | pub fn entity_is_active(&self, idx: usize) -> bool { 336 | self.ent.is_active(idx) 337 | } 338 | 339 | pub fn entity_set_visibility(&mut self, idx: usize, val: bool) { 340 | self.ent.set_visibility(idx, val); 341 | } 342 | 343 | pub fn entity_is_visible(&self, idx: usize) -> bool { 344 | self.ent.is_visible(idx) 345 | } 346 | 347 | pub fn get_entities(&self) -> &EntityRegistry { 348 | &self.ent 349 | } 350 | 351 | // Managers should not be mutable! Use interface functions instead. 352 | 353 | pub fn get_manager_position(&self) -> &PositionComponentManager { 354 | &self.pcm 355 | } 356 | 357 | pub fn get_manager_scale(&self) -> &ScaleComponentManager { 358 | &self.scm 359 | } 360 | 361 | pub fn get_manager_angle(&self) -> &AngleComponentManager { 362 | &self.acm 363 | } 364 | 365 | pub fn get_manager_frame(&self) -> &FrameComponentManager { 366 | &self.fcm 367 | } 368 | 369 | pub fn get_manager_text(&self) -> &TextRenderComponentManager { 370 | &self.tcm 371 | } 372 | 373 | pub fn get_manager_billboard(&self) -> &BillboardRenderComponentManager { 374 | &self.bbcm 375 | } 376 | 377 | pub fn get_manager_render(&self) -> &RenderComponentManager { 378 | &self.rcm 379 | } 380 | 381 | pub fn get_manager_physics(&self) -> &PhysicsComponentManager { 382 | &self.phcm 383 | } 384 | 385 | pub fn get_manager_line(&self) -> &LineRenderComponentManager { 386 | &self.lcm 387 | } 388 | 389 | pub fn get_manager_triangle(&self) -> &TriangleRenderComponentManager { 390 | &self.trm 391 | } 392 | 393 | pub fn get_manager_color(&self) -> &ColorComponentManager { 394 | &self.ccm 395 | } 396 | 397 | pub fn get_manager_easing(&self) -> &EasingComponentManager { 398 | &self.ecm 399 | } 400 | 401 | pub fn get_manager_tilemap(&self) -> &TilemapRenderComponentManager { 402 | &self.tmcm 403 | } 404 | 405 | pub fn easing_disable(&mut self, idx: usize) { 406 | self.ecm.deactivate(idx); 407 | } 408 | 409 | pub fn text_get_width(&self, idx: usize) -> usize { 410 | self.tcm.get_width(idx) 411 | } 412 | 413 | pub fn text_construct(&self, idx: usize, gl: &Gl, vao: u32, vbo: u32) { 414 | self.tcm.construct(idx, gl, vao, vbo); 415 | } 416 | 417 | pub fn text_is_constructed(&self, idx: usize) -> bool { 418 | self.tcm.is_constructed(idx) 419 | } 420 | 421 | pub fn text_reconstruct(&self, idx: usize) -> bool { 422 | self.tcm.reconstruct(idx) 423 | } 424 | 425 | pub fn billboard_construct(&mut self, idx: usize, gl: &Gl, vao: u32, vbo: u32) { 426 | self.bbcm.construct(idx, gl, vao, vbo); 427 | } 428 | 429 | pub fn billboard_load_image(&mut self, idx: usize, gl: &Gl) { 430 | self.bbcm.load_image(idx, gl); 431 | } 432 | 433 | pub fn line_buffer_construct(&self, idx: usize, gl: &Gl, vao: u32, vbo: u32) { 434 | self.lcm.construct(idx, gl, vao, vbo); 435 | } 436 | 437 | pub fn tilemap_construct(&mut self, idx: usize, gl: &Gl, vao: u32, vbo: u32) { 438 | self.tmcm.construct(idx, gl, vao, vbo); 439 | } 440 | 441 | pub fn tilemap_get_tileset_idx(&mut self, idx: usize) -> usize { 442 | self.tmcm.get_tileset_idx(idx) 443 | } 444 | 445 | pub fn triangle_buffer_construct(&self, idx: usize, gl: &Gl, vao: u32, vbo: u32) { 446 | self.trm.construct(idx, gl, vao, vbo); 447 | } 448 | 449 | pub fn parse_world(&mut self, filename: &str) { 450 | log(format!("World: Parsing '{}'", filename)); 451 | 452 | let file = File::open(filename).unwrap(); 453 | let reader = io::BufReader::new(file); 454 | 455 | for line in reader.lines() { 456 | let line = line.unwrap(); 457 | 458 | let len = line.len(); 459 | if 2 > len { 460 | continue; 461 | } 462 | 463 | let bytes = line.as_bytes(); 464 | if b'/' == bytes[0] && b'/' == bytes[1] { 465 | continue; 466 | } 467 | 468 | //log(format!("{:?}", line)); 469 | 470 | let split: Vec<&str> = line.split(',').collect(); 471 | if 1 > split.len() { 472 | continue; 473 | } 474 | 475 | let id = split[0].parse::().unwrap(); 476 | if id >= entity::ENTITY_SZ { 477 | continue; 478 | } 479 | 480 | let component = split[1]; 481 | 482 | match component { 483 | "text" => { 484 | if 3 <= split.len() { 485 | let val = split[2].replace("\"", ""); 486 | self.ent.add_component(id, COMPONENT_ACTIVE); 487 | self.entity_set_text(id, val); 488 | } 489 | } 490 | "color" => { 491 | if 5 == split.len() { 492 | let r = split[2].parse::().unwrap(); 493 | let g = split[3].parse::().unwrap(); 494 | let b = split[4].parse::().unwrap(); 495 | self.entity_set_color_rgba(id, r, g, b, 1.0); 496 | } else if 6 == split.len() { 497 | let r = split[2].parse::().unwrap(); 498 | let g = split[3].parse::().unwrap(); 499 | let b = split[4].parse::().unwrap(); 500 | let a = split[5].parse::().unwrap(); 501 | self.entity_set_color_rgba(id, r, g, b, a); 502 | } 503 | } 504 | "billboard" => { 505 | if 3 == split.len() { 506 | let image = split[2]; 507 | self.ent.add_component(id, COMPONENT_ACTIVE); 508 | self.entity_set_billboard(id, String::from(image)); 509 | } 510 | } 511 | "linebuffer" => { 512 | let n = split.len() - 2; 513 | let n_lines: usize = n / 12; 514 | let n_points: usize = n_lines * 2; 515 | if n_lines * 12 == n { 516 | let mut pnts: Vec = Vec::new(); 517 | let mut clrs: Vec = Vec::new(); 518 | 519 | for p in 0..n_points { 520 | let pidx: usize = 2 + p * 6; 521 | pnts.push(Position { 522 | x: split[pidx + 0].parse::().unwrap(), 523 | y: split[pidx + 1].parse::().unwrap(), 524 | }); 525 | clrs.push(Color { 526 | r: split[pidx + 2].parse::().unwrap(), 527 | g: split[pidx + 3].parse::().unwrap(), 528 | b: split[pidx + 4].parse::().unwrap(), 529 | a: split[pidx + 5].parse::().unwrap(), 530 | }); 531 | } 532 | self.ent.add_component(id, COMPONENT_ACTIVE); 533 | self.entity_set_line_buffer(id, &pnts, &clrs); 534 | } 535 | } 536 | "tribuffer" => { 537 | let n = split.len() - 2; 538 | let n_triangles: usize = n / 18; 539 | let n_points: usize = n_triangles * 3; 540 | if n_triangles * 18 == n { 541 | let mut pnts: Vec = Vec::new(); 542 | let mut clrs: Vec = Vec::new(); 543 | 544 | for p in 0..n_points { 545 | let pidx: usize = 2 + p * 6; 546 | pnts.push(Position { 547 | x: split[pidx + 0].parse::().unwrap(), 548 | y: split[pidx + 1].parse::().unwrap(), 549 | }); 550 | clrs.push(Color { 551 | r: split[pidx + 2].parse::().unwrap(), 552 | g: split[pidx + 3].parse::().unwrap(), 553 | b: split[pidx + 4].parse::().unwrap(), 554 | a: split[pidx + 5].parse::().unwrap(), 555 | }); 556 | } 557 | self.ent.add_component(id, COMPONENT_ACTIVE); 558 | self.entity_set_triangle_buffer(id, &pnts, &clrs); 559 | } 560 | } 561 | "visible" => { 562 | if 3 == split.len() { 563 | let val = split[2]; 564 | match val { 565 | "true" => self.ent.set_visibility(id, true), 566 | "false" => self.ent.set_visibility(id, false), 567 | _ => (), 568 | } 569 | } 570 | } 571 | "position" => { 572 | if 4 == split.len() { 573 | let x = split[2].parse::().unwrap(); 574 | let y = split[3].parse::().unwrap(); 575 | self.ent.add_component(id, COMPONENT_ACTIVE); 576 | self.entity_set_position_xy(id, x, y); 577 | } 578 | } 579 | "velocity" => { 580 | if 4 == split.len() { 581 | let x = split[2].parse::().unwrap(); 582 | let y = split[3].parse::().unwrap(); 583 | self.ent.add_component(id, COMPONENT_ACTIVE); 584 | self.entity_set_velocity_xy(id, x, y); 585 | } 586 | } 587 | "scale" => { 588 | if 3 <= split.len() { 589 | let x = split[2].parse::().unwrap(); 590 | let mut y = 1.0 as f32; 591 | if 4 == split.len() { 592 | y = split[3].parse::().unwrap(); 593 | } 594 | self.ent.add_component(id, COMPONENT_ACTIVE); 595 | self.entity_set_scale_xy(id, x, y); 596 | } 597 | } 598 | "angle" => { 599 | if 3 == split.len() { 600 | let angle = split[2].parse::().unwrap(); 601 | self.ent.add_component(id, COMPONENT_ACTIVE); 602 | self.entity_set_angle(id, crate::mgfw::deg2rad(angle)); 603 | } 604 | } 605 | "alpha" => { 606 | if 3 == split.len() { 607 | let alpha = split[2].parse::().unwrap(); 608 | self.ent.add_component(id, COMPONENT_COLOR); 609 | self.entity_set_alpha(id, alpha); 610 | } 611 | } 612 | "angular_velocity" => { 613 | if 3 == split.len() { 614 | let avel = split[2].parse::().unwrap(); 615 | self.ent.add_component(id, COMPONENT_ACTIVE); 616 | self.entity_set_angular_velocity(id, crate::mgfw::deg2rad(avel)); 617 | } 618 | } 619 | "acceleration" => { 620 | if 4 == split.len() { 621 | let x = split[2].parse::().unwrap(); 622 | let y = split[3].parse::().unwrap(); 623 | self.ent.add_component(id, COMPONENT_ACTIVE); 624 | self.entity_set_acceleration_xy(id, x, y); 625 | } 626 | } 627 | _ => (), 628 | } 629 | } 630 | } 631 | } 632 | -------------------------------------------------------------------------------- /src/mgfw/fonts/alagard.rs: -------------------------------------------------------------------------------- 1 | use std::collections::HashMap; 2 | 3 | pub struct Font { 4 | pub scale_w: i32, 5 | pub scale_h: i32, 6 | pub page_files: Vec, 7 | pub data: HashMap, 8 | } 9 | 10 | impl Font { 11 | pub fn new() -> Font { 12 | Font { 13 | scale_w: 256, 14 | scale_h: 64, 15 | page_files: get_pages(), 16 | data: get_data(), 17 | } 18 | } 19 | } 20 | 21 | fn get_pages() -> Vec { 22 | let mut pages: Vec = Vec::new(); 23 | pages.push(String::from("assets/mgfw/alagard.png")); 24 | pages 25 | } 26 | 27 | #[rustfmt::skip] 28 | fn get_data() -> HashMap { 29 | let mut data: HashMap = HashMap::new(); 30 | 31 | //char id=32 x=42 y=37 width=3 height=1 xoffset=-1 yoffset=14 xadvance=5 page=0 32 | data.insert(32 ,[42 ,37 ,3 ,1 ,-1 ,14 ,5 ,0 ]); 33 | data.insert(33 ,[15 ,27 ,4 ,11 ,0 ,1 ,5 ,0 ]); 34 | data.insert(34 ,[240 ,24 ,7 ,5 ,0 ,1 ,8 ,0 ]); 35 | data.insert(35 ,[58 ,26 ,10 ,10 ,0 ,2 ,11 ,0 ]); 36 | data.insert(36 ,[0 ,0 ,8 ,14 ,0 ,0 ,9 ,0 ]); 37 | data.insert(37 ,[77 ,0 ,12 ,12 ,0 ,1 ,13 ,0 ]); 38 | data.insert(38 ,[111 ,0 ,11 ,11 ,0 ,1 ,12 ,0 ]); 39 | data.insert(39 ,[252 ,24 ,3 ,5 ,0 ,1 ,4 ,0 ]); 40 | data.insert(40 ,[16 ,0 ,6 ,14 ,0 ,1 ,7 ,0 ]); 41 | data.insert(41 ,[9 ,0 ,6 ,14 ,1 ,1 ,8 ,0 ]); 42 | data.insert(42 ,[224 ,24 ,6 ,6 ,0 ,1 ,7 ,0 ]); 43 | data.insert(43 ,[47 ,26 ,10 ,10 ,0 ,2 ,11 ,0 ]); 44 | data.insert(44 ,[248 ,24 ,3 ,5 ,0 ,10 ,4 ,0 ]); 45 | data.insert(45 ,[35 ,38 ,6 ,1 ,0 ,8 ,7 ,0 ]); 46 | data.insert(46 ,[21 ,39 ,2 ,2 ,1 ,10 ,4 ,0 ]); 47 | data.insert(47 ,[36 ,26 ,10 ,10 ,1 ,2 ,12 ,0 ]); 48 | data.insert(48 ,[218 ,12 ,7 ,11 ,0 ,1 ,8 ,0 ]); 49 | data.insert(49 ,[0 ,27 ,4 ,11 ,0 ,1 ,5 ,0 ]); 50 | data.insert(50 ,[242 ,12 ,6 ,11 ,0 ,1 ,7 ,0 ]); 51 | data.insert(51 ,[194 ,12 ,7 ,11 ,0 ,1 ,8 ,0 ]); 52 | data.insert(52 ,[197 ,0 ,9 ,11 ,0 ,1 ,10 ,0 ]); 53 | data.insert(53 ,[226 ,12 ,7 ,11 ,0 ,1 ,8 ,0 ]); 54 | data.insert(54 ,[176 ,12 ,8 ,11 ,0 ,1 ,9 ,0 ]); 55 | data.insert(55 ,[185 ,12 ,8 ,11 ,0 ,1 ,9 ,0 ]); 56 | data.insert(56 ,[86 ,13 ,8 ,11 ,0 ,1 ,9 ,0 ]); 57 | data.insert(57 ,[247 ,0 ,8 ,11 ,0 ,1 ,9 ,0 ]); 58 | data.insert(58 ,[221 ,24 ,2 ,7 ,1 ,5 ,4 ,0 ]); 59 | data.insert(59 ,[85 ,25 ,3 ,10 ,0 ,5 ,4 ,0 ]); 60 | data.insert(60 ,[89 ,25 ,5 ,9 ,0 ,3 ,6 ,0 ]); 61 | data.insert(61 ,[9 ,39 ,7 ,4 ,1 ,6 ,9 ,0 ]); 62 | data.insert(62 ,[95 ,25 ,5 ,9 ,1 ,3 ,7 ,0 ]); 63 | data.insert(63 ,[69 ,26 ,7 ,10 ,0 ,2 ,8 ,0 ]); 64 | data.insert(64 ,[30 ,0 ,12 ,13 ,0 ,2 ,13 ,0 ]); 65 | data.insert(65 ,[59 ,14 ,8 ,11 ,0 ,1 ,9 ,0 ]); 66 | data.insert(66 ,[68 ,14 ,8 ,11 ,0 ,1 ,9 ,0 ]); 67 | data.insert(67 ,[77 ,13 ,8 ,11 ,0 ,1 ,9 ,0 ]); 68 | data.insert(68 ,[0 ,15 ,9 ,11 ,0 ,1 ,10 ,0 ]); 69 | data.insert(69 ,[187 ,0 ,9 ,11 ,0 ,1 ,10 ,0 ]); 70 | data.insert(70 ,[30 ,14 ,9 ,11 ,0 ,1 ,10 ,0 ]); 71 | data.insert(71 ,[95 ,13 ,8 ,11 ,0 ,1 ,9 ,0 ]); 72 | data.insert(72 ,[207 ,0 ,9 ,11 ,0 ,1 ,10 ,0 ]); 73 | data.insert(73 ,[20 ,27 ,4 ,11 ,0 ,1 ,5 ,0 ]); 74 | data.insert(74 ,[73 ,0 ,3 ,13 ,0 ,1 ,4 ,0 ]); 75 | data.insert(75 ,[10 ,15 ,9 ,11 ,0 ,1 ,10 ,0 ]); 76 | data.insert(76 ,[202 ,12 ,7 ,11 ,0 ,1 ,8 ,0 ]); 77 | data.insert(77 ,[98 ,0 ,12 ,11 ,0 ,1 ,13 ,0 ]); 78 | data.insert(78 ,[146 ,0 ,10 ,11 ,0 ,1 ,11 ,0 ]); 79 | data.insert(79 ,[104 ,12 ,8 ,11 ,0 ,1 ,9 ,0 ]); 80 | data.insert(80 ,[113 ,12 ,8 ,11 ,0 ,1 ,9 ,0 ]); 81 | data.insert(81 ,[43 ,0 ,9 ,13 ,0 ,1 ,10 ,0 ]); 82 | data.insert(82 ,[20 ,15 ,9 ,11 ,0 ,1 ,10 ,0 ]); 83 | data.insert(83 ,[50 ,14 ,8 ,11 ,0 ,1 ,9 ,0 ]); 84 | data.insert(84 ,[227 ,0 ,9 ,11 ,0 ,1 ,10 ,0 ]); 85 | data.insert(85 ,[135 ,0 ,10 ,11 ,0 ,1 ,11 ,0 ]); 86 | data.insert(86 ,[217 ,0 ,9 ,11 ,0 ,1 ,10 ,0 ]); 87 | data.insert(87 ,[123 ,0 ,11 ,11 ,0 ,1 ,12 ,0 ]); 88 | data.insert(88 ,[167 ,0 ,9 ,11 ,0 ,1 ,10 ,0 ]); 89 | data.insert(89 ,[157 ,0 ,9 ,11 ,0 ,1 ,10 ,0 ]); 90 | data.insert(90 ,[122 ,12 ,8 ,11 ,0 ,1 ,9 ,0 ]); 91 | data.insert(91 ,[58 ,0 ,4 ,13 ,1 ,1 ,6 ,0 ]); 92 | data.insert(92 ,[25 ,27 ,10 ,10 ,0 ,2 ,11 ,0 ]); 93 | data.insert(93 ,[68 ,0 ,4 ,13 ,0 ,1 ,5 ,0 ]); 94 | data.insert(94 ,[231 ,24 ,8 ,5 ,0 ,1 ,9 ,0 ]); 95 | data.insert(95 ,[24 ,39 ,10 ,1 ,-1 ,11 ,10 ,0 ]); 96 | data.insert(96 ,[17 ,39 ,3 ,3 ,2 ,1 ,6 ,0 ]); 97 | data.insert(97 ,[174 ,24 ,7 ,8 ,0 ,4 ,8 ,0 ]); 98 | data.insert(98 ,[131 ,12 ,8 ,11 ,0 ,1 ,9 ,0 ]); 99 | data.insert(99 ,[190 ,24 ,7 ,8 ,0 ,4 ,8 ,0 ]); 100 | data.insert(100 ,[140 ,12 ,8 ,11 ,0 ,1 ,9 ,0 ]); 101 | data.insert(101 ,[198 ,24 ,7 ,8 ,0 ,4 ,8 ,0 ]); 102 | data.insert(102 ,[210 ,12 ,7 ,11 ,0 ,1 ,8 ,0 ]); 103 | data.insert(103 ,[149 ,12 ,8 ,11 ,0 ,4 ,9 ,0 ]); 104 | data.insert(104 ,[177 ,0 ,9 ,11 ,0 ,1 ,10 ,0 ]); 105 | data.insert(105 ,[10 ,27 ,4 ,11 ,0 ,1 ,5 ,0 ]); 106 | data.insert(106 ,[23 ,0 ,3 ,14 ,0 ,1 ,4 ,0 ]); 107 | data.insert(107 ,[237 ,0 ,9 ,11 ,0 ,1 ,10 ,0 ]); 108 | data.insert(108 ,[5 ,27 ,4 ,11 ,0 ,1 ,5 ,0 ]); 109 | data.insert(109 ,[101 ,25 ,12 ,8 ,0 ,4 ,13 ,0 ]); 110 | data.insert(110 ,[137 ,24 ,9 ,8 ,0 ,4 ,10 ,0 ]); 111 | data.insert(111 ,[166 ,24 ,7 ,8 ,0 ,4 ,8 ,0 ]); 112 | data.insert(112 ,[158 ,12 ,8 ,11 ,0 ,4 ,9 ,0 ]); 113 | data.insert(113 ,[167 ,12 ,8 ,11 ,0 ,4 ,9 ,0 ]); 114 | data.insert(114 ,[182 ,24 ,7 ,8 ,0 ,4 ,8 ,0 ]); 115 | data.insert(115 ,[214 ,24 ,6 ,8 ,0 ,4 ,7 ,0 ]); 116 | data.insert(116 ,[249 ,12 ,5 ,11 ,0 ,1 ,6 ,0 ]); 117 | data.insert(117 ,[147 ,24 ,9 ,8 ,0 ,4 ,10 ,0 ]); 118 | data.insert(118 ,[157 ,24 ,8 ,8 ,0 ,4 ,9 ,0 ]); 119 | data.insert(119 ,[114 ,24 ,11 ,8 ,0 ,4 ,12 ,0 ]); 120 | data.insert(120 ,[126 ,24 ,10 ,8 ,0 ,4 ,11 ,0 ]); 121 | data.insert(121 ,[234 ,12 ,7 ,11 ,0 ,4 ,8 ,0 ]); 122 | data.insert(122 ,[206 ,24 ,7 ,8 ,0 ,4 ,8 ,0 ]); 123 | data.insert(123 ,[53 ,0 ,4 ,13 ,0 ,2 ,5 ,0 ]); 124 | data.insert(124 ,[27 ,0 ,2 ,14 ,2 ,1 ,5 ,0 ]); 125 | data.insert(125 ,[63 ,0 ,4 ,13 ,0 ,2 ,5 ,0 ]); 126 | data.insert(126 ,[0 ,39 ,8 ,4 ,0 ,6 ,9 ,0 ]); 127 | data.insert(162 ,[90 ,0 ,7 ,12 ,0 ,2 ,8 ,0 ]); 128 | data.insert(163 ,[77 ,25 ,7 ,10 ,0 ,2 ,8 ,0 ]); 129 | data.insert(165 ,[40 ,14 ,9 ,11 ,0 ,1 ,10 ,0 ]); 130 | 131 | 132 | data 133 | } 134 | -------------------------------------------------------------------------------- /src/mgfw/fonts/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod retro_gaming; 2 | //pub mod alagard; 3 | -------------------------------------------------------------------------------- /src/mgfw/fonts/retro_gaming.rs: -------------------------------------------------------------------------------- 1 | use std::collections::HashMap; 2 | 3 | pub struct Font { 4 | pub scale_w: i32, 5 | pub scale_h: i32, 6 | pub page_files: Vec, 7 | pub data: HashMap, 8 | } 9 | 10 | impl Font { 11 | pub fn new() -> Font { 12 | Font { 13 | scale_w: 256, 14 | scale_h: 64, 15 | page_files: get_pages(), 16 | data: get_data(), 17 | } 18 | } 19 | } 20 | 21 | fn get_pages() -> Vec { 22 | let mut pages: Vec = Vec::new(); 23 | pages.push(String::from("assets/mgfw/retro_gaming_0.png")); 24 | pages 25 | } 26 | 27 | #[rustfmt::skip] 28 | fn get_data() -> HashMap { 29 | let mut data: HashMap = HashMap::new(); 30 | 31 | //char id=32 x=11 y=21 width=3 height=1 xoffset=-1 yoffset=13 xadvance=4 page=0 32 | data.insert(32 ,[11 ,21 ,3 ,1 ,-1 ,13 ,5 ,0]); 33 | data.insert(33 ,[248 ,29 ,2 ,8 ,1 ,3 ,3 ,0]); 34 | data.insert(34 ,[246 ,39 ,5 ,3 ,1 ,3 ,6 ,0]); 35 | data.insert(35 ,[0 ,14 ,10 ,8 ,1 ,3 ,11 ,0]); 36 | data.insert(36 ,[3 ,0 ,7 ,12 ,1 ,1 ,8 ,0]); 37 | data.insert(37 ,[213 ,12 ,7 ,8 ,1 ,3 ,8 ,0]); 38 | data.insert(38 ,[32 ,12 ,8 ,8 ,1 ,3 ,9 ,0]); 39 | data.insert(39 ,[5 ,49 ,2 ,3 ,1 ,3 ,3 ,0]); 40 | data.insert(40 ,[223 ,30 ,4 ,8 ,1 ,3 ,6 ,0]); 41 | data.insert(41 ,[213 ,30 ,4 ,8 ,1 ,3 ,6 ,0]); 42 | data.insert(42 ,[92 ,39 ,8 ,5 ,1 ,4 ,9 ,0]); 43 | data.insert(43 ,[56 ,39 ,6 ,6 ,1 ,4 ,7 ,0]); 44 | data.insert(44 ,[252 ,37 ,3 ,3 ,0 ,9 ,3 ,0]); 45 | data.insert(45 ,[14 ,49 ,4 ,2 ,1 ,6 ,6 ,0]); 46 | data.insert(46 ,[19 ,49 ,2 ,2 ,1 ,9 ,3 ,0]); 47 | data.insert(47 ,[237 ,12 ,7 ,8 ,1 ,3 ,8 ,0]); 48 | data.insert(48 ,[245 ,11 ,7 ,8 ,1 ,3 ,8 ,0]); 49 | data.insert(49 ,[218 ,30 ,4 ,8 ,1 ,3 ,6 ,0]); 50 | data.insert(50 ,[0 ,23 ,7 ,8 ,1 ,3 ,8 ,0]); 51 | data.insert(51 ,[8 ,23 ,7 ,8 ,1 ,3 ,8 ,0]); 52 | data.insert(52 ,[24 ,21 ,7 ,8 ,1 ,3 ,8 ,0]); 53 | data.insert(53 ,[40 ,21 ,7 ,8 ,1 ,3 ,8 ,0]); 54 | data.insert(54 ,[112 ,21 ,7 ,8 ,1 ,3 ,8 ,0]); 55 | data.insert(55 ,[48 ,21 ,7 ,8 ,1 ,3 ,8 ,0]); 56 | data.insert(56 ,[72 ,21 ,7 ,8 ,1 ,3 ,8 ,0]); 57 | data.insert(57 ,[80 ,21 ,7 ,8 ,1 ,3 ,8 ,0]); 58 | data.insert(58 ,[75 ,39 ,2 ,6 ,1 ,5 ,3 ,0]); 59 | data.insert(59 ,[251 ,29 ,3 ,7 ,0 ,5 ,3 ,0]); 60 | data.insert(60 ,[42 ,39 ,5 ,7 ,1 ,4 ,6 ,0]); 61 | data.insert(61 ,[240 ,39 ,5 ,3 ,1 ,6 ,6 ,0]); 62 | data.insert(62 ,[36 ,39 ,5 ,7 ,1 ,4 ,6 ,0]); 63 | data.insert(63 ,[120 ,21 ,7 ,8 ,1 ,3 ,8 ,0]); 64 | data.insert(64 ,[152 ,21 ,7 ,8 ,1 ,3 ,8 ,0]); 65 | data.insert(65 ,[168 ,21 ,7 ,8 ,1 ,3 ,8 ,0]); 66 | data.insert(66 ,[176 ,21 ,7 ,8 ,1 ,3 ,8 ,0]); 67 | data.insert(67 ,[184 ,21 ,7 ,8 ,1 ,3 ,8 ,0]); 68 | data.insert(68 ,[112 ,30 ,7 ,8 ,1 ,3 ,8 ,0]); 69 | data.insert(69 ,[120 ,30 ,7 ,8 ,1 ,3 ,8 ,0]); 70 | data.insert(70 ,[128 ,30 ,7 ,8 ,1 ,3 ,8 ,0]); 71 | data.insert(71 ,[77 ,12 ,7 ,8 ,1 ,3 ,8 ,0]); 72 | data.insert(72 ,[85 ,12 ,7 ,8 ,1 ,3 ,8 ,0]); 73 | data.insert(73 ,[144 ,30 ,6 ,8 ,1 ,3 ,7 ,0]); 74 | data.insert(74 ,[93 ,12 ,7 ,8 ,1 ,3 ,8 ,0]); 75 | data.insert(75 ,[101 ,12 ,7 ,8 ,1 ,3 ,8 ,0]); 76 | data.insert(76 ,[172 ,30 ,6 ,8 ,1 ,3 ,7 ,0]); 77 | data.insert(77 ,[109 ,12 ,7 ,8 ,1 ,3 ,8 ,0]); 78 | data.insert(78 ,[117 ,12 ,7 ,8 ,1 ,3 ,8 ,0]); 79 | data.insert(79 ,[125 ,12 ,7 ,8 ,1 ,3 ,8 ,0]); 80 | data.insert(80 ,[133 ,12 ,7 ,8 ,1 ,3 ,8 ,0]); 81 | data.insert(81 ,[141 ,12 ,7 ,8 ,1 ,3 ,8 ,0]); 82 | data.insert(82 ,[149 ,12 ,7 ,8 ,1 ,3 ,8 ,0]); 83 | data.insert(83 ,[157 ,12 ,7 ,8 ,1 ,3 ,8 ,0]); 84 | data.insert(84 ,[165 ,12 ,7 ,8 ,1 ,3 ,8 ,0]); 85 | data.insert(85 ,[173 ,12 ,7 ,8 ,1 ,3 ,8 ,0]); 86 | data.insert(86 ,[181 ,12 ,7 ,8 ,1 ,3 ,8 ,0]); 87 | data.insert(87 ,[41 ,12 ,8 ,8 ,1 ,3 ,9 ,0]); 88 | data.insert(88 ,[189 ,12 ,7 ,8 ,1 ,3 ,8 ,0]); 89 | data.insert(89 ,[197 ,12 ,7 ,8 ,1 ,3 ,8 ,0]); 90 | data.insert(90 ,[205 ,12 ,7 ,8 ,1 ,3 ,8 ,0]); 91 | data.insert(91 ,[203 ,30 ,4 ,8 ,1 ,3 ,6 ,0]); 92 | data.insert(92 ,[221 ,12 ,7 ,8 ,1 ,3 ,8 ,0]); 93 | data.insert(93 ,[198 ,30 ,4 ,8 ,1 ,3 ,6 ,0]); 94 | data.insert(94 ,[225 ,39 ,7 ,3 ,1 ,3 ,8 ,0]); 95 | data.insert(95 ,[22 ,47 ,5 ,1 ,1 ,10 ,6 ,0]); 96 | data.insert(96 ,[0 ,49 ,4 ,3 ,1 ,3 ,6 ,0]); 97 | data.insert(97 ,[197 ,39 ,7 ,5 ,1 ,6 ,8 ,0]); 98 | data.insert(98 ,[16 ,21 ,7 ,8 ,1 ,3 ,8 ,0]); 99 | data.insert(99 ,[189 ,39 ,7 ,5 ,1 ,6 ,8 ,0]); 100 | data.insert(100 ,[32 ,21 ,7 ,8 ,1 ,3 ,8 ,0]); 101 | data.insert(101 ,[181 ,39 ,7 ,5 ,1 ,6 ,8 ,0]); 102 | data.insert(102 ,[192 ,30 ,5 ,8 ,1 ,3 ,6 ,0]); 103 | data.insert(103 ,[56 ,21 ,7 ,8 ,1 ,6 ,8 ,0]); 104 | data.insert(104 ,[64 ,21 ,7 ,8 ,1 ,3 ,8 ,0]); 105 | data.insert(105 ,[245 ,30 ,2 ,8 ,1 ,3 ,3 ,0]); 106 | data.insert(106 ,[250 ,0 ,5 ,9 ,1 ,3 ,6 ,0]); 107 | data.insert(107 ,[165 ,30 ,6 ,8 ,1 ,3 ,7 ,0]); 108 | data.insert(108 ,[233 ,30 ,3 ,8 ,1 ,3 ,4 ,0]); 109 | data.insert(109 ,[149 ,39 ,7 ,5 ,1 ,6 ,8 ,0]); 110 | data.insert(110 ,[101 ,39 ,7 ,5 ,1 ,6 ,8 ,0]); 111 | data.insert(111 ,[141 ,39 ,7 ,5 ,1 ,6 ,8 ,0]); 112 | data.insert(112 ,[128 ,21 ,7 ,8 ,1 ,6 ,8 ,0]); 113 | data.insert(113 ,[136 ,21 ,7 ,8 ,1 ,6 ,8 ,0]); 114 | data.insert(114 ,[205 ,39 ,6 ,5 ,1 ,6 ,7 ,0]); 115 | data.insert(115 ,[117 ,39 ,7 ,5 ,1 ,6 ,8 ,0]); 116 | data.insert(116 ,[186 ,30 ,5 ,8 ,1 ,3 ,6 ,0]); 117 | data.insert(117 ,[109 ,39 ,7 ,5 ,1 ,6 ,8 ,0]); 118 | data.insert(118 ,[125 ,39 ,7 ,5 ,1 ,6 ,8 ,0]); 119 | data.insert(119 ,[173 ,39 ,7 ,5 ,1 ,6 ,8 ,0]); 120 | data.insert(120 ,[157 ,39 ,7 ,5 ,1 ,6 ,8 ,0]); 121 | data.insert(121 ,[88 ,21 ,7 ,8 ,1 ,6 ,8 ,0]); 122 | data.insert(122 ,[133 ,39 ,7 ,5 ,1 ,6 ,8 ,0]); 123 | data.insert(123 ,[228 ,30 ,4 ,8 ,1 ,3 ,6 ,0]); 124 | data.insert(124 ,[247 ,0 ,2 ,10 ,1 ,3 ,3 ,0]); 125 | data.insert(125 ,[208 ,30 ,4 ,8 ,1 ,3 ,6 ,0]); 126 | data.insert(126 ,[233 ,39 ,6 ,3 ,1 ,5 ,7 ,0]); 127 | data.insert(161 ,[253 ,10 ,2 ,8 ,1 ,3 ,3 ,0]); 128 | data.insert(162 ,[28 ,39 ,7 ,7 ,1 ,5 ,8 ,0]); 129 | data.insert(163 ,[24 ,30 ,7 ,8 ,1 ,3 ,8 ,0]); 130 | data.insert(164 ,[48 ,39 ,7 ,6 ,1 ,4 ,8 ,0]); 131 | data.insert(165 ,[160 ,21 ,7 ,8 ,1 ,3 ,8 ,0]); 132 | data.insert(166 ,[0 ,0 ,2 ,13 ,1 ,1 ,3 ,0]); 133 | data.insert(167 ,[144 ,21 ,7 ,8 ,1 ,3 ,8 ,0]); 134 | data.insert(168 ,[8 ,49 ,5 ,2 ,1 ,3 ,6 ,0]); 135 | data.insert(169 ,[22 ,12 ,9 ,8 ,1 ,3 ,10 ,0]); 136 | data.insert(170 ,[70 ,39 ,4 ,6 ,1 ,3 ,6 ,0]); 137 | data.insert(171 ,[10 ,41 ,9 ,7 ,1 ,4 ,10 ,0]); 138 | data.insert(174 ,[63 ,39 ,6 ,6 ,1 ,3 ,7 ,0]); 139 | data.insert(177 ,[179 ,30 ,6 ,8 ,1 ,3 ,7 ,0]); 140 | data.insert(181 ,[59 ,12 ,8 ,8 ,0 ,6 ,8 ,0]); 141 | data.insert(182 ,[104 ,21 ,7 ,8 ,1 ,3 ,8 ,0]); 142 | data.insert(187 ,[0 ,41 ,9 ,7 ,1 ,4 ,10 ,0]); 143 | data.insert(191 ,[96 ,21 ,7 ,8 ,1 ,3 ,8 ,0]); 144 | data.insert(192 ,[51 ,0 ,7 ,11 ,1 ,0 ,8 ,0]); 145 | data.insert(193 ,[35 ,0 ,7 ,11 ,1 ,0 ,8 ,0]); 146 | data.insert(194 ,[203 ,0 ,7 ,11 ,1 ,0 ,8 ,0]); 147 | data.insert(195 ,[195 ,0 ,7 ,11 ,1 ,0 ,8 ,0]); 148 | data.insert(196 ,[187 ,0 ,7 ,11 ,1 ,0 ,8 ,0]); 149 | data.insert(197 ,[131 ,0 ,7 ,11 ,1 ,0 ,8 ,0]); 150 | data.insert(198 ,[11 ,12 ,10 ,8 ,1 ,3 ,11 ,0]); 151 | data.insert(199 ,[239 ,0 ,7 ,10 ,1 ,3 ,8 ,0]); 152 | data.insert(200 ,[179 ,0 ,7 ,11 ,1 ,0 ,8 ,0]); 153 | data.insert(201 ,[171 ,0 ,7 ,11 ,1 ,0 ,8 ,0]); 154 | data.insert(202 ,[155 ,0 ,7 ,11 ,1 ,0 ,8 ,0]); 155 | data.insert(203 ,[67 ,0 ,7 ,11 ,1 ,0 ,8 ,0]); 156 | data.insert(204 ,[232 ,0 ,6 ,11 ,1 ,0 ,7 ,0]); 157 | data.insert(205 ,[211 ,0 ,6 ,11 ,1 ,0 ,7 ,0]); 158 | data.insert(206 ,[225 ,0 ,6 ,11 ,1 ,0 ,7 ,0]); 159 | data.insert(207 ,[218 ,0 ,6 ,11 ,1 ,0 ,7 ,0]); 160 | data.insert(208 ,[50 ,12 ,8 ,8 ,1 ,3 ,9 ,0]); 161 | data.insert(209 ,[11 ,0 ,7 ,11 ,1 ,0 ,8 ,0]); 162 | data.insert(210 ,[107 ,0 ,7 ,11 ,1 ,0 ,8 ,0]); 163 | data.insert(211 ,[99 ,0 ,7 ,11 ,1 ,0 ,8 ,0]); 164 | data.insert(212 ,[91 ,0 ,7 ,11 ,1 ,0 ,8 ,0]); 165 | data.insert(213 ,[83 ,0 ,7 ,11 ,1 ,0 ,8 ,0]); 166 | data.insert(214 ,[75 ,0 ,7 ,11 ,1 ,0 ,8 ,0]); 167 | data.insert(215 ,[219 ,39 ,5 ,5 ,1 ,4 ,6 ,0]); 168 | data.insert(216 ,[229 ,12 ,7 ,8 ,1 ,3 ,8 ,0]); 169 | data.insert(217 ,[59 ,0 ,7 ,11 ,1 ,0 ,8 ,0]); 170 | data.insert(218 ,[27 ,0 ,7 ,11 ,1 ,0 ,8 ,0]); 171 | data.insert(219 ,[19 ,0 ,7 ,11 ,1 ,0 ,8 ,0]); 172 | data.insert(220 ,[115 ,0 ,7 ,11 ,1 ,0 ,8 ,0]); 173 | data.insert(221 ,[123 ,0 ,7 ,11 ,1 ,0 ,8 ,0]); 174 | data.insert(222 ,[192 ,21 ,7 ,8 ,1 ,3 ,8 ,0]); 175 | data.insert(223 ,[200 ,21 ,7 ,8 ,1 ,3 ,8 ,0]); 176 | data.insert(224 ,[208 ,21 ,7 ,8 ,1 ,3 ,8 ,0]); 177 | data.insert(225 ,[216 ,21 ,7 ,8 ,1 ,3 ,8 ,0]); 178 | data.insert(226 ,[224 ,21 ,7 ,8 ,1 ,3 ,8 ,0]); 179 | data.insert(227 ,[232 ,21 ,7 ,8 ,1 ,3 ,8 ,0]); 180 | data.insert(228 ,[240 ,21 ,7 ,8 ,1 ,3 ,8 ,0]); 181 | data.insert(229 ,[248 ,20 ,7 ,8 ,1 ,3 ,8 ,0]); 182 | data.insert(230 ,[78 ,39 ,13 ,5 ,1 ,6 ,14 ,0]); 183 | data.insert(231 ,[20 ,39 ,7 ,7 ,1 ,6 ,8 ,0]); 184 | data.insert(232 ,[0 ,32 ,7 ,8 ,1 ,3 ,8 ,0]); 185 | data.insert(233 ,[8 ,32 ,7 ,8 ,1 ,3 ,8 ,0]); 186 | data.insert(234 ,[136 ,30 ,7 ,8 ,1 ,3 ,8 ,0]); 187 | data.insert(235 ,[16 ,30 ,7 ,8 ,1 ,3 ,8 ,0]); 188 | data.insert(236 ,[241 ,30 ,3 ,8 ,0 ,3 ,3 ,0]); 189 | data.insert(237 ,[237 ,30 ,3 ,8 ,1 ,3 ,4 ,0]); 190 | data.insert(238 ,[151 ,30 ,6 ,8 ,-1 ,3 ,5 ,0]); 191 | data.insert(239 ,[158 ,30 ,6 ,8 ,-1 ,3 ,5 ,0]); 192 | data.insert(240 ,[68 ,12 ,8 ,8 ,1 ,3 ,9 ,0]); 193 | data.insert(241 ,[32 ,30 ,7 ,8 ,1 ,3 ,8 ,0]); 194 | data.insert(242 ,[40 ,30 ,7 ,8 ,1 ,3 ,8 ,0]); 195 | data.insert(243 ,[48 ,30 ,7 ,8 ,1 ,3 ,8 ,0]); 196 | data.insert(244 ,[56 ,30 ,7 ,8 ,1 ,3 ,8 ,0]); 197 | data.insert(245 ,[64 ,30 ,7 ,8 ,1 ,3 ,8 ,0]); 198 | data.insert(246 ,[72 ,30 ,7 ,8 ,1 ,3 ,8 ,0]); 199 | data.insert(247 ,[212 ,39 ,6 ,5 ,1 ,5 ,7 ,0]); 200 | data.insert(248 ,[165 ,39 ,7 ,5 ,1 ,6 ,8 ,0]); 201 | data.insert(249 ,[80 ,30 ,7 ,8 ,1 ,3 ,8 ,0]); 202 | data.insert(250 ,[88 ,30 ,7 ,8 ,1 ,3 ,8 ,0]); 203 | data.insert(251 ,[96 ,30 ,7 ,8 ,1 ,3 ,8 ,0]); 204 | data.insert(252 ,[104 ,30 ,7 ,8 ,1 ,3 ,8 ,0]); 205 | data.insert(253 ,[139 ,0 ,7 ,11 ,1 ,3 ,8 ,0]); 206 | data.insert(254 ,[147 ,0 ,7 ,11 ,1 ,3 ,8 ,0]); 207 | data.insert(255 ,[163 ,0 ,7 ,11 ,1 ,3 ,8 ,0]); 208 | data.insert(376 ,[43 ,0 ,7 ,11 ,1 ,0 ,8 ,0]); 209 | 210 | data 211 | } 212 | --------------------------------------------------------------------------------