Skip to content

Commit

Permalink
Pixi: deinit: state -> app
Browse files Browse the repository at this point in the history
  • Loading branch information
foxnne committed Jan 4, 2025
1 parent a7e7ed0 commit a99ed94
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 52 deletions.
54 changes: 27 additions & 27 deletions src/Pixi.zig
Original file line number Diff line number Diff line change
Expand Up @@ -477,58 +477,58 @@ pub fn tick(app: *App, app_mod: mach.Mod(App), editor_mod: mach.Mod(Editor)) !vo
}
}

pub fn deinit(editor_mod: mach.Mod(Editor)) !void {
pub fn deinit(app: *App, editor_mod: mach.Mod(Editor)) !void {
//deinit and save settings
state.settings.deinit(state.json_allocator.allocator());
app.settings.deinit(app.json_allocator.allocator());

//free everything allocated by the json_allocator
state.json_allocator.deinit();
app.json_allocator.deinit();

state.allocator.free(editor.theme.name);
app.allocator.free(editor.theme.name);

state.allocator.free(state.hotkeys.hotkeys);
state.allocator.free(state.mouse.buttons);
state.packer.deinit();
state.recents.deinit();
app.allocator.free(app.hotkeys.hotkeys);
app.allocator.free(app.mouse.buttons);
app.packer.deinit();
app.recents.deinit();

state.batcher.deinit();
state.pipeline_default.release();
state.uniform_buffer_default.release();
app.batcher.deinit();
app.pipeline_default.release();
app.uniform_buffer_default.release();

state.pipeline_compute.release();
app.pipeline_compute.release();

if (state.atlas.external) |*atlas| {
if (app.atlas.external) |*atlas| {
for (atlas.sprites) |sprite| {
state.allocator.free(sprite.name);
app.allocator.free(sprite.name);
}

for (atlas.animations) |animation| {
state.allocator.free(animation.name);
app.allocator.free(animation.name);
}

state.allocator.free(atlas.sprites);
state.allocator.free(atlas.animations);
app.allocator.free(atlas.sprites);
app.allocator.free(atlas.animations);
}
if (state.previous_atlas_export) |path| {
state.allocator.free(path);
if (app.previous_atlas_export) |path| {
app.allocator.free(path);
}
if (state.atlas.diffusemap) |*diffusemap| diffusemap.deinit();
if (state.atlas.heightmap) |*heightmap| heightmap.deinit();
if (state.colors.palette) |*palette| palette.deinit();
if (state.colors.keyframe_palette) |*keyframe_palette| keyframe_palette.deinit();
if (app.atlas.diffusemap) |*diffusemap| diffusemap.deinit();
if (app.atlas.heightmap) |*heightmap| heightmap.deinit();
if (app.colors.palette) |*palette| palette.deinit();
if (app.colors.keyframe_palette) |*keyframe_palette| keyframe_palette.deinit();

if (state.clipboard_image) |*image| image.deinit();
if (app.clipboard_image) |*image| image.deinit();

editor_mod.call(.deinit);
state.loaded_assets.deinit(state.allocator);
app.loaded_assets.deinit(app.allocator);

imgui_mach.shutdown();
imgui.getIO().fonts.?.clear();
imgui.destroyContext(null);

zstbi.deinit();
state.allocator.free(state.root_path);
state.allocator.destroy(state);
app.allocator.free(app.root_path);
app.allocator.destroy(app);

//uncomment this line to check for memory leaks on program shutdown
_ = gpa.detectLeaks();
Expand Down
50 changes: 25 additions & 25 deletions src/assets.zig
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,6 @@ pub const palettes = "assets/palettes/";

pub const themes = "assets/themes/";

pub const pixi_atlas = struct {
pub const path = "assets/pixi.atlas";
pub const pencil_0_default = 0;
pub const eraser_0_default = 1;
pub const bucket_0_default = 2;
pub const dropper_0_default = 3;
pub const selection_0_default = 4;
pub const selection_add_0_default = 5;
pub const selection_rem_0_default = 6;
pub const fox_0_default = 7;
pub const logo_0_default = 8;
};

pub const pixi_png = struct {
pub const path = "assets/pixi.png";
};

pub const fox_png = struct {
pub const path = "assets/fox.png";
};
Expand All @@ -32,12 +15,12 @@ pub const fox_bg_png = struct {
pub const path = "assets/fox_bg.png";
};

pub const pear36_hex = struct {
pub const path = "assets/palettes/pear36.hex";
pub const apollo_hex = struct {
pub const path = "assets/palettes/apollo.hex";
};

pub const pico_8_hex = struct {
pub const path = "assets/palettes/pico-8.hex";
pub const endesga_32_hex = struct {
pub const path = "assets/palettes/endesga-32.hex";
};

pub const journey_hex = struct {
Expand All @@ -48,15 +31,32 @@ pub const lospec500_hex = struct {
pub const path = "assets/palettes/lospec500.hex";
};

pub const pear36_hex = struct {
pub const path = "assets/palettes/pear36.hex";
};

pub const pico_8_hex = struct {
pub const path = "assets/palettes/pico-8.hex";
};

pub const resurrect_64_hex = struct {
pub const path = "assets/palettes/resurrect-64.hex";
};

pub const endesga_32_hex = struct {
pub const path = "assets/palettes/endesga-32.hex";
pub const pixi_atlas = struct {
pub const path = "assets/pixi.atlas";
pub const pencil_0_default = 0;
pub const eraser_0_default = 1;
pub const bucket_0_default = 2;
pub const dropper_0_default = 3;
pub const selection_0_default = 4;
pub const selection_add_0_default = 5;
pub const selection_rem_0_default = 6;
pub const fox_0_default = 7;
pub const logo_0_default = 8;
};

pub const apollo_hex = struct {
pub const path = "assets/palettes/apollo.hex";
pub const pixi_png = struct {
pub const path = "assets/pixi.png";
};

0 comments on commit a99ed94

Please sign in to comment.