Skip to content

Commit

Permalink
storage: Internal -> internal, External -> external
Browse files Browse the repository at this point in the history
  • Loading branch information
foxnne committed Jan 19, 2025
1 parent ebaeb84 commit 03a30e2
Show file tree
Hide file tree
Showing 19 changed files with 87 additions and 94 deletions.
4 changes: 2 additions & 2 deletions src/editor/Colors.zig
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ const Self = @This();
primary: [4]u8 = .{ 255, 255, 255, 255 },
secondary: [4]u8 = .{ 0, 0, 0, 255 },
height: u8 = 0,
palette: ?Pixi.storage.Internal.Palette = null,
keyframe_palette: ?Pixi.storage.Internal.Palette = null,
palette: ?Pixi.storage.internal.Palette = null,
keyframe_palette: ?Pixi.storage.internal.Palette = null,
36 changes: 18 additions & 18 deletions src/editor/Editor.zig
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,12 @@ sidebar: *Sidebar,
project_folder: ?[:0]const u8 = null,

previous_atlas_export: ?[:0]const u8 = null,
open_files: std.ArrayList(Pixi.storage.Internal.PixiFile) = undefined,
open_references: std.ArrayList(Pixi.storage.Internal.Reference) = undefined,
open_files: std.ArrayList(Pixi.storage.internal.PixiFile) = undefined,
open_references: std.ArrayList(Pixi.storage.internal.Reference) = undefined,
open_file_index: usize = 0,
open_reference_index: usize = 0,

atlas: Pixi.storage.Internal.Atlas = .{},
atlas: Pixi.storage.internal.Atlas = .{},
tools: Tools = .{},

colors: Colors = .{},
Expand Down Expand Up @@ -88,10 +88,10 @@ pub fn init(
.recents = try Recents.init(app.allocator),
};

editor.open_files = std.ArrayList(Pixi.storage.Internal.PixiFile).init(app.allocator);
editor.open_references = std.ArrayList(Pixi.storage.Internal.Reference).init(app.allocator);
editor.open_files = std.ArrayList(Pixi.storage.internal.PixiFile).init(app.allocator);
editor.open_references = std.ArrayList(Pixi.storage.internal.Reference).init(app.allocator);

editor.colors.keyframe_palette = try Pixi.storage.Internal.Palette.loadFromFile(Pixi.paths.pear36_hex.path);
editor.colors.keyframe_palette = try Pixi.storage.internal.Palette.loadFromFile(Pixi.paths.pear36_hex.path);

sidebar_mod.call(.init);
explorer_mod.call(.init);
Expand Down Expand Up @@ -258,7 +258,7 @@ pub fn newFile(editor: *Editor, path: [:0]const u8, import_path: ?[:0]const u8)
}
}

var internal: Pixi.storage.Internal.PixiFile = .{
var internal: Pixi.storage.internal.PixiFile = .{
.path = try Pixi.app.allocator.dupeZ(u8, path),
.width = @as(u32, @intCast(Pixi.editor.popups.file_setup_tiles[0] * Pixi.editor.popups.file_setup_tile_size[0])),
.height = @as(u32, @intCast(Pixi.editor.popups.file_setup_tiles[1] * Pixi.editor.popups.file_setup_tile_size[1])),
Expand All @@ -275,8 +275,8 @@ pub fn newFile(editor: *Editor, path: [:0]const u8, import_path: ?[:0]const u8)
.keyframe_transform_texture = undefined,
.deleted_animations = .{},
.background = undefined,
.history = Pixi.storage.Internal.PixiFile.History.init(Pixi.app.allocator),
.buffers = Pixi.storage.Internal.PixiFile.Buffers.init(Pixi.app.allocator),
.history = Pixi.storage.internal.PixiFile.History.init(Pixi.app.allocator),
.buffers = Pixi.storage.internal.PixiFile.Buffers.init(Pixi.app.allocator),
.temporary_layer = undefined,
.selection_layer = undefined,
};
Expand All @@ -293,7 +293,7 @@ pub fn newFile(editor: *Editor, path: [:0]const u8, import_path: ?[:0]const u8)
.texture = try Pixi.gfx.Texture.createEmpty(internal.width, internal.height, .{}),
};

var new_layer: Pixi.storage.Internal.Layer = .{
var new_layer: Pixi.storage.internal.Layer = .{
.name = try std.fmt.allocPrintZ(Pixi.app.allocator, "{s}", .{"Layer 0"}),
.texture = undefined,
.id = internal.newId(),
Expand All @@ -309,7 +309,7 @@ pub fn newFile(editor: *Editor, path: [:0]const u8, import_path: ?[:0]const u8)

internal.keyframe_animation_texture = try Pixi.gfx.Texture.createEmpty(internal.width, internal.height, .{});
internal.keyframe_transform_texture = .{
.vertices = .{Pixi.storage.Internal.PixiFile.TransformVertex{ .position = zmath.f32x4s(0.0) }} ** 4,
.vertices = .{Pixi.storage.internal.PixiFile.TransformVertex{ .position = zmath.f32x4s(0.0) }} ** 4,
.texture = internal.layers.items(.texture)[0],
};

Expand All @@ -322,7 +322,7 @@ pub fn newFile(editor: *Editor, path: [:0]const u8, import_path: ?[:0]const u8)
const tiles = @as(usize, @intCast(editor.popups.file_setup_tiles[0] * editor.popups.file_setup_tiles[1]));
var i: usize = 0;
while (i < tiles) : (i += 1) {
const sprite: Pixi.storage.Internal.Sprite = .{
const sprite: Pixi.storage.internal.Sprite = .{
.name = try std.fmt.allocPrintZ(Pixi.app.allocator, "{s}_{d}", .{ base_name[0..ext_ind], i }),
.index = i,
};
Expand Down Expand Up @@ -362,7 +362,7 @@ pub fn openFile(editor: *Editor, path: [:0]const u8) !bool {
}
}

if (try Pixi.storage.Internal.PixiFile.load(path)) |file| {
if (try Pixi.storage.internal.PixiFile.load(path)) |file| {
try editor.open_files.insert(0, file);
editor.setActiveFile(0);
return true;
Expand All @@ -380,7 +380,7 @@ pub fn openReference(editor: *Editor, path: [:0]const u8) !bool {

const texture = try Pixi.gfx.Texture.loadFromFile(path, .{});

const reference: Pixi.storage.Internal.Reference = .{
const reference: Pixi.storage.internal.Reference = .{
.path = try Pixi.app.allocator.dupeZ(u8, path),
.texture = texture,
};
Expand Down Expand Up @@ -430,14 +430,14 @@ pub fn getFileIndex(editor: *Editor, path: [:0]const u8) ?usize {
return null;
}

pub fn getFile(editor: *Editor, index: usize) ?*Pixi.storage.Internal.PixiFile {
pub fn getFile(editor: *Editor, index: usize) ?*Pixi.storage.internal.PixiFile {
if (editor.open_files.items.len == 0) return null;
if (index >= editor.open_files.items.len) return null;

return &editor.open_files.items[index];
}

pub fn getReference(editor: *Editor, index: usize) ?*Pixi.storage.Internal.Reference {
pub fn getReference(editor: *Editor, index: usize) ?*Pixi.storage.internal.Reference {
if (editor.open_references.items.len == 0) return null;
if (index >= editor.open_references.items.len) return null;

Expand Down Expand Up @@ -482,13 +482,13 @@ pub fn closeFile(editor: *Editor, index: usize) !void {

pub fn rawCloseFile(editor: *Editor, index: usize) !void {
editor.open_file_index = 0;
var file: Pixi.storage.Internal.PixiFile = editor.open_files.orderedRemove(index);
var file: Pixi.storage.internal.PixiFile = editor.open_files.orderedRemove(index);
file.deinit();
}

pub fn closeReference(editor: *Editor, index: usize) !void {
editor.open_reference_index = 0;
var reference: Pixi.storage.Internal.Reference = editor.open_references.orderedRemove(index);
var reference: Pixi.storage.internal.Reference = editor.open_references.orderedRemove(index);
reference.deinit();
}

Expand Down
4 changes: 2 additions & 2 deletions src/editor/artboard/canvas.zig
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const Editor = Pixi.Editor;
const imgui = @import("zig-imgui");
const zmath = @import("zmath");

pub fn draw(file: *Pixi.storage.Internal.PixiFile, core: *Core, app: *Pixi, editor: *Editor) !void {
pub fn draw(file: *Pixi.storage.internal.PixiFile, core: *Core, app: *Pixi, editor: *Editor) !void {
const transforming = file.transform_texture != null;

const window_width = imgui.getWindowWidth();
Expand Down Expand Up @@ -299,7 +299,7 @@ pub fn draw(file: *Pixi.storage.Internal.PixiFile, core: *Core, app: *Pixi, edit
file.camera.drawRect(rect, 3.0, editor.theme.text.toU32());

// Draw the origin
const sprite: Pixi.storage.Internal.Sprite = file.sprites.slice().get(sprite_index);
const sprite: Pixi.storage.internal.Sprite = file.sprites.slice().get(sprite_index);
file.camera.drawLine(
.{ x + sprite.origin_x, y },
.{ x + sprite.origin_x, y + tile_height },
Expand Down
6 changes: 3 additions & 3 deletions src/editor/artboard/flipbook/canvas.zig
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const Editor = Pixi.Editor;

const imgui = @import("zig-imgui");

pub fn draw(file: *Pixi.storage.Internal.PixiFile, app: *Pixi, editor: *Editor) !void {
pub fn draw(file: *Pixi.storage.internal.PixiFile, app: *Pixi, editor: *Editor) !void {
const window_height = imgui.getWindowHeight();
const tile_width = @as(f32, @floatFromInt(file.tile_width));
const tile_height = @as(f32, @floatFromInt(file.tile_height));
Expand Down Expand Up @@ -40,7 +40,7 @@ pub fn draw(file: *Pixi.storage.Internal.PixiFile, app: *Pixi, editor: *Editor)

// Handle playing animations and locking the current extents
if (file.selected_animation_state == .play and file.animations.slice().len > 0) {
const animation: Pixi.storage.Internal.Animation = file.animations.slice().get(file.selected_animation_index);
const animation: Pixi.storage.internal.Animation = file.animations.slice().get(file.selected_animation_index);
file.selected_animation_elapsed += app.delta_time;
if (file.selected_animation_elapsed > 1.0 / @as(f32, @floatFromInt(animation.fps))) {
file.selected_animation_elapsed = 0.0;
Expand Down Expand Up @@ -241,7 +241,7 @@ pub fn draw(file: *Pixi.storage.Internal.PixiFile, app: *Pixi, editor: *Editor)
}

if (file.selected_animation_state == .play) {
const animation: Pixi.storage.Internal.Animation = file.animations.slice().get(file.selected_animation_index);
const animation: Pixi.storage.internal.Animation = file.animations.slice().get(file.selected_animation_index);
// Draw progress bar
{
const window_position = imgui.getWindowPos();
Expand Down
4 changes: 2 additions & 2 deletions src/editor/artboard/flipbook/menu.zig
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ const Editor = Pixi.Editor;
const nfd = @import("nfd");
const imgui = @import("zig-imgui");

const History = Pixi.storage.Internal.PixiFile.History;
const History = Pixi.storage.internal.PixiFile.History;

pub fn draw(file: *Pixi.storage.Internal.PixiFile, mouse_ratio: f32, app: *Pixi, editor: *Editor) !void {
pub fn draw(file: *Pixi.storage.internal.PixiFile, mouse_ratio: f32, app: *Pixi, editor: *Editor) !void {
imgui.pushStyleVarImVec2(imgui.StyleVar_WindowPadding, .{ .x = 10.0, .y = 10.0 });
defer imgui.popStyleVar();
imgui.pushStyleColorImVec4(imgui.Col_Text, editor.theme.text.toImguiVec4());
Expand Down
28 changes: 14 additions & 14 deletions src/editor/artboard/flipbook/timeline.zig
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const frame_node_spacing: f32 = 4.0;

const work_area_offset: f32 = 12.0;

//var animation_opt: ?* Pixi.storage.Internal.KeyframeAnimation = null;
//var animation_opt: ?* Pixi.storage.internal.KeyframeAnimation = null;

var animation_index: ?usize = null;

Expand All @@ -23,7 +23,7 @@ var ms_hovered: ?usize = null;
var keyframe_dragging: ?u32 = null;
var mouse_scroll_delta_y: f32 = 0.0;

pub fn draw(file: *Pixi.storage.Internal.PixiFile, core: *Core, app: *Pixi) !void {
pub fn draw(file: *Pixi.storage.internal.PixiFile, core: *Core, app: *Pixi) !void {
const window_height = imgui.getWindowHeight();
const window_width = imgui.getWindowWidth();
const tile_width = @as(f32, @floatFromInt(file.tile_width));
Expand Down Expand Up @@ -401,14 +401,14 @@ pub fn draw(file: *Pixi.storage.Internal.PixiFile, core: *Core, app: *Pixi) !voi

const t: f32 = progress / total;

const tween_vertices: [4]Pixi.storage.Internal.PixiFile.TransformVertex = .{
const tween_vertices: [4]Pixi.storage.internal.PixiFile.TransformVertex = .{
.{ .position = zmath.lerp(from_frame.vertices[0].position, to_frame.vertices[0].position, t) },
.{ .position = zmath.lerp(from_frame.vertices[1].position, to_frame.vertices[1].position, t) },
.{ .position = zmath.lerp(from_frame.vertices[2].position, to_frame.vertices[2].position, t) },
.{ .position = zmath.lerp(from_frame.vertices[3].position, to_frame.vertices[3].position, t) },
};

const tween_pivot: Pixi.storage.Internal.PixiFile.TransformVertex = .{ .position = zmath.lerp(from_frame.pivot.position, to_frame.pivot.position, t) };
const tween_pivot: Pixi.storage.internal.PixiFile.TransformVertex = .{ .position = zmath.lerp(from_frame.pivot.position, to_frame.pivot.position, t) };

var from_rotation: f32 = from_frame.rotation;

Expand Down Expand Up @@ -496,7 +496,7 @@ pub fn draw(file: *Pixi.storage.Internal.PixiFile, core: *Core, app: *Pixi) !voi
}
}

pub fn drawVerticalLines(file: *Pixi.storage.Internal.PixiFile, animation_length: usize, scroll: [2]f32) !void {
pub fn drawVerticalLines(file: *Pixi.storage.internal.PixiFile, animation_length: usize, scroll: [2]f32) !void {
const tile_width = @as(f32, @floatFromInt(file.tile_width));
const tile_height = @as(f32, @floatFromInt(file.tile_height));

Expand Down Expand Up @@ -535,9 +535,9 @@ pub fn drawVerticalLines(file: *Pixi.storage.Internal.PixiFile, animation_length

if (primary_hotkey_down) {
if (animation_index == null) {
const new_animation: Pixi.storage.Internal.KeyframeAnimation = .{
const new_animation: Pixi.storage.internal.KeyframeAnimation = .{
.name = "New Keyframe Animation",
.keyframes = std.ArrayList(Pixi.storage.Internal.Keyframe).init(Pixi.app.allocator),
.keyframes = std.ArrayList(Pixi.storage.internal.Keyframe).init(Pixi.app.allocator),
.active_keyframe_id = 0,
.id = file.newId(),
};
Expand All @@ -552,7 +552,7 @@ pub fn drawVerticalLines(file: *Pixi.storage.Internal.PixiFile, animation_length
const sprite = file.sprites.slice().get(sprite_index);
const origin = zmath.loadArr2(.{ sprite.origin_x, sprite.origin_y });

const new_frame: Pixi.storage.Internal.Frame = .{
const new_frame: Pixi.storage.internal.Frame = .{
.id = file.newFrameId(),
.layer_id = file.layers.items(.id)[file.selected_layer_index],
.sprite_index = sprite_index,
Expand All @@ -570,10 +570,10 @@ pub fn drawVerticalLines(file: *Pixi.storage.Internal.PixiFile, animation_length

file.keyframe_animations.items(.active_keyframe_id)[index] = kf.id;
} else {
var new_keyframe: Pixi.storage.Internal.Keyframe = .{
var new_keyframe: Pixi.storage.internal.Keyframe = .{
.id = file.newKeyframeId(),
.time = hovered_time,
.frames = std.ArrayList(Pixi.storage.Internal.Frame).init(Pixi.app.allocator),
.frames = std.ArrayList(Pixi.storage.internal.Frame).init(Pixi.app.allocator),
.active_frame_id = new_frame.id,
};

Expand All @@ -592,7 +592,7 @@ pub fn drawVerticalLines(file: *Pixi.storage.Internal.PixiFile, animation_length
}
}

pub fn drawNodeArea(file: *Pixi.storage.Internal.PixiFile, animation_length: usize, scroll: [2]f32) !void {
pub fn drawNodeArea(file: *Pixi.storage.internal.PixiFile, animation_length: usize, scroll: [2]f32) !void {
const window_position = imgui.getWindowPos();
const window_hovered: bool = imgui.isWindowHovered(imgui.HoveredFlags_ChildWindows);

Expand Down Expand Up @@ -766,10 +766,10 @@ pub fn drawNodeArea(file: *Pixi.storage.Internal.PixiFile, animation_length: usi
}
} else {
if (dragging_keyframe.frames.items.len > 1) {
var new_keyframe: Pixi.storage.Internal.Keyframe = .{
var new_keyframe: Pixi.storage.internal.Keyframe = .{
.active_frame_id = dragging_frame_id,
.id = file.newKeyframeId(),
.frames = std.ArrayList(Pixi.storage.Internal.Frame).init(Pixi.app.allocator),
.frames = std.ArrayList(Pixi.storage.internal.Frame).init(Pixi.app.allocator),
.time = ms_float / 1000.0,
};

Expand Down Expand Up @@ -826,7 +826,7 @@ pub fn drawNodeArea(file: *Pixi.storage.Internal.PixiFile, animation_length: usi

if (secondary_down) {
try animation.keyframes.append(.{
.frames = std.ArrayList(Pixi.storage.Internal.Frame).init(Pixi.app.allocator),
.frames = std.ArrayList(Pixi.storage.internal.Frame).init(Pixi.app.allocator),
.id = file.newKeyframeId(),
.time = ms_float / 1000.0,
.active_frame_id = dragging_keyframe.active_frame_id,
Expand Down
2 changes: 1 addition & 1 deletion src/editor/artboard/rulers.zig
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ const Pixi = @import("../../Pixi.zig");
const Core = @import("mach").Core;
const imgui = @import("zig-imgui");

pub fn draw(file: *Pixi.storage.Internal.PixiFile, app: *Pixi, _: *Core) !void {
pub fn draw(file: *Pixi.storage.internal.PixiFile, app: *Pixi, _: *Core) !void {
const file_width = @as(f32, @floatFromInt(file.width));
const file_height = @as(f32, @floatFromInt(file.height));
const tile_width = @as(f32, @floatFromInt(file.tile_width));
Expand Down
2 changes: 1 addition & 1 deletion src/editor/explorer/animations.zig
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ pub fn draw(editor: *Editor) !void {
}
}

fn contextMenu(animation_index: usize, file: *Pixi.storage.Internal.PixiFile, editor: *Editor) !void {
fn contextMenu(animation_index: usize, file: *Pixi.storage.internal.PixiFile, editor: *Editor) !void {
if (imgui.beginPopupContextItem()) {
defer imgui.endPopup();

Expand Down
2 changes: 1 addition & 1 deletion src/editor/explorer/keyframe_animations.zig
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ pub fn draw(editor: *Editor) !void {
}
}

fn contextMenu(editor: *Editor, animation_index: usize, file: *Pixi.storage.Internal.PixiFile) !void {
fn contextMenu(editor: *Editor, animation_index: usize, file: *Pixi.storage.internal.PixiFile) !void {
if (imgui.beginPopupContextItem()) {
defer imgui.endPopup();

Expand Down
2 changes: 1 addition & 1 deletion src/editor/explorer/layers.zig
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ const std = @import("std");

const Pixi = @import("../../Pixi.zig");
const Editor = Pixi.Editor;
const History = Pixi.storage.Internal.PixiFile.History;
const History = Pixi.storage.internal.PixiFile.History;

const imgui = @import("zig-imgui");

Expand Down
2 changes: 1 addition & 1 deletion src/editor/explorer/tools.zig
Original file line number Diff line number Diff line change
Expand Up @@ -432,7 +432,7 @@ fn searchPalettes(editor: *Editor) !void {
if (editor.colors.palette) |*palette|
palette.deinit();

editor.colors.palette = Pixi.storage.Internal.Palette.loadFromFile(abs_path) catch null;
editor.colors.palette = Pixi.storage.internal.Palette.loadFromFile(abs_path) catch null;
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/editor/popups/animation.zig
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const Editor = Pixi.Editor;

const imgui = @import("zig-imgui");

const History = Pixi.storage.Internal.PixiFile.History;
const History = Pixi.storage.internal.PixiFile.History;

pub fn draw(editor: *Editor) !void {
if (editor.getFile(editor.open_file_index)) |file| {
Expand Down
Loading

0 comments on commit 03a30e2

Please sign in to comment.