50 Commits

Author SHA1 Message Date
9a5918f3f7 Experimental clangd support for PoolBox 2025-08-12 22:15:08 +02:00
18ebf33e2c Add clangd support to 'Support' 2025-08-12 21:57:16 +02:00
d8065f6266 Add clangd support 2025-08-12 21:50:46 +02:00
f25548085f Update name of tim_project 2025-04-16 21:48:54 +02:00
85d787151a Delete dummy file 2025-04-16 21:46:40 +02:00
d69b144ebe Include another image for the tim_project file 2025-04-16 21:46:13 +02:00
a686df5bf6 Integrated auto generated Dönerfisch 2025-04-16 21:18:52 +02:00
3500a288bc Support image size for files 2025-04-16 21:18:37 +02:00
e51908ae09 Support creating hpp file 2025-04-16 20:42:51 +02:00
4ea7575057 Basic project suport 2025-04-14 20:47:56 +02:00
e3ed4a3b43 Update existing project for the new settings 2025-04-13 16:55:13 +02:00
3f507fd19e Setup usage example 2025-04-08 21:22:39 +02:00
f8ec08008a Support settings and encode 2025-04-08 19:19:32 +00:00
4942012da1 Added storage for settings 2025-04-08 19:19:32 +00:00
9501954587 Slowly introducing file settings 2025-04-08 19:19:32 +00:00
751533dcf6 Move primitives around 2025-04-08 19:19:32 +00:00
5a1997873d Make palette optional 2025-04-08 19:19:32 +00:00
5cd29460fb Prepare GUI for additonal settings 2025-04-08 19:19:32 +00:00
7a2052575d Prepare file settings box 2025-04-08 19:19:32 +00:00
a475a0c82d Bump dependency versions 2025-04-05 22:38:14 +02:00
32da34cad6 Fix various focus issues 2025-04-05 22:34:30 +02:00
af633a4fdf Fix scoll issue 2025-04-05 22:22:33 +02:00
b0b8c43700 Bump version to 1.0.0 2025-04-02 22:11:37 +02:00
ed4671698a Add label to indicate focusing ability 2025-04-02 22:10:36 +02:00
b487ca2591 Focus on left click 2025-04-02 22:08:06 +02:00
a33aa6bb4e Add width/height for images by catty request 2025-04-02 21:46:46 +02:00
85b5aa0070 Support naming of VRAM 2025-04-02 21:34:32 +02:00
b3a666b5ea Increase zoom level to 800% 2025-04-02 21:23:56 +02:00
a8ca3bf859 Create public function for loading files 2025-04-02 21:14:19 +02:00
ec6c20185e Support loading relative pathes 2025-04-02 21:04:42 +02:00
a6d8ecab16 Improve error message when failing to load image 2025-04-02 20:52:28 +02:00
a89699334e Create relative pathes for saving projects 2025-04-02 20:47:50 +02:00
5f93549a05 Fix usage of checked property 2025-04-02 20:06:35 +02:00
2e6aa8dbe9 Improve text message for appending elements 2025-04-01 17:20:05 +02:00
a9801e9fe2 Support appending and overriding existing elements from project 2025-04-01 17:19:28 +02:00
47b5de2d6a Clear existing elements 2025-04-01 16:28:27 +02:00
bab01bbd86 Load VRAM images from project file 2025-04-01 16:03:35 +02:00
a260c1ffb7 Allow position information for newly added VRAM items 2025-04-01 15:24:41 +02:00
5cc88e0b87 Deserialize project 2025-03-20 21:37:19 +01:00
5f4ade47bd Support selecting project to open 2025-03-20 21:26:32 +01:00
2345b3da57 Save encoding information 2025-03-20 21:16:41 +01:00
e0a266317e Support saving palette information 2025-03-20 20:57:10 +01:00
aae57e47e4 Implement writing image and half the platte information 2025-03-19 22:01:32 +01:00
d1d590d32a Save tim_project files 2025-03-19 21:32:18 +01:00
18e6800e0f Implement browsing project save location 2025-03-19 21:17:26 +01:00
d42fe2776c Serialize project to json 2025-03-19 20:47:21 +01:00
7a197d9b71 Create a simple Job 2025-03-19 20:21:45 +01:00
b394330405 zip jobs 2025-03-18 22:31:59 +01:00
602fb3a5c2 Obtain all required vectors; Quick draft for project 2025-03-18 21:54:25 +01:00
6a1b87cdb1 Update name of VRAM images to reflect data 2025-03-18 21:48:36 +01:00
41 changed files with 8009 additions and 682 deletions

3
.clangd Normal file
View File

@@ -0,0 +1,3 @@
CompileFlags:
Remove: [-fmodules-ts, -mno-shared, -mno-llsc, -march=r2000, -mtune=r2000, implied_comparison_category_type_not_found]
Compiler: mipsel-linux-gnu-g++

2
.gitignore vendored
View File

@@ -9,6 +9,8 @@
**/config **/config
.lfsconfig .lfsconfig
.cache
compile_commands.json
*.d *.d
*.a *.a

View File

@@ -4,4 +4,5 @@
*.d *.d
*.o *.o
*.lba *.lba
**/bin **/bin
**/auto_gen

View File

@@ -11,7 +11,7 @@
{ {
"label": "build", "label": "build",
"type": "shell", "type": "shell",
"command": "${env:JABY_ENGINE_PATH}/scripts/podman_jaby_engine.sh ${workspaceFolder}:. make ${input:project}_${input:target} BUILD_PROFILE=${input:build profile} REGION=${input:region} CUSTOM_CONFIG=${input:custom config}", "command": "${env:JABY_ENGINE_PATH}/scripts/podman_jaby_engine.sh ${workspaceFolder}:. bear -- make ${input:project}_${input:target} BUILD_PROFILE=${input:build profile} REGION=${input:region} CUSTOM_CONFIG=${input:custom config}",
"group": { "group": {
"kind": "build", "kind": "build",
"isDefault": true "isDefault": true

View File

@@ -1,4 +1,5 @@
#pragma once #pragma once
#include "auto_gen/vram_layout.hpp"
#include <PSX/File/cd_file_types.hpp> #include <PSX/File/cd_file_types.hpp>
namespace Assets { namespace Assets {
@@ -11,11 +12,6 @@ namespace Assets {
}; };
static constexpr auto PacoTIM = SimpleTIM::create(896, 0, 960, 510); static constexpr auto PacoTIM = SimpleTIM::create(896, 0, 960, 510);
static constexpr auto DoenerFishInfo = ImageInfo{
.tim = SimpleTIM::create(896 + 30, 0, 960 + 16, 510),
.size = GPU::SizeI16::create(128, 64)
};
namespace JabyLoader { namespace JabyLoader {
static constexpr auto TIMLoaction = SimpleTIM::create(PacoTIM.get_texture_x(), PacoTIM.get_texture_y() + 128, 960 + 48, 510); static constexpr auto TIMLoaction = SimpleTIM::create(PacoTIM.get_texture_x(), PacoTIM.get_texture_y() + 128, 960 + 48, 510);
static constexpr auto JabyFrame = GPU::AreaI16::create(0, 0, 32, 44); static constexpr auto JabyFrame = GPU::AreaI16::create(0, 0, 32, 44);

View File

@@ -1,3 +1,4 @@
#include "../../../include/auto_gen/vram_layout.hpp"
#include "../../../include/shared.hpp" #include "../../../include/shared.hpp"
#include "include/controller_state.hpp" #include "include/controller_state.hpp"
#include <PSX/Periphery/periphery.hpp> #include <PSX/Periphery/periphery.hpp>

View File

@@ -1,4 +1,4 @@
#include "include/controller_test_assets.hpp" #include "../../../include/auto_gen/vram_layout.hpp"
#include <PSX/File/Processor/cd_file_processor.hpp> #include <PSX/File/Processor/cd_file_processor.hpp>
#include <PSX/AutoLBA/auto_lba_declaration.hpp> #include <PSX/AutoLBA/auto_lba_declaration.hpp>
@@ -13,6 +13,6 @@ namespace ControllerTest {
__declare_lba_header(LBA); __declare_lba_header(LBA);
CDFile Assets[1] = { CDFile Assets[1] = {
CDFileBuilder::simple_tim(LBA::CONT, ControllerButtonTIM), CDFileBuilder::simple_tim(LBA::CONT, Controller_png::tim),
}; };
} }

View File

@@ -1,5 +1,5 @@
#pragma once #pragma once
#include "controller_test_assets.hpp" #include "../../../../include/auto_gen/vram_layout.hpp"
#include <FontWriter/font_writer.hpp> #include <FontWriter/font_writer.hpp>
#include <PSX/GPU/make_gpu_primitives.hpp> #include <PSX/GPU/make_gpu_primitives.hpp>
#include <PSX/Periphery/controller.hpp> #include <PSX/Periphery/controller.hpp>
@@ -18,43 +18,43 @@ namespace ControllerTest {
ControllerState state; ControllerState state;
for(auto& tex_page : state.tex_page) { for(auto& tex_page : state.tex_page) {
tex_page = Make::TexPage(ControllerButtonTIM.get_texture_position(), GPU::TextureColorMode::clut4).linked(); tex_page = Make::TexPage(Controller_png::tim.get_texture_position(), GPU::TextureColorMode::clut4).linked();
} }
for(auto& buttons : state.buttons) { for(auto& buttons : state.buttons) {
// Triangle // Triangle
buttons[0] = Make::SPRT_16(Make::Vertex(71, 0).move(offset.x, offset.y), Make::OffsetPageWithClut(GPU::PageOffset::from_tile_id16(0, Make::SizeI16(16, 16)), Make::PageClut(ControllerButtonTIM.get_clut_position()))).linked(); buttons[0] = Make::SPRT_16(Make::Vertex(71, 0).move(offset.x, offset.y), Make::OffsetPageWithClut(GPU::PageOffset::from_tile_id16(0, Make::SizeI16(16, 16)), Make::PageClut(Controller_png::tim.get_clut_position()))).linked();
// Circle // Circle
buttons[1] = Make::SPRT_16(Make::Vertex(82, 12).move(offset.x, offset.y), Make::OffsetPageWithClut(GPU::PageOffset::from_tile_id16(1, Make::SizeI16(16, 16)), Make::PageClut(ControllerButtonTIM.get_clut_position()))).linked(); buttons[1] = Make::SPRT_16(Make::Vertex(82, 12).move(offset.x, offset.y), Make::OffsetPageWithClut(GPU::PageOffset::from_tile_id16(1, Make::SizeI16(16, 16)), Make::PageClut(Controller_png::tim.get_clut_position()))).linked();
// Cross // Cross
buttons[2] = Make::SPRT_16(Make::Vertex(71, 23).move(offset.x, offset.y), Make::OffsetPageWithClut(GPU::PageOffset::from_tile_id16(2, Make::SizeI16(16, 16)), Make::PageClut(ControllerButtonTIM.get_clut_position()))).linked(); buttons[2] = Make::SPRT_16(Make::Vertex(71, 23).move(offset.x, offset.y), Make::OffsetPageWithClut(GPU::PageOffset::from_tile_id16(2, Make::SizeI16(16, 16)), Make::PageClut(Controller_png::tim.get_clut_position()))).linked();
// Square // Square
buttons[3] = Make::SPRT_16(Make::Vertex(60, 11).move(offset.x, offset.y), Make::OffsetPageWithClut(GPU::PageOffset::from_tile_id16(3, Make::SizeI16(16, 16)), Make::PageClut(ControllerButtonTIM.get_clut_position()))).linked(); buttons[3] = Make::SPRT_16(Make::Vertex(60, 11).move(offset.x, offset.y), Make::OffsetPageWithClut(GPU::PageOffset::from_tile_id16(3, Make::SizeI16(16, 16)), Make::PageClut(Controller_png::tim.get_clut_position()))).linked();
// Play // Play
buttons[4] = Make::SPRT_16(Make::Vertex(51, 21).move(offset.x, offset.y), Make::OffsetPageWithClut(GPU::PageOffset::from_tile_id16(4, Make::SizeI16(16, 16)), Make::PageClut(ControllerButtonTIM.get_clut_position()))).linked(); buttons[4] = Make::SPRT_16(Make::Vertex(51, 21).move(offset.x, offset.y), Make::OffsetPageWithClut(GPU::PageOffset::from_tile_id16(4, Make::SizeI16(16, 16)), Make::PageClut(Controller_png::tim.get_clut_position()))).linked();
// Block // Block
buttons[5] = Make::SPRT_16(Make::Vertex(24, 21).move(offset.x, offset.y), Make::OffsetPageWithClut(GPU::PageOffset::from_tile_id16(5, Make::SizeI16(16, 16)), Make::PageClut(ControllerButtonTIM.get_clut_position()))).linked(); buttons[5] = Make::SPRT_16(Make::Vertex(24, 21).move(offset.x, offset.y), Make::OffsetPageWithClut(GPU::PageOffset::from_tile_id16(5, Make::SizeI16(16, 16)), Make::PageClut(Controller_png::tim.get_clut_position()))).linked();
// L1 // L1
buttons[6] = Make::SPRT_16(Make::Vertex(7, 39).move(offset.x, offset.y), Make::OffsetPageWithClut(GPU::PageOffset::from_tile_id16(7, Make::SizeI16(16, 16)), Make::PageClut(ControllerButtonTIM.get_clut_position()))).linked(); buttons[6] = Make::SPRT_16(Make::Vertex(7, 39).move(offset.x, offset.y), Make::OffsetPageWithClut(GPU::PageOffset::from_tile_id16(7, Make::SizeI16(16, 16)), Make::PageClut(Controller_png::tim.get_clut_position()))).linked();
// L2 // L2
buttons[7] = Make::SPRT_16(Make::Vertex(7, 49).move(offset.x, offset.y), Make::OffsetPageWithClut(GPU::PageOffset::from_tile_id16(8, Make::SizeI16(16, 16)), Make::PageClut(ControllerButtonTIM.get_clut_position()))).linked(); buttons[7] = Make::SPRT_16(Make::Vertex(7, 49).move(offset.x, offset.y), Make::OffsetPageWithClut(GPU::PageOffset::from_tile_id16(8, Make::SizeI16(16, 16)), Make::PageClut(Controller_png::tim.get_clut_position()))).linked();
// R1 // R1
buttons[8] = Make::SPRT_16(Make::Vertex(71, 39).move(offset.x, offset.y), Make::OffsetPageWithClut(GPU::PageOffset::from_tile_id16(7, Make::SizeI16(16, 16)), Make::PageClut(ControllerButtonTIM.get_clut_position()))).linked(); buttons[8] = Make::SPRT_16(Make::Vertex(71, 39).move(offset.x, offset.y), Make::OffsetPageWithClut(GPU::PageOffset::from_tile_id16(7, Make::SizeI16(16, 16)), Make::PageClut(Controller_png::tim.get_clut_position()))).linked();
// R2 // R2
buttons[9] = Make::SPRT_16(Make::Vertex(71, 49).move(offset.x, offset.y), Make::OffsetPageWithClut(GPU::PageOffset::from_tile_id16(8, Make::SizeI16(16, 16)), Make::PageClut(ControllerButtonTIM.get_clut_position()))).linked(); buttons[9] = Make::SPRT_16(Make::Vertex(71, 49).move(offset.x, offset.y), Make::OffsetPageWithClut(GPU::PageOffset::from_tile_id16(8, Make::SizeI16(16, 16)), Make::PageClut(Controller_png::tim.get_clut_position()))).linked();
// L3 // L3
buttons[10] = Make::SPRT_16(Make::Vertex(24, 34).move(offset.x, offset.y), Make::OffsetPageWithClut(GPU::PageOffset::from_tile_id16(9, Make::SizeI16(16, 16)), Make::PageClut(ControllerButtonTIM.get_clut_position()))).linked(); buttons[10] = Make::SPRT_16(Make::Vertex(24, 34).move(offset.x, offset.y), Make::OffsetPageWithClut(GPU::PageOffset::from_tile_id16(9, Make::SizeI16(16, 16)), Make::PageClut(Controller_png::tim.get_clut_position()))).linked();
// R3 // R3
buttons[11] = Make::SPRT_16(Make::Vertex(52, 34).move(offset.x, offset.y), Make::OffsetPageWithClut(GPU::PageOffset::from_tile_id16(9, Make::SizeI16(16, 16)), Make::PageClut(ControllerButtonTIM.get_clut_position()))).linked(); buttons[11] = Make::SPRT_16(Make::Vertex(52, 34).move(offset.x, offset.y), Make::OffsetPageWithClut(GPU::PageOffset::from_tile_id16(9, Make::SizeI16(16, 16)), Make::PageClut(Controller_png::tim.get_clut_position()))).linked();
// Connection Symbol // Connection Symbol
buttons[12] = Make::SPRT_16(Make::Vertex(37, 9).move(offset.x, offset.y), Make::OffsetPageWithClut(GPU::PageOffset::from_tile_id16(10, Make::SizeI16(16, 16)), Make::PageClut(ControllerButtonTIM.get_clut_position()))).linked(); buttons[12] = Make::SPRT_16(Make::Vertex(37, 9).move(offset.x, offset.y), Make::OffsetPageWithClut(GPU::PageOffset::from_tile_id16(10, Make::SizeI16(16, 16)), Make::PageClut(Controller_png::tim.get_clut_position()))).linked();
} }
for(auto& arrows : state.arrows) { for(auto& arrows : state.arrows) {
arrows[0] = Make::POLY_FT4(__jabyengine_polyFT4_vertex_rect( Make::AreaI16(Make::PositionI16( 7, 5).move(offset.x, offset.y), Make::SizeI16(16, 16)), Make::PositionI16(6*16, 0)), Make::TPage(ControllerButtonTIM.get_texture_position(), GPU::SemiTransparency::B_Half_add_F_Half, GPU::TextureColorMode::clut4), Make::PageClut(ControllerButtonTIM.get_clut_position())).linked(); arrows[0] = Make::POLY_FT4(__jabyengine_polyFT4_vertex_rect( Make::AreaI16(Make::PositionI16( 7, 5).move(offset.x, offset.y), Make::SizeI16(16, 16)), Make::PositionI16(6*16, 0)), Make::TPage(Controller_png::tim.get_texture_position(), GPU::SemiTransparency::B_Half_add_F_Half, GPU::TextureColorMode::clut4), Make::PageClut(Controller_png::tim.get_clut_position())).linked();
arrows[1] = Make::POLY_FT4(__jabyengine_polyFT4_vertex_rect270(Make::AreaI16(Make::PositionI16(14, 11).move(offset.x, offset.y), Make::SizeI16(16, 16)), Make::PositionI16(6*16, 0)), Make::TPage(ControllerButtonTIM.get_texture_position(), GPU::SemiTransparency::B_Half_add_F_Half, GPU::TextureColorMode::clut4), Make::PageClut(ControllerButtonTIM.get_clut_position())).linked(); arrows[1] = Make::POLY_FT4(__jabyengine_polyFT4_vertex_rect270(Make::AreaI16(Make::PositionI16(14, 11).move(offset.x, offset.y), Make::SizeI16(16, 16)), Make::PositionI16(6*16, 0)), Make::TPage(Controller_png::tim.get_texture_position(), GPU::SemiTransparency::B_Half_add_F_Half, GPU::TextureColorMode::clut4), Make::PageClut(Controller_png::tim.get_clut_position())).linked();
arrows[2] = Make::POLY_FT4(__jabyengine_polyFT4_vertex_rect180(Make::AreaI16(Make::PositionI16( 7, 17).move(offset.x, offset.y), Make::SizeI16(16, 16)), Make::PositionI16(6*16, 0)), Make::TPage(ControllerButtonTIM.get_texture_position(), GPU::SemiTransparency::B_Half_add_F_Half, GPU::TextureColorMode::clut4), Make::PageClut(ControllerButtonTIM.get_clut_position())).linked(); arrows[2] = Make::POLY_FT4(__jabyengine_polyFT4_vertex_rect180(Make::AreaI16(Make::PositionI16( 7, 17).move(offset.x, offset.y), Make::SizeI16(16, 16)), Make::PositionI16(6*16, 0)), Make::TPage(Controller_png::tim.get_texture_position(), GPU::SemiTransparency::B_Half_add_F_Half, GPU::TextureColorMode::clut4), Make::PageClut(Controller_png::tim.get_clut_position())).linked();
arrows[3] = Make::POLY_FT4(__jabyengine_polyFT4_vertex_rect90( Make::AreaI16(Make::PositionI16( 0, 11).move(offset.x, offset.y), Make::SizeI16(16, 16)), Make::PositionI16(6*16, 0)), Make::TPage(ControllerButtonTIM.get_texture_position(), GPU::SemiTransparency::B_Half_add_F_Half, GPU::TextureColorMode::clut4), Make::PageClut(ControllerButtonTIM.get_clut_position())).linked(); arrows[3] = Make::POLY_FT4(__jabyengine_polyFT4_vertex_rect90( Make::AreaI16(Make::PositionI16( 0, 11).move(offset.x, offset.y), Make::SizeI16(16, 16)), Make::PositionI16(6*16, 0)), Make::TPage(Controller_png::tim.get_texture_position(), GPU::SemiTransparency::B_Half_add_F_Half, GPU::TextureColorMode::clut4), Make::PageClut(Controller_png::tim.get_clut_position())).linked();
} }
return state; return state;

View File

@@ -1,8 +0,0 @@
#pragma once
#include <PSX/File/cd_file_types.hpp>
namespace ControllerTest {
using namespace JabyEngine;
static constexpr auto ControllerButtonTIM = SimpleTIM::create(384, 0, 384, 511);
}

View File

@@ -86,10 +86,10 @@ namespace GTETest {
} }
static auto doener_fish = GTE_Sprite::create(Make::POLY_FT4( static auto doener_fish = GTE_Sprite::create(Make::POLY_FT4(
Make::AreaI16(Make::PositionI16(0, 0), Assets::Main::DoenerFishInfo.size), Make::AreaI16(Make::PositionI16(0, 0), doener_fish_png::size),
Assets::Main::DoenerFishInfo.tim.get_page_offset_clut4(), doener_fish_png::tim.get_page_offset_clut4(),
Make::TPage(Assets::Main::DoenerFishInfo.tim.get_texture_position(), GPU::SemiTransparency::B_add_F, GPU::TextureColorMode::clut4), Make::TPage(doener_fish_png::tim.get_texture_position(), GPU::SemiTransparency::B_add_F, GPU::TextureColorMode::clut4),
Make::PageClut(Assets::Main::DoenerFishInfo.tim.get_clut_position()), Make::PageClut(doener_fish_png::tim.get_clut_position()),
GPU::Color24::Grey() GPU::Color24::Grey()
).linked()); ).linked());

View File

@@ -6,8 +6,8 @@ namespace GTETest {
using namespace JabyEngine; using namespace JabyEngine;
static constexpr auto JabySTARTim = SimpleTIM::create( static constexpr auto JabySTARTim = SimpleTIM::create(
// v Doenerfisch rotates so we need some space // v Dönerfisch rotates so we need some space
Assets::Main::DoenerFishInfo.tim.get_texture_x(), Assets::Main::DoenerFishInfo.tim.get_texture_y() + Assets::Main::DoenerFishInfo.size.height + 2, doener_fish_png::tim.get_texture_x(), doener_fish_png::tim.get_texture_y() + doener_fish_png::size.height + 2,
Assets::Main::DoenerFishInfo.tim.get_clut_x() + 16, Assets::Main::DoenerFishInfo.tim.get_clut_y() doener_fish_png::tim.get_clut_x() + 16, doener_fish_png::tim.get_clut_y()
); );
} }

View File

@@ -108,8 +108,9 @@ static const Menu::SimpleMenu::Entry MenuEntries[] = {
}; };
static const auto doener_fish = Make::SPRT( static const auto doener_fish = Make::SPRT(
Make::AreaI16(Make::PositionI16(8, GPU::Display::Height - Assets::Main::DoenerFishInfo.size.height), Assets::Main::DoenerFishInfo.size), // v this needs to be nicer! Has to be Make::AreaI16(Make::PositionI16(8, GPU::Display::Height - doener_fish_png::size.height), doener_fish_png::size),
Make::OffsetPageWithClut(Assets::Main::DoenerFishInfo.tim.get_page_offset_clut4(), Make::PageClut(Assets::Main::DoenerFishInfo.tim.get_clut_position())), // v this needs to be nicer! Has to be
Make::OffsetPageWithClut(doener_fish_png::tim.get_page_offset_clut4(), Make::PageClut(doener_fish_png::tim.get_clut_position())),
GPU::Color24::Grey() GPU::Color24::Grey()
); );

View File

@@ -68,7 +68,7 @@ namespace Assets {
static const CDFile Files[] = { static const CDFile Files[] = {
CDFileBuilder::simple_tim(LBA::PACO, PacoTIM), CDFileBuilder::simple_tim(LBA::PACO, PacoTIM),
CDFileBuilder::simple_tim(LBA::DFISH, DoenerFishInfo.tim), CDFileBuilder::simple_tim(LBA::DFISH, doener_fish_png::tim),
CDFileBuilder::simple_tim(LBA::JABY_LOAD, JabyLoader::TIMLoaction), CDFileBuilder::simple_tim(LBA::JABY_LOAD, JabyLoader::TIMLoaction),
CDFileBuilder::sony_vag(LBA::APPLE_SFX, VAG::create(0, 1.0_vol)), CDFileBuilder::sony_vag(LBA::APPLE_SFX, VAG::create(0, 1.0_vol)),
CDFileBuilder::sony_vag(LBA::BLUBB_SFX, VAG::create(1, 1.0_vol)), CDFileBuilder::sony_vag(LBA::BLUBB_SFX, VAG::create(1, 1.0_vol)),

View File

@@ -1,7 +1,8 @@
include $(JABY_ENGINE_DIR)/mkfile/common/ExportPath.mk include $(JABY_ENGINE_DIR)/mkfile/common/ExportPath.mk
include $(JABY_ENGINE_DIR)/mkfile/common/RebuildTarget.mk include $(JABY_ENGINE_DIR)/mkfile/common/RebuildTarget.mk
OUTPUT_DIR = bin OUTPUT_DIR = bin
AUTO_GEN_DIR = ../application/include/auto_gen
CLUT_4_COLOR_TRANS_FLAGS = simple-tim clut4 --color-trans CLUT_4_COLOR_TRANS_FLAGS = simple-tim clut4 --color-trans
# Ressources to convert # Ressources to convert
@@ -22,12 +23,6 @@ IconTexture_FLAGS = simple-tim clut4 --semi-trans --color-trans
INPUT += $(OUTPUT_DIR)/Paco.img INPUT += $(OUTPUT_DIR)/Paco.img
Paco_FLAGS = $(CLUT_4_COLOR_TRANS_FLAGS) Paco_FLAGS = $(CLUT_4_COLOR_TRANS_FLAGS)
INPUT += $(OUTPUT_DIR)/Controller.img
Controller_FLAGS = $(CLUT_4_COLOR_TRANS_FLAGS)
INPUT += $(OUTPUT_DIR)/doener_fish.img
doener_fish_FLAGS = $(CLUT_4_COLOR_TRANS_FLAGS)
INPUT += $(OUTPUT_DIR)/JabyStar.img INPUT += $(OUTPUT_DIR)/JabyStar.img
JabyStar_FLAGS = $(CLUT_4_COLOR_TRANS_FLAGS) JabyStar_FLAGS = $(CLUT_4_COLOR_TRANS_FLAGS)
@@ -60,7 +55,12 @@ $(OUTPUT_DIR)/%.tim: %.png
@mkdir -p $(OUTPUT_DIR) @mkdir -p $(OUTPUT_DIR)
psxfileconv --lz4 $< -o $@ $($*_TIM_FLAGS) psxfileconv --lz4 $< -o $@ $($*_TIM_FLAGS)
all: $(INPUT) $(AUTO_GEN_DIR)/vram_layout.hpp: tim_example.tim_project Controller.png doener_fish.png
@mkdir -p $(AUTO_GEN_DIR)
psxfileconv tim_example.tim_project -o $(OUTPUT_DIR)/dummy.img project --hpp $(AUTO_GEN_DIR)/vram_layout.hpp
all: $(INPUT) $(AUTO_GEN_DIR)/vram_layout.hpp
clean: clean:
rm -fr $(OUTPUT_DIR) rm -fr $(OUTPUT_DIR)
rm -fr $(AUTO_GEN_DIR)

View File

@@ -0,0 +1 @@
{"jobs":[{"name":"doener_fish.png","file_path":"doener_fish.png","image_pos":{"x":926,"y":0},"palette_rect":{"pos":{"x":976,"y":510},"size":{"width":16,"height":1}},"settings":{"compress":true,"transparency":"FirstColor","encoding":"FourBit"}},{"name":"Controller.png","file_path":"Controller.png","image_pos":{"x":384,"y":0},"palette_rect":{"pos":{"x":384,"y":511},"size":{"width":16,"height":1}},"settings":{"compress":true,"transparency":"FirstColor","encoding":"FourBit"}}]}

View File

@@ -224,7 +224,7 @@ namespace JabyEngine {
return Size::create(static_cast<T>(size.width), static_cast<T>(size.height)); return Size::create(static_cast<T>(size.width), static_cast<T>(size.height));
} }
auto operator<=>(const Size<T>&) const = default; bool operator<=>(const Size<T>&) const = default;
}; };
using SizeI8 = Size<int8_t>; using SizeI8 = Size<int8_t>;
using SizeU8 = Size<uint8_t>; using SizeU8 = Size<uint8_t>;

View File

@@ -19,13 +19,13 @@
{ {
"label": "make", "label": "make",
"type": "shell", "type": "shell",
"command": "../../scripts/podman_jaby_engine.sh ../../:src/Library make ${input:target} BUILD_PROFILE=${input:build cfg} PSX_TV_FORMAT=${input:tv format} CUSTOM_CONFIG=${input:config options}", "command": "../../scripts/podman_jaby_engine.sh ../../:src/Library bear --output ${workspaceFolder}/../../compile_commands.json -- make ${input:target} BUILD_PROFILE=${input:build cfg} PSX_TV_FORMAT=${input:tv format} CUSTOM_CONFIG=${input:config options}",
"group": "build" "group": "build"
}, },
{ {
"label": "make_all", "label": "make_all",
"type": "shell", "type": "shell",
"command": "../../scripts/podman_jaby_engine.sh ../../:src/Library make -f MakeAll.mk ${input:target prefix}_${input:target} BUILD_PROFILE=${input:build cfg} CUSTOM_CONFIG=${input:config options}", "command": "../../scripts/podman_jaby_engine.sh ../../:src/Library bear --output ${workspaceFolder}/../../compile_commands.json -- make -f MakeAll.mk ${input:target prefix}_${input:target} BUILD_PROFILE=${input:build cfg} CUSTOM_CONFIG=${input:config options}",
"group": "build" "group": "build"
} }
], ],
@@ -75,29 +75,5 @@
}, },
"settings": { "settings": {
"cmake.configureOnOpen": false, "cmake.configureOnOpen": false,
"C_Cpp.default.includePath": [
"include",
"../../include"
],
"C_Cpp.default.compilerPath": "",
"C_Cpp.default.cStandard": "c17",
"C_Cpp.default.cppStandard": "c++20",
"C_Cpp.default.intelliSenseMode": "linux-gcc-x86",
"C_Cpp.default.compilerArgs": [
],
"C_Cpp.default.defines": [
"JABYENGINE_PAL",
"__DEBUG_SPU_MMU__",
"__friends=public"
],
"files.exclude": {
"**/*.o": true,
"**/*.dep": true
},
"files.associations": {
"stdio.h": "c",
"TUTO0.C": "cpp",
"MAIN.C": "cpp"
}
} }
} }

File diff suppressed because it is too large Load Diff

View File

@@ -28,11 +28,15 @@ symphonia-vorbis = ["symphonia", "symphonia/vorbis"]
[dependencies] [dependencies]
bitflags = "2.8.0" bitflags = "2.8.0"
cdtypes = {path = "../cdtypes"} cdtypes = {path = "../cdtypes"}
cpp_out = {path = "../cpp_out"}
clap = {version = "4.5.27", features = ["derive"]} clap = {version = "4.5.27", features = ["derive"]}
image = "0.24.9" image = "0.24.9"
hound = "3.5.1" hound = "3.5.1"
paste = "1.0.15" paste = "1.0.15"
png = "0.17.16" png = "0.17.16"
rubato = "0.16.1" rubato = "0.16.1"
serde = {version = "1.0.219", features = ["derive"]}
serde_json = "1.0"
symphonia = {version = "0.5.4", optional = true, default-features = false} symphonia = {version = "0.5.4", optional = true, default-features = false}
tim_tool = {path = "../tim_tool"}
tool_helper = {path = "../tool_helper"} tool_helper = {path = "../tool_helper"}

View File

@@ -23,7 +23,7 @@ pub struct Point {
} }
impl Point { impl Point {
pub const POINT_VALUE_NAME:&'static str = "{x,y}"; pub const POINT_VALUE_NAME:&'static str = "{x,y}";
} }
impl std::default::Default for Point { impl std::default::Default for Point {

View File

@@ -36,7 +36,8 @@ fn modify_palette(mut image: IndexedImage, clut_align: ClutAlignment, semi_trans
image image
} }
fn encode<T: PSXImageConverter>(header_conv: &mut dyn HeaderEncoder, image: T, tex_pos: Point, clut_pos: Point, color_depth: ColorType, clut_align: ClutAlignment, output: &mut dyn Write) -> Result<(), Error> { fn encode<T: PSXImageConverter>(header_conv: &mut dyn HeaderEncoder, image: T, tex_pos: Point, clut_pos: Point, color_depth: ColorType, clut_align: ClutAlignment, output: &mut dyn Write) -> Result<(u16, u16), Error> {
let image_size = (image.width(), image.height());
let (width, height) = { let (width, height) = {
fn return_error(clut_type: u32, div: u32, width: u16, height: u16) -> Result<(u16, u16), Error> { fn return_error(clut_type: u32, div: u32, width: u16, height: u16) -> Result<(u16, u16), Error> {
return Err(Error::from_callback(|| {format!("CLUT {} images require a width divideable by {} (found width: {}/{}={}, height: {})", clut_type, div, width, div, (width as f32/div as f32), height)})); return Err(Error::from_callback(|| {format!("CLUT {} images require a width divideable by {} (found width: {}/{}={}, height: {})", clut_type, div, width, div, (width as f32/div as f32), height)}));
@@ -115,10 +116,10 @@ fn encode<T: PSXImageConverter>(header_conv: &mut dyn HeaderEncoder, image: T, t
tool_helper::raw::write_raw(output, &color)?; tool_helper::raw::write_raw(output, &color)?;
} }
Ok(()) Ok(image_size)
} }
fn convert_full16(header_conv: &mut dyn HeaderEncoder, input: Input, output: &mut dyn Write, tex_pos: Point) -> Result<(), Error> { fn convert_full16(header_conv: &mut dyn HeaderEncoder, input: Input, output: &mut dyn Write, tex_pos: Point) -> Result<(u16, u16), Error> {
match ImageReader::new(Cursor::new(tool_helper::input_to_vec(input)?)).with_guessed_format()?.decode() { match ImageReader::new(Cursor::new(tool_helper::input_to_vec(input)?)).with_guessed_format()?.decode() {
Ok(image) => { Ok(image) => {
match image { match image {
@@ -132,7 +133,7 @@ fn convert_full16(header_conv: &mut dyn HeaderEncoder, input: Input, output: &mu
} }
} }
fn convert_palette_based(header_conv: &mut dyn HeaderEncoder, input: Input, output: &mut dyn Write, tex_pos: Point, clut_pos: Point, color_type: ColorType, clut_align: ClutAlignment, semi_transparent: bool, transparent_palette: bool) -> Result<(), Error> { fn convert_palette_based(header_conv: &mut dyn HeaderEncoder, input: Input, output: &mut dyn Write, tex_pos: Point, clut_pos: Point, color_type: ColorType, clut_align: ClutAlignment, semi_transparent: bool, transparent_palette: bool) -> Result<(u16, u16), Error> {
match png::Decoder::new(input).read_info() { match png::Decoder::new(input).read_info() {
Ok(reader) => { Ok(reader) => {
let output_type = { let output_type = {

View File

@@ -7,7 +7,7 @@ use tool_helper::{Error, Input};
pub type Arguments = super::args::Arguments; pub type Arguments = super::args::Arguments;
pub fn convert(args: Arguments, input: Input, output: &mut dyn Write) -> Result<(), Error> { pub fn convert(args: Arguments, input: Input, output: &mut dyn Write) -> Result<(u16, u16), Error> {
let mut header_conv = Header::default(); let mut header_conv = Header::default();
match args.color_depth { match args.color_depth {
ColorType::Full16 => super::convert_full16(&mut header_conv, input, output, Point::default()), ColorType::Full16 => super::convert_full16(&mut header_conv, input, output, Point::default()),

View File

@@ -9,16 +9,16 @@ use tool_helper::{Error, Input};
#[derive(Args)] #[derive(Args)]
pub struct Arguments { pub struct Arguments {
#[clap(flatten)] #[clap(flatten)]
global: super::args::Arguments, pub(crate) global: super::args::Arguments,
#[clap(long, value_parser, default_value_t, value_name = Point::POINT_VALUE_NAME)] #[clap(long, value_parser, default_value_t, value_name = Point::POINT_VALUE_NAME)]
clut_pos: Point, pub(crate) clut_pos: Point,
#[clap(long, value_parser, default_value_t, value_name = Point::POINT_VALUE_NAME)] #[clap(long, value_parser, default_value_t, value_name = Point::POINT_VALUE_NAME)]
tex_pos: Point, pub(crate) tex_pos: Point,
} }
pub fn convert(args: Arguments, input: Input, output: &mut dyn Write) -> Result<(), Error> { pub fn convert(args: Arguments, input: Input, output: &mut dyn Write) -> Result<(u16, u16), Error> {
let global_args = args.global; let global_args = args.global;
let mut header_conv = Header::default(); let mut header_conv = Header::default();

View File

@@ -1,3 +1,88 @@
pub mod audio; pub mod audio;
pub mod images; pub mod images;
pub mod nothing; pub mod nothing;
pub mod project;
use crate::audio::*;
use crate::images::*;
use clap::Subcommand;
use std::path::PathBuf;
use tool_helper::Error;
#[derive(Subcommand)]
pub enum SubCommands {
Nothing,
SimpleTIM(reduced_tim::Arguments),
TIM(tim::Arguments),
VAG(vag::Arguments),
XA(xa::Arguments),
Project(project::Arguments),
}
pub fn run_subcommand(compress_lz4: bool, input_path: Option<PathBuf>, output_path: Option<PathBuf>, sub_command: SubCommands) -> Result<Option<(u16, u16)>, Error> {
let mut input = tool_helper::open_input(&input_path)?;
let mut buffer = Vec::<u8>::new();
let mut output_file = tool_helper::open_output(&output_path)?;
let dst_buffer = {
if compress_lz4 {
&mut buffer as &mut dyn std::io::Write
}
else {
&mut output_file as &mut dyn std::io::Write
}
};
let cmd_result: Result<Option<(u16, u16)>, Error> = {
match sub_command {
SubCommands::Nothing => {
nothing::copy(&mut input, dst_buffer)?;
Ok(None)
},
SubCommands::SimpleTIM(args) => {
Ok(Some(reduced_tim::convert(args, input, dst_buffer)?))
},
SubCommands::TIM(args) => {
Ok(Some(tim::convert(args, input, dst_buffer)?))
},
SubCommands::VAG(args) => {
audio::vag::convert(args, &output_path, input, dst_buffer)?;
Ok(None)
}
SubCommands::XA(args) => {
audio::xa::convert(args, input, dst_buffer)?;
Ok(None)
}
SubCommands::Project(args) => {
project::run_project(input, args, input_path, &output_path)?;
if let Some(file_path) = &output_path {
let _result = std::fs::remove_file(file_path);
}
Ok(None)
},
}
};
match cmd_result {
Ok(cmd_result) => {
// We encoded the file to a temporary buffer and now need to write it
if compress_lz4 {
let buffer = tool_helper::compress::psx_default::lz4(&buffer)?;
output_file.write(&buffer)?;
}
Ok(cmd_result)
}
Err(cmd_error) => {
if let Some(file_path) = output_path {
let _result = std::fs::remove_file(file_path);
}
else {
tool_helper::print_warning("Open stream detected! Incomplete file can not be deleted".to_owned());
}
Err(cmd_error)
}
}
}

View File

@@ -1,11 +1,11 @@
use clap::{Parser, Subcommand}; use clap::Parser;
use psxfileconv::{audio::{self, *}, images::*, nothing};
use std::path::PathBuf; use std::path::PathBuf;
use tool_helper::{exit_with_error, Error}; use psxfileconv::{SubCommands, run_subcommand};
use tool_helper::exit_with_error;
#[derive(Parser)] #[derive(Parser)]
#[clap(about = "Converts files to various JabyEngine related file formats", long_about = None)] #[clap(about = "Converts files to various JabyEngine related file formats", long_about = None)]
struct CommandLine { pub struct CommandLine {
#[clap(long="lz4", default_value_t=false)] #[clap(long="lz4", default_value_t=false)]
compress_lz4: bool, compress_lz4: bool,
@@ -19,64 +19,10 @@ struct CommandLine {
sub_command: SubCommands, sub_command: SubCommands,
} }
#[derive(Subcommand)]
enum SubCommands {
Nothing,
SimpleTIM(reduced_tim::Arguments),
TIM(tim::Arguments),
VAG(vag::Arguments),
XA(xa::Arguments),
}
fn run_main(cmd: CommandLine) -> Result<(), Error> {
let mut input = tool_helper::open_input(&cmd.input_file)?;
let mut buffer = Vec::<u8>::new();
let mut output_file = tool_helper::open_output(&cmd.output_file)?;
let dst_buffer = {
if cmd.compress_lz4 {
&mut buffer as &mut dyn std::io::Write
}
else {
&mut output_file as &mut dyn std::io::Write
}
};
let cmd_result: Result<(), Error> = {
match cmd.sub_command {
SubCommands::Nothing => nothing::copy(&mut input, dst_buffer),
SubCommands::SimpleTIM(args) => reduced_tim::convert(args, input, dst_buffer),
SubCommands::TIM(args) => tim::convert(args, input, dst_buffer),
SubCommands::VAG(args) => audio::vag::convert(args, &cmd.output_file, input, dst_buffer),
SubCommands::XA(args) => audio::xa::convert(args, input, dst_buffer),
}
};
if let Err(cmd_error) = cmd_result {
if let Some(file_path) = cmd.output_file {
let _result = std::fs::remove_file(file_path);
}
else {
tool_helper::print_warning("Open stream detected! Incomplete file can not be deleted".to_owned());
}
return Err(cmd_error);
}
// We encoded the file to a temporary buffer and now need to write it
if cmd.compress_lz4 {
let buffer = tool_helper::compress::psx_default::lz4(&buffer)?;
output_file.write(&buffer)?;
}
Ok(())
}
fn main() { fn main() {
match CommandLine::try_parse() { match CommandLine::try_parse() {
Ok(cmd) => { Ok(cmd) => {
if let Err(error) = run_main(cmd) { if let Err(error) = run_subcommand(cmd.compress_lz4, cmd.input_file, cmd.output_file, cmd.sub_command) {
exit_with_error(error); exit_with_error(error);
} }
}, },

View File

@@ -0,0 +1,39 @@
use std::path::PathBuf;
use tim_tool::logic::project::Job;
use tool_helper::{Error, Output};
pub struct CppHeader {
file_out: Output,
}
impl CppHeader {
pub fn new(file_path: &Option<PathBuf>) -> Result<CppHeader, Error> {
let mut file_out = tool_helper::open_output(file_path)?;
writeln!(file_out, "#pragma once")?;
writeln!(file_out, "#include <PSX/File/cd_file_types.hpp>")?;
writeln!(file_out, "")?;
Ok(CppHeader{file_out})
}
pub fn push_job(&mut self, job: &Job, size: (u16, u16)) -> Result<(), Error> {
let name = job.name.replace('.', "_");
let (clut_x, clut_y) = if let Some(palette_rect) = &job.palette_rect {(palette_rect.pos.x, palette_rect.pos.y)} else {(0, 0)};
writeln!(self.file_out, "namespace {} {{", name)?;
writeln!(self.file_out, "\tusing namespace JabyEngine;")?;
writeln!(self.file_out, "")?;
writeln!(self.file_out, "\tstatic constexpr auto tim = SimpleTIM::create({}, {}, {}, {});", job.image_pos.x, job.image_pos.y, clut_x, clut_y)?;
writeln!(self.file_out, "\tstatic constexpr auto size = GPU::SizeI16::create({}, {});", size.0, size.1)?;
writeln!(self.file_out, "}}")?;
Ok(())
}
}
impl Drop for CppHeader {
fn drop(&mut self) {
}
}

View File

@@ -0,0 +1,90 @@
mod hpp_out;
use crate::images::args::{Arguments as IMGArguments, ClutAlignment, ColorType};
use clap::Args;
use hpp_out::CppHeader;
use std::path::PathBuf;
use tool_helper::{Error, Input};
use tim_tool::logic::{tim::types::Encoding, project::*};
#[derive(Args)]
pub struct Arguments {
#[clap(long="hpp", value_parser)]
hpp_out_path: Option<PathBuf>
}
pub fn run_project(input: Input, args: Arguments, input_path: Option<PathBuf>, output_path: &Option<PathBuf>) -> Result<(), Error> {
let location_path = if let Some(input_path) = input_path {input_path} else {PathBuf::from(".")};
let output_path = if let Some(output_path) = &output_path {
let mut output_path = output_path.clone();
if output_path.is_file() {
output_path.pop();
}
output_path
} else {PathBuf::from(".")};
let project = serde_json::from_reader::<Input, Project>(input).map_err(|error|{Error::from_text(format!("Reading project failed: {}", error))})?;
let mut hpp_out = CppHeader::new(&args.hpp_out_path)?;
for mut job in project.jobs {
let args = to_arguments(&job)?;
let output_path = {
let mut path = output_path.clone();
path.push(&job.name);
path.set_extension("img");
path
};
let sub_command = crate::SubCommands::SimpleTIM(args);
let org_img_size = crate::run_subcommand(job.settings.compress, Some(Job::create_file_path(job.file_path, &location_path)), Some(output_path), sub_command)?;
job.file_path = PathBuf::new();
hpp_out.push_job(&job, org_img_size.unwrap_or((0, 0)))?;
}
Ok(())
}
fn to_arguments(job: &Job) -> Result<IMGArguments, Error> {
let (semi_transparent, transparent_palette) = get_transparency(&job.settings.transparency);
return Ok(IMGArguments {
color_depth: get_encoding(&job.settings.encoding),
clut_align: get_palette_rect(&job.palette_rect)?,
semi_transparent,
transparent_palette,
});
fn get_transparency(transparency: &Transparency) -> (bool, bool) {
match transparency {
Transparency::None => (false, false),
Transparency::FirstColor => (false, true),
Transparency::PSXSemi => (true, false),
Transparency::Both => (true, true),
}
}
fn get_encoding(encoding: &Encoding) -> ColorType {
match encoding {
Encoding::FourBit => ColorType::Clut4,
Encoding::EightBit => ColorType::Clut8,
Encoding::FullColor => ColorType::Full16,
}
}
fn get_palette_rect(rect: &Option<PaletteRect>) -> Result<ClutAlignment, Error> {
if let Some(rect) = rect {
if rect.size.height == 1 {
return Ok(ClutAlignment::Linear);
}
if rect.size.width%16 == 0 {
return Ok(ClutAlignment::Block);
}
return Err(Error::from_text(format!("psxfileconv currently only supports linear or block CLUTs with a width of 16px")));
}
Ok(ClutAlignment::None)
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -1,20 +1,23 @@
[package] [package]
name = "tim_tool" name = "tim_tool"
version = "0.1.0" version = "1.0.0"
edition = "2021" edition = "2021"
[profile.release] [profile.release]
panic = "abort" panic = "abort"
[dependencies] [dependencies]
pathdiff = "0.2.3"
png = "0.17.16" png = "0.17.16"
rfd = "0.15.2" rfd = "0.15.3"
slint = "1.9.2" slint = "1.10.0"
serde = {version = "1.0.219", features = ["derive"]}
serde_json = "1.0"
tiny-skia = "0.11.4" tiny-skia = "0.11.4"
tool_helper = {path = "../tool_helper"} tool_helper = {path = "../tool_helper"}
[build-dependencies] [build-dependencies]
slint-build = "1.9.2" slint-build = "1.10.0"
[package.metadata.bundle] [package.metadata.bundle]
name = "TIMTOOL" name = "TIMTOOL"
@@ -25,4 +28,4 @@ category = "Developer Tool"
short_description = "TIM Tool for JabyEngine" short_description = "TIM Tool for JabyEngine"
long_description = """ long_description = """
A new interpetation of the TIM Tool from Sony, for use with PSYQ and the JabyEngine A new interpetation of the TIM Tool from Sony, for use with PSYQ and the JabyEngine
""" """

View File

@@ -1,8 +1,10 @@
use crate::{gui::{main_tab::MainTab, MutexTIMManager, VRAM_HEIGHT, VRAM_WIDTH}, MainWindow}; use std::{fs::File, io::Write, path::PathBuf};
use crate::{gui::{self, main_tab::{MainTab, NewVRAMImageInfo}, MutexTIMManager, VRAM_HEIGHT, VRAM_WIDTH}, MainWindow};
use super::FileTab; use super::FileTab;
use rfd::FileDialog; use rfd::FileDialog;
use slint::SharedString; use slint::SharedString;
use tim_tool::logic::tim::types::Encoding; use tim_tool::logic::{project::{FileSettings, ImagePosition, Job, PaletteRect, Project, Transparency}, tim::types::Encoding, TIMManager};
use tool_helper::Error; use tool_helper::Error;
pub(super) fn on_browse_file(tim_manager: MutexTIMManager) -> impl FnMut(&mut FileTab, &MainWindow) -> Result<(), Error> + 'static { pub(super) fn on_browse_file(tim_manager: MutexTIMManager) -> impl FnMut(&mut FileTab, &MainWindow) -> Result<(), Error> + 'static {
@@ -32,7 +34,7 @@ pub(super) fn on_browse_file(tim_manager: MutexTIMManager) -> impl FnMut(&mut Fi
}; };
} }
pub(super) fn on_update_palette_size(tim_manager: MutexTIMManager) -> impl FnMut(&mut FileTab, &MainWindow, u32, u32) -> Result<(), Error> + 'static { pub(super) fn on_update_palette_size(tim_manager: MutexTIMManager) -> impl FnMut(&mut FileTab, &MainWindow, u16, u16) -> Result<(), Error> + 'static {
return move |file_tab, _main_window, width, height| -> Result<(), Error> { return move |file_tab, _main_window, width, height| -> Result<(), Error> {
file_tab.update_palette(tim_manager.lock().expect("VRAM already locked").change_unadded_tim_palette_size(width, height)?); file_tab.update_palette(tim_manager.lock().expect("VRAM already locked").change_unadded_tim_palette_size(width, height)?);
Ok(()) Ok(())
@@ -43,15 +45,8 @@ pub(super) fn on_add_image(tim_manager: MutexTIMManager) -> impl FnMut(&mut File
return move |file_tab, main_tab, main_window| { return move |file_tab, main_tab, main_window| {
let file_name = file_tab.get_file_name(); let file_name = file_tab.get_file_name();
let encoding = file_tab.get_encoding()?; let encoding = file_tab.get_encoding()?;
let mut tim_mgr = tim_manager.lock().expect("VRAM already locked");
let (image, palette_image) = tim_mgr.get_converted_unadded_tim_image(encoding)?;
let (full_image, _) = tim_mgr.get_converted_unadded_tim_image(Encoding::FullColor)?;
let images_created = main_tab.add_new_vram_file(&file_name, full_image, image, encoding, palette_image); add_unadded_tim(main_tab, &mut tim_manager.lock().expect("VRAM already locked"), UnaddedTIM::new(&file_name, encoding), FileSettings::from_encoding(encoding))?;
if let Err(error) = tim_mgr.add_unadded_tim(images_created) {
main_tab.pop_vram_files(images_created);
return Err(error);
}
file_tab.clear_load(); file_tab.clear_load();
main_window.invoke_change_to_main(); main_window.invoke_change_to_main();
@@ -59,26 +54,199 @@ pub(super) fn on_add_image(tim_manager: MutexTIMManager) -> impl FnMut(&mut File
}; };
} }
pub(super) fn on_load_project_clicked() -> impl FnMut(&mut FileTab, &MainWindow) -> Result<(), Error> + 'static { pub(super) fn on_load_project_clicked(tim_manager: MutexTIMManager) -> impl FnMut(&mut FileTab, &mut MainTab, &MainWindow) -> Result<(), Error> + 'static {
move |_file_tab, _main_window| { move |_file_tab, main_tab, main_window| {
Err(Error::not_implemented("on_load_project_clicked")) let open_location = main_window.get_project_widget_open_project_path();
if open_location.is_empty() {
return Err(Error::from_str("Please specify location for project file to open"));
}
let file_content = tool_helper::read_file_to_string(&PathBuf::from(open_location.as_str()))?;
let new_project = match serde_json::from_str::<Project>(&file_content) {
Ok(project) => project,
Err(error) => {
return Err(Error::from_error(error));
}
};
let mut tim_manager = tim_manager.lock().expect("VRAM already locked");
if !main_window.get_project_widget_append_project_elements() {
clear_all_vram_images(main_tab, &mut tim_manager);
main_window.invoke_clear_file_tab_current_selected_file();
}
for job in new_project.jobs {
let file_path = Job::create_file_path(job.file_path, open_location.as_str());
let (_, _) = tim_manager.load_unadded_tim(&file_path)?;
let (pal_x, pal_y, pal_width, pal_height) = if let Some(palette_rect) = job.palette_rect {palette_rect.into()} else {(0, 0, 0, 0)};
tim_manager.change_unadded_tim_palette_size(pal_width, pal_height)?;
let unadded_tim = UnaddedTIM{
file_name: &job.name,
image_x: job.image_pos.x,
image_y: job.image_pos.y,
palette_x: pal_x,
palette_y: pal_y,
encoding: job.settings.encoding
};
add_unadded_tim(main_tab, &mut tim_manager, unadded_tim, job.settings)?;
}
main_window.invoke_change_to_main();
Ok(())
} }
} }
pub(super) fn on_save_project_clicked() -> impl FnMut(&mut FileTab, &MainWindow) -> Result<(), Error> + 'static { pub(super) fn on_save_project_clicked(tim_manager: MutexTIMManager) -> impl FnMut(&mut FileTab, &MainTab, &MainWindow) -> Result<(), Error> + 'static {
move |_file_tab, _main_window| { move |_file_tab, main_tab, main_window| {
Err(Error::not_implemented("on_save_project_clicked")) let save_location = main_window.get_project_widget_save_project_path();
if save_location.is_empty() {
return Err(Error::from_str("Please specify save location for project file"));
}
let tim_info = tim_manager.lock().expect("VRAM already locked").clone_added_tims();
let vram_info = main_tab.clone_vram_info();
let use_rel_path = main_window.get_project_widget_use_rel_paths();
if tim_info.len() != vram_info.len() {
return Err(Error::from_str("TIM and VRAM info not in sync! Please close program"));
}
let mut cur_job:Option<Job> = None;
let mut cur_palette:Option<PaletteRect> = None;
let mut map_result = Ok(());
let mut project = Project::new(tim_info.into_iter().zip(vram_info.into_iter()).filter_map(|(tim, (name, vram))| {
if map_result.is_err() {
return None;
}
if vram.is_palette {
let cur_palette = std::mem::replace(&mut cur_palette, None);
if let Some(mut cur_palette) = cur_palette {
cur_palette.pos = ImagePosition::new(vram.x as u16, vram.y as u16);
if let Some(cur_job) = &mut cur_job {
cur_job.palette_rect = Some(cur_palette);
}
}
None
}
else {
// We are done with the old job
let prev_job = std::mem::replace(&mut cur_job, None);
if let Some(tim) = tim {
if let Some((width, height)) = tim.get_palette_size() {
cur_palette = Some(PaletteRect::new(0, 0, width, height));
}
let file_path = if use_rel_path {
match tim.get_path_rel_to(PathBuf::from(save_location.as_str())) {
Ok(file_path) => file_path,
Err(error) => {
map_result = Err(error);
PathBuf::new()
}
}
} else {tim.get_path()};
cur_job = Some(Job::new(name, file_path, (vram.x as u16, vram.y as u16), FileSettings::new(
vram.use_compression,
Transparency::from(vram.trans_setting),
Encoding::from_str(vram.encoding_str.as_str())
)));
}
prev_job
}
}).collect());
map_result?;
if let Some(cur_job) = cur_job {
project.jobs.push(cur_job);
}
let json_content = match serde_json::to_string(&project) {
Ok(json_content) => json_content,
Err(error) => {
return Err(Error::from_error(error));
}
};
let mut file = File::create(save_location)?;
file.write_all(json_content.as_bytes())?;
gui::display_information("Saving project", "Project saved successfully");
Ok(())
} }
} }
pub(super) fn on_browse_open_project_clicked() -> impl FnMut(&mut FileTab, &MainWindow) -> Result<(), Error> + 'static { pub(super) fn on_browse_open_project_clicked() -> impl FnMut(&mut FileTab, &MainWindow) -> Result<(), Error> + 'static {
move |_file_tab, _main_window| { move |_file_tab, main_window| {
Err(Error::not_implemented("on_browse_open_project_clicked")) let file_path = create_project_file_dialog()
.set_title("Save location for TIM project file")
.pick_file();
if let Some(file_path) = file_path {
if let Some(file_path) = file_path.to_str() {
main_window.set_project_widget_open_project_path(SharedString::from(file_path));
}
}
Ok(())
} }
} }
pub(super) fn on_browse_save_project_clicked() -> impl FnMut(&mut FileTab, &MainWindow) -> Result<(), Error> + 'static { pub(super) fn on_browse_save_project_clicked() -> impl FnMut(&mut FileTab, &MainWindow) -> Result<(), Error> + 'static {
move |_file_tab, _main_window| { move |_file_tab, main_window| {
Err(Error::not_implemented("on_browse_save_project_clicked")) let file_path = create_project_file_dialog()
.set_title("Save location for TIM project file")
.save_file();
if let Some(file_path) = file_path {
if let Some(file_path) = file_path.to_str() {
main_window.set_project_widget_save_project_path(SharedString::from(file_path));
}
}
Ok(())
} }
}
struct UnaddedTIM<'a> {
pub file_name: &'a String,
pub image_x: u16,
pub image_y: u16,
pub palette_x: u16,
pub palette_y: u16,
pub encoding: Encoding,
}
impl<'a> UnaddedTIM<'a> {
pub fn new(file_name: &String, encoding: Encoding,) -> UnaddedTIM {
UnaddedTIM{file_name, image_x: 0, image_y: 0, palette_x: 0, palette_y: 0, encoding}
}
}
fn add_unadded_tim(main_tab: &mut MainTab, tim_manager: &mut TIMManager, unadded_tim: UnaddedTIM, settings: FileSettings) -> Result<(), Error> {
let (image, palette_image) = tim_manager.get_converted_unadded_tim_image(unadded_tim.encoding)?;
let (full_image, _) = tim_manager.get_converted_unadded_tim_image(Encoding::FullColor)?;
let image = NewVRAMImageInfo::new(image, unadded_tim.image_x, unadded_tim.image_y, settings);
let palette_image = if let Some(palette_image) = palette_image { Some(NewVRAMImageInfo::new(palette_image, unadded_tim.palette_x, unadded_tim.palette_y, FileSettings::from_encoding(Encoding::FullColor))) } else { None };
let images_created = main_tab.add_new_vram_file(unadded_tim.file_name, full_image, image, palette_image);
if let Err(error) = tim_manager.add_unadded_tim(images_created) {
main_tab.pop_vram_files(images_created);
return Err(error);
}
Ok(())
}
fn clear_all_vram_images(main_tab: &mut MainTab, tim_manager: &mut TIMManager) {
tim_manager.clear();
main_tab.clear();
}
fn create_project_file_dialog() -> FileDialog {
FileDialog::new()
.add_filter("TIM project file (.tim_project)", &["tim_project"])
.add_filter("JSON file (.json; .jsn)", &["json", "jsn"])
.add_filter("All", &["*"])
} }

View File

@@ -60,29 +60,29 @@ impl FileTab {
let (cloned_object, cloned_main_window, mut function) = (object.clone(), main_window.clone(), callbacks::on_update_palette_size(tim_manager.clone())); let (cloned_object, cloned_main_window, mut function) = (object.clone(), main_window.clone(), callbacks::on_update_palette_size(tim_manager.clone()));
main_window.borrow().on_file_tab_update_palette_size(move |width, height| { main_window.borrow().on_file_tab_update_palette_size(move |width, height| {
if let Err(error) = function(&mut cloned_object.borrow_mut(), &cloned_main_window.borrow(), width as u32, height as u32) { if let Err(error) = function(&mut cloned_object.borrow_mut(), &cloned_main_window.borrow(), width as u16, height as u16) {
display_error("Updating palette failed", &error.to_string()); display_error("Updating palette failed", &error.to_string());
} }
}); });
let (cloned_object, cloned_main_window, mut function) = (object.clone(), main_window.clone(), callbacks::on_add_image(tim_manager.clone())); let (cloned_object, cloned_main_tab, cloned_main_window, mut function) = (object.clone(), main_tab.clone(), main_window.clone(), callbacks::on_add_image(tim_manager.clone()));
main_window.borrow().on_file_tab_add_convert_image(move || { main_window.borrow().on_file_tab_add_convert_image(move || {
if let Err(error) = function(&mut cloned_object.borrow_mut(), &mut main_tab.borrow_mut(), &cloned_main_window.borrow()) { if let Err(error) = function(&mut cloned_object.borrow_mut(), &mut cloned_main_tab.borrow_mut(), &cloned_main_window.borrow()) {
display_error("Adding file failed", &error.to_string()); display_error("Adding file failed", &error.to_string());
} }
}); });
// Project functions // Project functions
let (cloned_object, cloned_main_window, mut function) = (object.clone(), main_window.clone(), callbacks::on_load_project_clicked()); let (cloned_object, cloned_main_tab, cloned_main_window, mut function) = (object.clone(), main_tab.clone(), main_window.clone(), callbacks::on_load_project_clicked(tim_manager.clone()));
main_window.borrow().on_project_widget_load_project_clicked(move || { main_window.borrow().on_project_widget_load_project_clicked(move || {
if let Err(error) = function(&mut cloned_object.borrow_mut(), &cloned_main_window.borrow()) { if let Err(error) = function(&mut cloned_object.borrow_mut(), &mut cloned_main_tab.borrow_mut(), &cloned_main_window.borrow()) {
display_error("Loading project failed", &error.to_string()); display_error("Loading project failed", &error.to_string());
} }
}); });
let (cloned_object, cloned_main_window, mut function) = (object.clone(), main_window.clone(), callbacks::on_save_project_clicked()); let (cloned_object, cloned_main_tab, cloned_main_window, mut function) = (object.clone(), main_tab.clone(), main_window.clone(), callbacks::on_save_project_clicked(tim_manager.clone()));
main_window.borrow().on_project_widget_save_project_clicked (move || { main_window.borrow().on_project_widget_save_project_clicked (move || {
if let Err(error) = function(&mut cloned_object.borrow_mut(), &cloned_main_window.borrow()) { if let Err(error) = function(&mut cloned_object.borrow_mut(), &cloned_main_tab.borrow(), &cloned_main_window.borrow()) {
display_error("Saving project failed", &error.to_string()); display_error("Saving project failed", &error.to_string());
} }
}); });

View File

@@ -1,28 +1,41 @@
mod callbacks; mod callbacks;
use crate::{gui::{MutexTIMManager, VRAM_HEIGHT, VRAM_WIDTH}, VRAMImage}; use crate::{gui::{MutexTIMManager, VRAM_HEIGHT, VRAM_WIDTH}, VRAMImgData, VRAMInfo, VRAMData};
use super::MainWindowRef; use super::MainWindowRef;
use slint::{Model, SharedString}; use slint::{Model, SharedString};
use std::{cell::RefCell, ops::RangeInclusive, rc::Rc, sync::{Arc, Mutex}}; use std::{cell::RefCell, ops::RangeInclusive, rc::Rc, sync::{Arc, Mutex}};
use tim_tool::logic::tim::types::Encoding; use tim_tool::logic::project::FileSettings;
pub struct NewVRAMImageInfo {
pub image: slint::Image,
pub x: u16,
pub y: u16,
pub settings: FileSettings,
}
impl NewVRAMImageInfo {
pub fn new(image: slint::Image, x: u16, y: u16, settings: FileSettings) -> NewVRAMImageInfo {
NewVRAMImageInfo{image, x, y, settings}
}
}
struct VRAM { struct VRAM {
count: usize, count: usize,
file_list: Rc<slint::VecModel<slint::StandardListViewItem>>, file_list: Rc<slint::VecModel<slint::StandardListViewItem>>,
image_list: Rc<slint::VecModel<VRAMImage>> info: Rc<slint::VecModel<VRAMData>>
} }
impl VRAM { impl VRAM {
pub fn push(&mut self, name: slint::StandardListViewItem, image: VRAMImage) { pub fn push(&mut self, name: slint::StandardListViewItem, image: VRAMData) {
self.file_list.push(name); self.file_list.push(name);
self.image_list.push(image); self.info.push(image);
self.count += 1; self.count += 1;
} }
pub fn remove(&mut self, idx: usize) { pub fn remove(&mut self, idx: usize) {
self.count -= 1; self.count -= 1;
self.file_list.remove(idx); self.file_list.remove(idx);
self.image_list.remove(idx); self.info.remove(idx);
} }
pub fn pop(&mut self) { pub fn pop(&mut self) {
@@ -40,12 +53,12 @@ impl MainTab {
pub fn new(main_window: MainWindowRef, tim_manager: MutexTIMManager) -> SharedMainTab { pub fn new(main_window: MainWindowRef, tim_manager: MutexTIMManager) -> SharedMainTab {
let vram_file_list:Vec<slint::StandardListViewItem> = main_window.borrow().get_main_tab_vram_file_list().iter().collect(); let vram_file_list:Vec<slint::StandardListViewItem> = main_window.borrow().get_main_tab_vram_file_list().iter().collect();
let vram_file_list = Rc::new(slint::VecModel::from(vram_file_list)); let vram_file_list = Rc::new(slint::VecModel::from(vram_file_list));
let vram_image_list = Rc::new(slint::VecModel::from(Vec::<VRAMImage>::new())); let info = Rc::new(slint::VecModel::from(Vec::<VRAMData>::new()));
main_window.borrow().set_main_tab_vram_file_list(vram_file_list.clone().into()); main_window.borrow().set_main_tab_vram_file_list(vram_file_list.clone().into());
main_window.borrow().set_main_tab_vram_images(vram_image_list.clone().into()); main_window.borrow().set_main_tab_vram_data(info.clone().into());
let object = SharedMainTab::new(MainTab{vram: Arc::new(Mutex::new(VRAM{count: 0, file_list: vram_file_list, image_list: vram_image_list}))}.into()); let object = SharedMainTab::new(MainTab{vram: Arc::new(Mutex::new(VRAM{count: 0, file_list: vram_file_list, info}))}.into());
let (cloned_object, cloned_main_window, mut function) = (object.clone(), main_window.clone(), callbacks::on_move_vram_image()); let (cloned_object, cloned_main_window, mut function) = (object.clone(), main_window.clone(), callbacks::on_move_vram_image());
main_window.borrow().on_move_vram_image(move |idx, dx, dy| { main_window.borrow().on_move_vram_image(move |idx, dx, dy| {
@@ -59,30 +72,45 @@ impl MainTab {
object object
} }
pub fn add_new_vram_file(&mut self, file_name: &String, full_image: slint::Image, image: slint::Image, encoding: Encoding, image_palette: Option<slint::Image>) -> usize { pub fn clear(&mut self) {
let mut vram_data = self.vram.lock().expect("VRAM already locked");
let count = vram_data.count;
for _ in 0..count {
vram_data.pop();
}
}
pub fn add_new_vram_file(&mut self, file_name: &String, full_image: slint::Image, texture: NewVRAMImageInfo, image_palette: Option<NewVRAMImageInfo>) -> usize {
let mut vram_data = self.vram.lock().expect("VRAM already locked"); let mut vram_data = self.vram.lock().expect("VRAM already locked");
let mut add_new_image = |file_name: &String, full_image: slint::Image, image: slint::Image, encoding: Encoding, palette_count: i32, is_palette: bool| { let mut add_new_image = |file_name: &String, full_image: slint::Image, vram_image: NewVRAMImageInfo, palette_count: i32, is_palette: bool| {
let encoding_str = if is_palette {"<Palette>"} else {encoding.to_str()}; let encoding_str = if is_palette {"<Palette>"} else {vram_image.settings.encoding.to_str()};
let vram_image = VRAMImage{ let vram_image = VRAMData {
full_img: full_image, images: VRAMImgData {
img: image, full_image,
x: 0, image: vram_image.image,
y: 0, },
encoding_str: SharedString::from(encoding_str), info: VRAMInfo {
palette_count, x: vram_image.x as i32,
is_palette, y: vram_image.y as i32,
encoding_str: SharedString::from(encoding_str),
use_compression: vram_image.settings.compress,
trans_setting: vram_image.settings.transparency.as_idx(),
palette_count,
is_palette,
}
}; };
vram_data.push(slint::StandardListViewItem::from(file_name.as_str()), vram_image); vram_data.push(slint::StandardListViewItem::from(file_name.as_str()), vram_image);
}; };
let mut images_added = 1; let mut images_added = 1;
add_new_image(file_name, full_image, image, encoding, if image_palette.is_some() {1} else {0}, false); add_new_image(file_name, full_image, texture, if image_palette.is_some() {1} else {0}, false);
if let Some(image_palette) = image_palette { if let Some(image_palette) = image_palette {
let file_name = " => ".to_owned() + file_name.as_str() + " (Palette)"; let file_name = " => ".to_owned() + file_name.as_str() + " (Palette)";
images_added += 1; images_added += 1;
add_new_image(&file_name, image_palette.clone(), image_palette, encoding, 0, true); add_new_image(&file_name, image_palette.image.clone(), image_palette, 0, true);
} }
images_added images_added
@@ -91,13 +119,13 @@ impl MainTab {
pub fn remove_vram_file(&mut self, idx: usize) -> Result<RangeInclusive<usize>, &'static str> { pub fn remove_vram_file(&mut self, idx: usize) -> Result<RangeInclusive<usize>, &'static str> {
let mut vram_data = self.vram.lock().expect("VRAM already locked"); let mut vram_data = self.vram.lock().expect("VRAM already locked");
let extras = { let extras = {
if let Some(element) = vram_data.image_list.iter().skip(idx).next() { if let Some(element) = vram_data.info.iter().skip(idx).next() {
if element.is_palette { if element.info.is_palette {
return Err("Can not remove palette. Delete image instead"); return Err("Can not remove palette. Delete image instead");
} }
else { else {
element.palette_count as usize element.info.palette_count as usize
} }
} }
@@ -126,28 +154,36 @@ impl MainTab {
pub fn move_vram_image(&mut self, idx: usize, dx: i32, dy: i32) { pub fn move_vram_image(&mut self, idx: usize, dx: i32, dy: i32) {
let vram_data = self.vram.lock().expect("VRAM already locked"); let vram_data = self.vram.lock().expect("VRAM already locked");
if let Some(mut vram_info) = vram_data.image_list.row_data(idx) { if let Some(mut vram_info) = vram_data.info.row_data(idx) {
vram_info.x += dx; vram_info.info.x += dx;
vram_info.y += dy; vram_info.info.y += dy;
if vram_info.x < 0 { if vram_info.info.x < 0 {
vram_info.x = 0; vram_info.info.x = 0;
} }
if vram_info.y < 0 { if vram_info.info.y < 0 {
vram_info.y = 0; vram_info.info.y = 0;
} }
let (vram_img_width, vram_img_height) = (vram_info.img.size().width as i32, vram_info.img.size().height as i32); let (vram_img_width, vram_img_height) = (vram_info.images.image.size().width as i32, vram_info.images.image.size().height as i32);
if (vram_info.x + vram_img_width) > VRAM_WIDTH as i32 { if (vram_info.info.x + vram_img_width) > VRAM_WIDTH as i32 {
vram_info.x = VRAM_WIDTH as i32 - vram_img_width; vram_info.info.x = VRAM_WIDTH as i32 - vram_img_width;
} }
if (vram_info.y + vram_img_height) > VRAM_HEIGHT as i32 { if (vram_info.info.y + vram_img_height) > VRAM_HEIGHT as i32 {
vram_info.y = VRAM_HEIGHT as i32 - vram_img_height; vram_info.info.y = VRAM_HEIGHT as i32 - vram_img_height;
} }
vram_data.image_list.set_row_data(idx, vram_info); vram_data.info.set_row_data(idx, vram_info);
} }
} }
pub fn clone_vram_info(&self) -> Vec<(String, VRAMInfo)> {
let vram_data = self.vram.lock().expect("VRAM already locked");
vram_data.info.iter().zip(vram_data.file_list.iter()).map(|(vram_data, file_name)| {
(file_name.text.to_string(), vram_data.info.clone())
}).collect()
}
} }

View File

@@ -1,3 +1,4 @@
pub mod project;
pub mod tim; pub mod tim;
pub mod tim_mgr; pub mod tim_mgr;

View File

@@ -0,0 +1,164 @@
use super::tim::types::Encoding;
use serde::{Deserialize, Serialize};
use std::path::PathBuf;
#[derive(Serialize, Deserialize)]
pub struct FileSettings {
pub compress: bool,
pub transparency: Transparency,
pub encoding: Encoding,
}
impl FileSettings {
pub fn new(compress: bool, transparency: Transparency, encoding: Encoding) -> FileSettings {
FileSettings{compress, transparency, encoding}
}
pub fn from_encoding(encoding: Encoding) -> FileSettings {
let mut new_type = FileSettings::default();
new_type.encoding = encoding;
new_type
}
}
impl std::default::Default for FileSettings {
fn default() -> Self {
Self{compress: Default::default(), transparency: Transparency::None, encoding: Encoding::FullColor}
}
}
#[derive(Serialize, Deserialize)]
pub struct Job {
pub name: String,
pub file_path: PathBuf,
pub image_pos: ImagePosition,
pub palette_rect: Option<PaletteRect>,
pub settings: FileSettings,
}
impl Job {
pub fn new(name: String, file_path: PathBuf, image_pos: (u16, u16), settings: FileSettings) -> Job {
Job{name, file_path, image_pos: ImagePosition{x: image_pos.0, y: image_pos.1}, palette_rect: None, settings}
}
pub fn create_file_path<T:?Sized + std::convert::AsRef<std::ffi::OsStr>>(file_path: PathBuf, location_path: &T) -> PathBuf {
if file_path.is_file() {
file_path
}
else {
let mut new_file_path = PathBuf::from(location_path);
new_file_path.pop();
new_file_path.push(file_path);
new_file_path
}
}
}
#[derive(Serialize, Deserialize)]
pub struct Project {
pub jobs: Vec<Job>
}
impl Project {
pub fn new(jobs: Vec<Job>) -> Project {
Project{jobs}
}
}
#[derive(Serialize, Deserialize)]
pub struct ImagePosition {
pub x: u16,
pub y: u16,
}
impl ImagePosition {
pub fn new(x: u16, y: u16) -> ImagePosition {
ImagePosition{x, y}
}
}
impl std::default::Default for ImagePosition {
fn default() -> Self {
ImagePosition::new(0, 0)
}
}
#[derive(Clone, Copy, Serialize, Deserialize)]
pub struct ImageSize {
pub width: u16,
pub height: u16,
}
impl ImageSize {
pub fn new(width: u16, height: u16) -> ImageSize {
ImageSize{width, height}
}
}
impl From<ImageSize> for (u16, u16) {
fn from(value: ImageSize) -> Self {
(value.width, value.height)
}
}
impl std::default::Default for ImageSize {
fn default() -> Self {
ImageSize::new(0, 0)
}
}
#[derive(Serialize, Deserialize)]
pub struct PaletteRect {
pub pos: ImagePosition,
pub size: ImageSize,
}
impl PaletteRect {
pub fn new(x: u16, y: u16, width: u16, height: u16) -> PaletteRect {
PaletteRect{pos: ImagePosition{x, y}, size: ImageSize{width, height}}
}
}
impl From<PaletteRect> for (u16, u16, u16, u16) {
fn from(value: PaletteRect) -> Self {
(value.pos.x, value.pos.y, value.size.width, value.size.height)
}
}
impl std::default::Default for PaletteRect {
fn default() -> Self {
PaletteRect{pos: ImagePosition::default(), size: ImageSize::default()}
}
}
#[derive(Serialize, Deserialize)]
pub enum Transparency {
None,
FirstColor,
PSXSemi,
Both,
}
impl Transparency {
pub fn from(selection: i32) -> Transparency {
match selection {
0 => Transparency::None,
1 => Transparency::FirstColor,
2 => Transparency::PSXSemi,
3 => Transparency::Both,
_ => Transparency::None,
}
}
pub fn as_idx(&self) -> i32 {
match self {
Transparency::None => 0,
Transparency::FirstColor => 1,
Transparency::PSXSemi => 2,
Transparency::Both => 3,
}
}
}

View File

@@ -1,12 +1,14 @@
pub mod types; pub mod types;
use pathdiff::diff_paths;
use std::{fs::File, path::PathBuf}; use std::{fs::File, path::PathBuf};
use slint::{Rgba8Pixel, SharedPixelBuffer}; use slint::{Rgba8Pixel, SharedPixelBuffer};
use tool_helper::Error; use tool_helper::Error;
use types::Encoding; use types::Encoding;
#[derive(Clone)]
pub struct TIMInfo { pub struct TIMInfo {
_path: PathBuf, path: PathBuf,
image_data: SharedPixelBuffer<Rgba8Pixel>, image_data: SharedPixelBuffer<Rgba8Pixel>,
palette: Option<PaletteInfo>, palette: Option<PaletteInfo>,
} }
@@ -18,8 +20,8 @@ impl TIMInfo {
*iter.next()?, *iter.next()?, *iter.next()?, *iter.next()?, *iter.next()?, *iter.next()?,
if load_alpha {*iter.next()?} else {0xFF})) if load_alpha {*iter.next()?} else {0xFF}))
} }
let mut reader = png::Decoder::new(File::open(path)?).read_info().or_else(|error| {Err(Error::from_error(error))})?; let mut reader = png::Decoder::new(File::open(path).map_err(|error| Error::from_text(format!("Failed loading \"{}\" with {}", path.to_string_lossy().as_ref(), error)))?).read_info().or_else(|error| {Err(Error::from_error(error))})?;
let info = reader.info().clone(); let info = reader.info().clone();
let mut buffer = vec![0; reader.output_buffer_size()]; let mut buffer = vec![0; reader.output_buffer_size()];
@@ -52,7 +54,7 @@ impl TIMInfo {
_ => {return Err(Error::from_str("Only 4 and 8bit color depth are supported for indexed color images"));} _ => {return Err(Error::from_str("Only 4 and 8bit color depth are supported for indexed color images"));}
} }
} }
Ok(TIMInfo{_path: path.clone(), image_data, palette: Some(PaletteInfo::new(palette_colors))}) Ok(TIMInfo{path: path.clone(), image_data, palette: Some(PaletteInfo::new(palette_colors))})
} }
else { else {
@@ -70,11 +72,11 @@ impl TIMInfo {
_ => {return Err(Error::from_str("Only 8bit color depth are supported for direct color images"));} _ => {return Err(Error::from_str("Only 8bit color depth are supported for direct color images"));}
} }
} }
Ok(TIMInfo{_path: path.clone(), image_data, palette: None}) Ok(TIMInfo{path: path.clone(), image_data, palette: None})
} }
} }
pub fn change_palette_size(&mut self, width: u32, height: u32) -> Result<Option<slint::Image>, Error> { pub fn change_palette_size(&mut self, width: u16, height: u16) -> Result<Option<slint::Image>, Error> {
if let Some(palette) = &mut self.palette { if let Some(palette) = &mut self.palette {
if width == 0 || height == 0 { if width == 0 || height == 0 {
return Err(Error::from_text(format!("{}px x {}px is not a valid size for palette", width, height))); return Err(Error::from_text(format!("{}px x {}px is not a valid size for palette", width, height)));
@@ -117,12 +119,36 @@ impl TIMInfo {
None None
}) })
} }
pub fn get_palette_size(&self) -> Option<(u16, u16)> {
if let Some(palette_info) = &self.palette {
Some((palette_info.width, palette_info.height))
}
else {
None
}
}
pub fn get_path(&self) -> std::path::PathBuf {
self.path.clone()
}
pub fn get_path_rel_to(&self, mut reference_path: std::path::PathBuf) -> Result<std::path::PathBuf, Error> {
let file_path = self.path.clone();
reference_path.pop();
diff_paths(&file_path, &reference_path).ok_or_else(|| {
Error::from_text(format!("Can not create relative path from {} to {}", file_path.to_string_lossy().as_ref(), reference_path.to_string_lossy().as_ref()))
})
}
} }
#[derive(Clone)]
struct PaletteInfo { struct PaletteInfo {
data: Vec<Rgba8Pixel>, data: Vec<Rgba8Pixel>,
width: u32, width: u16,
height: u32, height: u16,
} }
impl PaletteInfo { impl PaletteInfo {
@@ -132,7 +158,7 @@ impl PaletteInfo {
} }
pub fn get_image(&self) -> slint::Image { pub fn get_image(&self) -> slint::Image {
let mut image_data = SharedPixelBuffer::new(self.width, self.height); let mut image_data = SharedPixelBuffer::new(self.width as u32, self.height as u32);
let dst_pixels = image_data.make_mut_slice(); let dst_pixels = image_data.make_mut_slice();
for (idx, byte) in dst_pixels.iter_mut().enumerate() { for (idx, byte) in dst_pixels.iter_mut().enumerate() {

View File

@@ -1,4 +1,6 @@
#[derive(Clone, Copy)] use serde::{Deserialize, Serialize};
#[derive(Clone, Copy, Deserialize, Serialize)]
pub enum Encoding { pub enum Encoding {
FourBit, FourBit,
EightBit, EightBit,
@@ -17,4 +19,13 @@ impl Encoding {
Encoding::FullColor => Self::FULL_COLOR_NAME, Encoding::FullColor => Self::FULL_COLOR_NAME,
} }
} }
pub fn from_str(str: &str) -> Encoding {
match str {
Self::FOUR_BIT_NAME => Encoding::FourBit,
Self::EIGHT_BIT_NAME => Encoding::EightBit,
Self::FULL_COLOR_NAME => Encoding::FullColor,
_ => Encoding::FullColor,
}
}
} }

View File

@@ -13,6 +13,10 @@ impl TIMManager {
TIMManager{added_tims: Default::default(), unadded_tim: None} TIMManager{added_tims: Default::default(), unadded_tim: None}
} }
pub fn clear(&mut self) {
self.added_tims.clear();
}
pub fn remove_added_tim(&mut self, range: RangeInclusive<usize>) { pub fn remove_added_tim(&mut self, range: RangeInclusive<usize>) {
let idx = *range.start(); let idx = *range.start();
for _ in range { for _ in range {
@@ -60,7 +64,7 @@ impl TIMManager {
} }
} }
pub fn change_unadded_tim_palette_size(&mut self, width: u32, height: u32) -> Result<Option<Image>, Error> { pub fn change_unadded_tim_palette_size(&mut self, width: u16, height: u16) -> Result<Option<Image>, Error> {
if let Some(unadded_tim) = &mut self.unadded_tim { if let Some(unadded_tim) = &mut self.unadded_tim {
unadded_tim.change_palette_size(width, height) unadded_tim.change_palette_size(width, height)
} }
@@ -69,4 +73,8 @@ impl TIMManager {
Ok(None) Ok(None)
} }
} }
pub fn clone_added_tims(&self) -> Vec<Option<TIMInfo>> {
self.added_tims.clone()
}
} }

View File

@@ -7,13 +7,15 @@ export component MainWindow inherits Window {
// Main Tab values // Main Tab values
in-out property main_tab_vram_bg <=> main_tab.vram_bg; in-out property main_tab_vram_bg <=> main_tab.vram_bg;
in-out property main_tab_vram_file_list <=> main_tab.vram_files; in-out property main_tab_vram_file_list <=> main_tab.vram_files;
in-out property main_tab_vram_images <=> main_tab.vram_images; in-out property main_tab_vram_data <=> main_tab.vram_data;
callback main_tab_remove_file_clicked <=> main_tab.remove_file_clicked; callback main_tab_remove_file_clicked <=> main_tab.remove_file_clicked;
callback move_vram_image <=> main_tab.move_vram_image; callback move_vram_image <=> main_tab.move_vram_image;
// Project widget values // Project widget values
in-out property project_widget-open_project_path <=> file_tab.project_widget-open_project_path; in-out property project_widget-open_project_path <=> file_tab.project_widget-open_project_path;
in-out property project_widget-save_project_path <=> file_tab.project_widget-save_project_path; in-out property project_widget-save_project_path <=> file_tab.project_widget-save_project_path;
in-out property project_widget-append_project_elements <=> file_tab.project_widget-append_project_elements;
in-out property project_widget-use_rel_paths <=> file_tab.project_widget-use_rel_paths;
callback project_widget-load_project_clicked <=> file_tab.project_widget-load_project_clicked; callback project_widget-load_project_clicked <=> file_tab.project_widget-load_project_clicked;
callback project_widget-save_project_clicked <=> file_tab.project_widget-save_project_clicked; callback project_widget-save_project_clicked <=> file_tab.project_widget-save_project_clicked;
callback project_widget-browse_open_project_clicked <=> file_tab.project_widget-browse_open_project_clicked; callback project_widget-browse_open_project_clicked <=> file_tab.project_widget-browse_open_project_clicked;
@@ -79,5 +81,10 @@ export component MainWindow inherits Window {
public function change_to_main() { public function change_to_main() {
tab_widget.current-index = 1; tab_widget.current-index = 1;
main_tab.set_active();
}
public function clear_file_tab-current_selected_file() {
main_tab.clear_current_selection();
} }
} }

View File

@@ -8,6 +8,8 @@ export enum State {
component ProjectWidget inherits Rectangle { component ProjectWidget inherits Rectangle {
in-out property <string> open_project_path; in-out property <string> open_project_path;
in-out property <string> save_project_path; in-out property <string> save_project_path;
in-out property <bool> append_project_elements;
in-out property <bool> use_rel_paths;
callback load_project_clicked(); callback load_project_clicked();
callback save_project_clicked(); callback save_project_clicked();
@@ -24,7 +26,7 @@ component ProjectWidget inherits Rectangle {
VerticalLayout { VerticalLayout {
alignment: start; alignment: start;
Text { Text {
text: "Select a project to open. Any existing changes will be dropped"; text: "Select a project to open.";
} }
HorizontalLayout { HorizontalLayout {
alignment: start; alignment: start;
@@ -39,6 +41,13 @@ component ProjectWidget inherits Rectangle {
} }
} }
} }
HorizontalLayout {
alignment: start;
CheckBox {
text: "Append elements from project to existing elements";
checked <=> root.append_project_elements;
}
}
HorizontalLayout { HorizontalLayout {
alignment: start; alignment: start;
Button { Button {
@@ -72,7 +81,8 @@ component ProjectWidget inherits Rectangle {
} }
} }
CheckBox { CheckBox {
text: "Use relative path for files"; text: "Use relative path for files";
checked <=> root.use_rel_paths;
} }
HorizontalLayout { HorizontalLayout {
alignment: start; alignment: start;
@@ -251,7 +261,7 @@ component ConvertImageWidget inherits Rectangle {
} }
} }
LineEdit { LineEdit {
text: root.image_name; text <=> root.image_name;
} }
} }
HorizontalLayout { HorizontalLayout {
@@ -282,6 +292,8 @@ export component FileTab inherits Rectangle {
// For project widget // For project widget
in-out property <string> project_widget-open_project_path; in-out property <string> project_widget-open_project_path;
in-out property <string> project_widget-save_project_path; in-out property <string> project_widget-save_project_path;
in-out property <bool> project_widget-append_project_elements;
in-out property <bool> project_widget-use_rel_paths;
callback project_widget-load_project_clicked(); callback project_widget-load_project_clicked();
callback project_widget-save_project_clicked(); callback project_widget-save_project_clicked();
callback project_widget-browse_open_project_clicked(); callback project_widget-browse_open_project_clicked();
@@ -332,9 +344,11 @@ export component FileTab inherits Rectangle {
padding: 4px; padding: 4px;
alignment: start; alignment: start;
if root.state == State.Project : ProjectWidget { if root.state == State.Project : ProjectWidget {
open_project_path <=> root.project_widget-open_project_path; open_project_path <=> root.project_widget-open_project_path;
save_project_path <=> root.project_widget-save_project_path; save_project_path <=> root.project_widget-save_project_path;
append_project_elements <=> root.project_widget-append_project_elements;
use_rel_paths <=> root.project_widget-use_rel_paths;
load_project_clicked() => { load_project_clicked() => {
root.project_widget-load_project_clicked(); root.project_widget-load_project_clicked();
} }

View File

@@ -1,28 +1,39 @@
import { VRAMArea } from "../vram-components.slint"; import { VRAMArea } from "../vram-components.slint";
import { Button, ComboBox, GroupBox, StandardListView, LineEdit, ScrollView, Slider } from "std-widgets.slint"; import { Button, CheckBox, ComboBox, GroupBox, StandardListView, LineEdit, ScrollView, Slider } from "std-widgets.slint";
struct VRAMImage { struct VRAMImgData {
full_img: image, full_image: image,
img: image, image: image,
x: int, }
y: int,
encoding_str: string, struct VRAMInfo {
palette_count: int, x: int,
is_palette: bool, y: int,
encoding_str: string,
use_compression: bool,
trans_setting: int,
palette_count: int,
is_palette: bool, // < Can we combine the palette into this, instead of having it separate?
}
struct VRAMData {
images: VRAMImgData,
info: VRAMInfo,
} }
export component MainTab inherits Rectangle { export component MainTab inherits Rectangle {
property <float> scale: 1.0; property <float> scale: 1.0;
in-out property <image> vram_bg; in-out property <image> vram_bg;
in-out property <[StandardListViewItem]> vram_files: []; in-out property <[StandardListViewItem]> vram_files: [];
in-out property <[VRAMImage]> vram_images: []; in-out property <[VRAMData]> vram_data: [];
callback add_file_clicked(); callback add_file_clicked();
callback remove_file_clicked(int); callback remove_file_clicked(int);
callback move_vram_image(int, int, int); callback move_vram_image(int, int, int);
width: group.width + group.x*2; width: group.width + group.x*2;
height: group.height + group.y*2 + 32px; height: group.height + group.y*2 + 32px;
forward-focus: key_focus;
group := GroupBox { group := GroupBox {
title: "VRAM Layout"; title: "VRAM Layout";
@@ -54,12 +65,12 @@ export component MainTab inherits Rectangle {
scale: scale; scale: scale;
} }
for vram_image[i] in root.vram_images: VRAMArea { for vram_data[i] in root.vram_data: VRAMArea {
x: root.get_border_width()*1px; x: root.get_border_width()*1px;
y: root.get_border_width()*1px; y: root.get_border_width()*1px;
img: vram_image.img; img: vram_data.images.image;
img_x: vram_image.x; img_x: vram_data.info.x;
img_y: vram_image.y; img_y: vram_data.info.y;
scale: scale; scale: scale;
TouchArea { TouchArea {
@@ -82,10 +93,20 @@ export component MainTab inherits Rectangle {
if event.kind == PointerEventKind.down { if event.kind == PointerEventKind.down {
cur_sel_x.text = parent.img_x; cur_sel_x.text = parent.img_x;
cur_sel_y.text = parent.img_y; cur_sel_y.text = parent.img_y;
cur_sel_img.source = vram-image.full_img; cur_sel_width.text = "Width: " + vram_data.images.image.width;
encoding_text.encoding_str = vram-image.encoding_str; cur_sel_height.text = "Height: " + vram_data.images.image.height;
cur_sel_img.source = vram_data.images.full_image;
encoding_text.encoding_str = vram_data.info.encoding_str;
cur_sel_img.visible = true; cur_sel_img.visible = true;
if !vram-data.info.is_palette {
file_settings_box.set_active(i);
}
else {
file_settings_box.set_inactive();
}
vram_files_list.current-item = i; vram_files_list.current-item = i;
} }
} }
@@ -111,10 +132,20 @@ export component MainTab inherits Rectangle {
} }
function update_viewport() { function update_viewport() {
// If this value is positive, then the image moved so much to the right, that we do not use the full display area anymore
if self.viewport-x > 0 {
self.viewport-x = 0;
}
if abs(self.viewport-x) + self.width > self.viewport-width { if abs(self.viewport-x) + self.width > self.viewport-width {
self.viewport-x += (self.width + abs(self.viewport-x)) - self.viewport-width; self.viewport-x += (self.width + abs(self.viewport-x)) - self.viewport-width;
} }
if self.viewport-y > 0 {
self.viewport-y = 0;
}
// If this value is positive, then the image moved so much down, that we do not use the full display area anymore
if abs(self.viewport-y) + self.height > self.viewport-height { if abs(self.viewport-y) + self.height > self.viewport-height {
self.viewport-y += (self.height + abs(self.viewport-y)) - self.viewport-height; self.viewport-y += (self.height + abs(self.viewport-y)) - self.viewport-height;
} }
@@ -131,7 +162,7 @@ export component MainTab inherits Rectangle {
} }
slider := Slider { slider := Slider {
minimum: 100.0; minimum: 100.0;
maximum: 400.0; maximum: 800.0;
step: 1.0; step: 1.0;
value: 100.0; value: 100.0;
@@ -154,11 +185,36 @@ export component MainTab inherits Rectangle {
model: root.vram_files; model: root.vram_files;
current-item-changed(current-item) => { current-item-changed(current-item) => {
cur_sel_x.text = root.vram_images[current-item].x; cur_sel_x.text = root.vram_data[current-item].info.x;
cur_sel_y.text = root.vram_images[current-item].y; cur_sel_y.text = root.vram_data[current-item].info.y;
cur_sel_img.source = root.vram_images[current-item].full_img; cur_sel_width.text = "Width: " + root.vram_data[current-item].images.image.width;
encoding_text.encoding_str = root.vram_images[current-item].encoding_str; cur_sel_height.text = "Height: " + root.vram_data[current-item].images.image.height;
cur_sel_img.source = root.vram_data[current-item].images.full_image;
encoding_text.encoding_str = root.vram_data[current-item].info.encoding_str;
cur_sel_img.visible = true; cur_sel_img.visible = true;
if !root.vram_data[current-item].info.is_palette {
file_settings_box.set_active(current-item);
}
else {
file_settings_box.set_inactive();
}
}
item-pointer-event(item, event, position) => {
if event.button == PointerEventButton.right && event.kind == PointerEventKind.down {
main_view.viewport-x = -(root.vram_data[item].info.x + (root.vram_data[item].info.x/64))*root.scale*1px + (main_view.width/4);
main_view.viewport-y = -(root.vram_data[item].info.y + (root.vram_data[item].info.y/256))*root.scale*1px + (main_view.height/4);
main_view.update_viewport();
}
}
}
HorizontalLayout {
padding: 4px;
alignment: center;
Text {
text: "Right click to focus element on screen";
} }
} }
HorizontalLayout { HorizontalLayout {
@@ -171,10 +227,7 @@ export component MainTab inherits Rectangle {
text: "Remove file"; text: "Remove file";
clicked => { clicked => {
root.remove_file_clicked(vram_files_list.current_item); root.remove_file_clicked(vram_files_list.current_item);
vram_files_list.current-item = -1; root.clear_current_selection();
cur_sel_x.text = 0;
cur_sel_y.text = 0;
cur_sel_img.visible = false;
} }
} }
} }
@@ -206,15 +259,21 @@ export component MainTab inherits Rectangle {
cur_sel_x := LineEdit { cur_sel_x := LineEdit {
input-type: number; input-type: number;
text: 0; text: 0;
width: 64pt; width: 48pt;
accepted(text) => { accepted(text) => {
if(vram_files_list.current-item != -1) { if(vram_files_list.current-item != -1) {
root.move_vram_image(vram_files_list.current-item, text.to-float() - vram_images[vram_files_list.current-item].x, 0); root.move_vram_image(vram_files_list.current-item, text.to-float() - vram_data[vram_files_list.current-item].info.x, 0);
self.text = vram_images[vram_files_list.current-item].x; self.text = vram_data[vram_files_list.current-item].info.x;
} }
} }
} }
VerticalLayout {
alignment: center;
cur_sel_width := Text {
text: "Width: 0";
}
}
} }
HorizontalLayout { HorizontalLayout {
alignment: start; alignment: start;
@@ -227,15 +286,21 @@ export component MainTab inherits Rectangle {
cur_sel_y := LineEdit { cur_sel_y := LineEdit {
input-type: number; input-type: number;
text: 0; text: 0;
width: 64pt; width: 48pt;
accepted(text) => { accepted(text) => {
if(vram_files_list.current-item != -1) { if(vram_files_list.current-item != -1) {
root.move_vram_image(vram_files_list.current-item, 0, text.to-float() - vram_images[vram_files_list.current-item].y); root.move_vram_image(vram_files_list.current-item, 0, text.to-float() - vram_data[vram_files_list.current-item].info.y);
self.text = vram_images[vram_files_list.current-item].y; self.text = vram_data[vram_files_list.current-item].info.y;
} }
} }
} }
VerticalLayout {
alignment: center;
cur_sel_height := Text {
text: "Height: 0";
}
}
} }
encoding_text := Text { encoding_text := Text {
in-out property <string> encoding_str; in-out property <string> encoding_str;
@@ -243,31 +308,79 @@ export component MainTab inherits Rectangle {
} }
} }
} }
file_settings_box := GroupBox {
title: "File settings";
enabled: false;
VerticalLayout {
alignment: start;
lz4_check_box := CheckBox {
text: "Compress (lz4)";
enabled: file_settings_box.enabled;
toggled => {
if(vram_files_list.current-item != -1) {
root.vram_data[vram_files_list.current-item].info.use_compression = self.checked;
}
}
}
GroupBox {
title: "Transparency:";
enabled: file_settings_box.enabled;
VerticalLayout {
alignment: start;
trans_combo_box := ComboBox {
model: ["No transparency", "First color transparent", "PSX semi-transparency", "Both"];
enabled: file_settings_box.enabled;
selected(current-value) => {
if(vram_files_list.current-item != -1) {
root.vram_data[vram_files_list.current-item].info.trans_setting = self.current-index;
}
}
}
}
}
}
public function set_active(current-item: int) {
lz4_check_box.checked = root.vram_data[current-item].info.use_compression;
trans_combo_box.current-index = root.vram_data[current-item].info.trans_setting;
self.enabled = true;
}
public function set_inactive() {
lz4_check_box.checked = false;
trans_combo_box.current-index = 0;
self.enabled = false;
}
}
} }
} }
} }
FocusScope { key_focus := FocusScope {
key-pressed(event) => { key-pressed(event) => {
if(vram_files_list.current-item != -1) { if(vram_files_list.current-item != -1) {
if(event.text == Key.LeftArrow) { if(event.text == Key.LeftArrow) {
root.move_vram_image(vram_files_list.current-item, -1, 0); root.move_vram_image(vram_files_list.current-item, -1, 0);
cur_sel_x.text = vram_images[vram_files_list.current-item].x; cur_sel_x.text = vram_data[vram_files_list.current-item].info.x;
} }
if(event.text == Key.RightArrow) { if(event.text == Key.RightArrow) {
root.move_vram_image(vram_files_list.current-item, 1, 0); root.move_vram_image(vram_files_list.current-item, 1, 0);
cur_sel_x.text = vram_images[vram_files_list.current-item].x; cur_sel_x.text = vram_data[vram_files_list.current-item].info.x;
} }
if(event.text == Key.UpArrow) { if(event.text == Key.UpArrow) {
root.move_vram_image(vram_files_list.current-item, 0, -1); root.move_vram_image(vram_files_list.current-item, 0, -1);
cur_sel_y.text = vram_images[vram_files_list.current-item].y; cur_sel_y.text = vram_data[vram_files_list.current-item].info.y;
} }
if(event.text == Key.DownArrow) { if(event.text == Key.DownArrow) {
root.move_vram_image(vram_files_list.current-item, 0, 1); root.move_vram_image(vram_files_list.current-item, 0, 1);
cur_sel_y.text = vram_images[vram_files_list.current-item].y; cur_sel_y.text = vram_data[vram_files_list.current-item].info.y;
} }
} }
accept accept
@@ -277,4 +390,15 @@ export component MainTab inherits Rectangle {
function get_border_width() -> int { function get_border_width() -> int {
return 4; return 4;
} }
public function clear_current_selection() {
vram_files_list.current-item = -1;
cur_sel_x.text = 0;
cur_sel_y.text = 0;
cur_sel_img.visible = false;
}
public function set_active() {
key_focus.focus();
}
} }

View File

@@ -19,7 +19,7 @@
{ {
"label": "make", "label": "make",
"type": "shell", "type": "shell",
"command": "../../scripts/podman_jaby_engine.sh ${workspaceFolder}/..:src/FontWriter make ${input:target} BUILD_PROFILE=${input:build cfg}", "command": "../../scripts/podman_jaby_engine.sh ${workspaceFolder}/..:src/FontWriter bear --output ${workspaceFolder}/../compile_commands.json -- make ${input:target} BUILD_PROFILE=${input:build cfg}",
"group": "build" "group": "build"
} }
], ],