Compare commits
48 Commits
5ccf593963
...
topic/bg/f
Author | SHA1 | Date | |
---|---|---|---|
157e4d5937 | |||
f25548085f | |||
85d787151a | |||
d69b144ebe | |||
a686df5bf6 | |||
3500a288bc | |||
e51908ae09 | |||
4ea7575057 | |||
e3ed4a3b43 | |||
3f507fd19e | |||
f8ec08008a | |||
4942012da1 | |||
9501954587 | |||
751533dcf6 | |||
5a1997873d | |||
5cd29460fb | |||
7a2052575d | |||
a475a0c82d | |||
32da34cad6 | |||
af633a4fdf | |||
b0b8c43700 | |||
ed4671698a | |||
b487ca2591 | |||
a33aa6bb4e | |||
85b5aa0070 | |||
b3a666b5ea | |||
a8ca3bf859 | |||
ec6c20185e | |||
a6d8ecab16 | |||
a89699334e | |||
5f93549a05 | |||
2e6aa8dbe9 | |||
a9801e9fe2 | |||
47b5de2d6a | |||
bab01bbd86 | |||
a260c1ffb7 | |||
5cc88e0b87 | |||
5f4ade47bd | |||
2345b3da57 | |||
e0a266317e | |||
aae57e47e4 | |||
d1d590d32a | |||
18e6800e0f | |||
d42fe2776c | |||
7a197d9b71 | |||
b394330405 | |||
602fb3a5c2 | |||
6a1b87cdb1 |
1
examples/PoolBox/.gitignore
vendored
1
examples/PoolBox/.gitignore
vendored
@@ -5,3 +5,4 @@
|
|||||||
*.o
|
*.o
|
||||||
*.lba
|
*.lba
|
||||||
**/bin
|
**/bin
|
||||||
|
**/auto_gen
|
@@ -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);
|
||||||
|
@@ -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>
|
||||||
|
@@ -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),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@@ -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;
|
||||||
|
@@ -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);
|
|
||||||
}
|
|
@@ -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());
|
||||||
|
|
||||||
|
@@ -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()
|
||||||
);
|
);
|
||||||
}
|
}
|
@@ -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()
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@@ -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)),
|
||||||
|
@@ -2,6 +2,7 @@ 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)
|
||||||
|
|
||||||
@@ -35,10 +30,10 @@ INPUT += $(OUTPUT_DIR)/JabyTails.img
|
|||||||
JabyTails_FLAGS = $(CLUT_4_COLOR_TRANS_FLAGS)
|
JabyTails_FLAGS = $(CLUT_4_COLOR_TRANS_FLAGS)
|
||||||
|
|
||||||
INPUT += $(OUTPUT_DIR)/IMG_6921.tim
|
INPUT += $(OUTPUT_DIR)/IMG_6921.tim
|
||||||
IMG_6921_TIM_FLAGS = tim full16 --clut-pos {384,255} --tex-pos {384,256}
|
IMG_6921_TIM_FLAGS = tim full16 --clut-pos [384,255] --tex-pos [384,256]
|
||||||
|
|
||||||
INPUT += $(OUTPUT_DIR)/AllTheJaby.tim
|
INPUT += $(OUTPUT_DIR)/AllTheJaby.tim
|
||||||
AllTheJaby_TIM_FLAGS = tim full16 --tex-pos {0,0}
|
AllTheJaby_TIM_FLAGS = tim full16 --tex-pos [0,0]
|
||||||
|
|
||||||
$(OUTPUT_DIR)/%.vag: audio/%.wav
|
$(OUTPUT_DIR)/%.vag: audio/%.wav
|
||||||
@mkdir -p $(OUTPUT_DIR)
|
@mkdir -p $(OUTPUT_DIR)
|
||||||
@@ -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)
|
1
examples/PoolBox/assets/tim_example.tim_project
Normal file
1
examples/PoolBox/assets/tim_example.tim_project
Normal 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"}}]}
|
5748
src/Tools/psxfileconv/Cargo.lock
generated
5748
src/Tools/psxfileconv/Cargo.lock
generated
File diff suppressed because it is too large
Load Diff
@@ -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"}
|
||||||
|
@@ -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 {
|
||||||
@@ -34,7 +34,7 @@ impl std::default::Default for Point {
|
|||||||
|
|
||||||
impl ToString for Point {
|
impl ToString for Point {
|
||||||
fn to_string(&self) -> std::string::String {
|
fn to_string(&self) -> std::string::String {
|
||||||
"{0,0}".to_owned()
|
"[0,0]".to_owned()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -42,7 +42,7 @@ impl FromStr for Point {
|
|||||||
type Err = String;
|
type Err = String;
|
||||||
|
|
||||||
fn from_str(s: &str) -> Result<Self, Self::Err> {
|
fn from_str(s: &str) -> Result<Self, Self::Err> {
|
||||||
let values:Vec<&str> = s.split(&['{', ',', '}']).filter_map(|value| if value.is_empty() {None} else {Some(value)}).collect();
|
let values:Vec<&str> = s.split(&['[', ',', ']']).filter_map(|value| if value.is_empty() {None} else {Some(value)}).collect();
|
||||||
|
|
||||||
if values.len() != 2 {
|
if values.len() != 2 {
|
||||||
return Err(format!("Two values expected for Point but found {}", values.len()));
|
return Err(format!("Two values expected for Point but found {}", values.len()));
|
||||||
|
@@ -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 = {
|
||||||
|
@@ -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()),
|
||||||
|
@@ -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();
|
||||||
|
|
||||||
|
@@ -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)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@@ -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);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
39
src/Tools/psxfileconv/src/project/hpp_out.rs
Normal file
39
src/Tools/psxfileconv/src/project/hpp_out.rs
Normal 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) {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
90
src/Tools/psxfileconv/src/project/mod.rs
Normal file
90
src/Tools/psxfileconv/src/project/mod.rs
Normal 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)
|
||||||
|
}
|
||||||
|
}
|
1675
src/Tools/tim_tool/Cargo.lock
generated
1675
src/Tools/tim_tool/Cargo.lock
generated
File diff suppressed because it is too large
Load Diff
@@ -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"
|
||||||
|
@@ -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", &["*"])
|
||||||
|
}
|
@@ -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());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@@ -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 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 count = vram_data.count;
|
||||||
let encoding_str = if is_palette {"<Palette>"} else {encoding.to_str()};
|
|
||||||
let vram_image = VRAMImage{
|
for _ in 0..count {
|
||||||
full_img: full_image,
|
vram_data.pop();
|
||||||
img: image,
|
}
|
||||||
x: 0,
|
}
|
||||||
y: 0,
|
|
||||||
|
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 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 {vram_image.settings.encoding.to_str()};
|
||||||
|
let vram_image = VRAMData {
|
||||||
|
images: VRAMImgData {
|
||||||
|
full_image,
|
||||||
|
image: vram_image.image,
|
||||||
|
},
|
||||||
|
info: VRAMInfo {
|
||||||
|
x: vram_image.x as i32,
|
||||||
|
y: vram_image.y as i32,
|
||||||
encoding_str: SharedString::from(encoding_str),
|
encoding_str: SharedString::from(encoding_str),
|
||||||
|
use_compression: vram_image.settings.compress,
|
||||||
|
trans_setting: vram_image.settings.transparency.as_idx(),
|
||||||
palette_count,
|
palette_count,
|
||||||
is_palette,
|
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()
|
||||||
|
}
|
||||||
}
|
}
|
@@ -1,3 +1,4 @@
|
|||||||
|
pub mod project;
|
||||||
pub mod tim;
|
pub mod tim;
|
||||||
pub mod tim_mgr;
|
pub mod tim_mgr;
|
||||||
|
|
||||||
|
164
src/Tools/tim_tool/src/logic/project/mod.rs
Normal file
164
src/Tools/tim_tool/src/logic/project/mod.rs
Normal 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,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@@ -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>,
|
||||||
}
|
}
|
||||||
@@ -19,7 +21,7 @@ impl TIMInfo {
|
|||||||
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() {
|
||||||
|
@@ -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,
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
@@ -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()
|
||||||
|
}
|
||||||
}
|
}
|
@@ -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();
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -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 {
|
||||||
@@ -73,6 +82,7 @@ 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();
|
||||||
@@ -334,6 +346,8 @@ export component FileTab inherits Rectangle {
|
|||||||
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();
|
||||||
|
@@ -1,21 +1,31 @@
|
|||||||
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,
|
||||||
|
}
|
||||||
|
|
||||||
|
struct VRAMInfo {
|
||||||
x: int,
|
x: int,
|
||||||
y: int,
|
y: int,
|
||||||
encoding_str: string,
|
encoding_str: string,
|
||||||
|
use_compression: bool,
|
||||||
|
trans_setting: int,
|
||||||
palette_count: int,
|
palette_count: int,
|
||||||
is_palette: bool,
|
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);
|
||||||
@@ -23,6 +33,7 @@ export component MainTab inherits Rectangle {
|
|||||||
|
|
||||||
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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
FocusScope {
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
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();
|
||||||
|
}
|
||||||
}
|
}
|
Reference in New Issue
Block a user