Skip to content

Commit

Permalink
changed it from using a ghost icon to being a line color
Browse files Browse the repository at this point in the history
  • Loading branch information
RealRTTV committed Feb 14, 2024
1 parent b7b30b4 commit ab8e7e4
Show file tree
Hide file tree
Showing 11 changed files with 55 additions and 442 deletions.
13 changes: 7 additions & 6 deletions src/assets.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ pub const LINE_NUMBER_SEPARATOR_UV: Vec2u = Vec2u::new(60, 64);
pub const END_LINE_NUMBER_SEPARATOR_UV: Vec2u = Vec2u::new(62, 64);
pub const HORIZONTAL_SEPARATOR_UV: Vec2u = Vec2u::new(17, 80); // (14 by 2)
pub const TEXT_UNDERLINE_UV: Vec2u = Vec2u::new(16, 82);
pub const INSERTION_UV: Vec2u = Vec2u::new(16, 84);
pub const TOOLTIP_UV: Vec2u = Vec2u::new(96, 144);
pub const BOOKMARK_UV: Vec2u = Vec2u::new(112, 96);
pub const HIDDEN_BOOKMARK_UV: Vec2u = Vec2u::new(96, 128);
Expand Down Expand Up @@ -115,12 +116,12 @@ pub const LONG_ARRAY_UV: Vec2u = Vec2u::new(0, 32);
pub const REGION_UV: Vec2u = Vec2u::new(96, 32);
pub const CHUNK_UV: Vec2u = Vec2u::new(64, 32);

pub const BYTE_GHOST_UV: Vec2u = Vec2u::new(0, 16);
pub const SHORT_GHOST_UV: Vec2u = Vec2u::new(16, 16);
pub const INT_GHOST_UV: Vec2u = Vec2u::new(32, 16);
pub const LONG_GHOST_UV: Vec2u = Vec2u::new(48, 16);
pub const FLOAT_GHOST_UV: Vec2u = Vec2u::new(64, 16);
pub const DOUBLE_GHOST_UV: Vec2u = Vec2u::new(80, 16);
pub const BYTE_GRAYSCALE_UV: Vec2u = Vec2u::new(0, 16);
pub const SHORT_GRAYSCALE_UV: Vec2u = Vec2u::new(16, 16);
pub const INT_GRAYSCALE_UV: Vec2u = Vec2u::new(32, 16);
pub const LONG_GRAYSCALE_UV: Vec2u = Vec2u::new(48, 16);
pub const FLOAT_GRAYSCALE_UV: Vec2u = Vec2u::new(64, 16);
pub const DOUBLE_GRAYSCALE_UV: Vec2u = Vec2u::new(80, 16);
pub const BYTE_ARRAY_GHOST_UV: Vec2u = Vec2u::new(96, 16);
pub const STRING_GHOST_UV: Vec2u = Vec2u::new(16, 48);
pub const LIST_GHOST_UV: Vec2u = Vec2u::new(32, 48);
Expand Down
Binary file modified src/assets/atlas.hex
Binary file not shown.
Binary file modified src/assets/atlas.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
60 changes: 4 additions & 56 deletions src/elements/array.rs
Original file line number Diff line number Diff line change
Expand Up @@ -194,34 +194,7 @@ macro_rules! array {
}

let pos = ctx.pos();
if ctx.ghost(
ctx.pos() + (16, 16),
builder,
|x, y| pos == (x - 16, y - 8),
|id| id == $id,
) {
builder.draw_texture(
ctx.pos() + (0, 16),
CONNECTION_UV,
(16, (self.height() != 1) as usize * 7 + 9),
);
if !tail {
builder.draw_texture(ctx.pos() - (16, 0) + (0, 16), CONNECTION_UV, (8, 16));
}
ctx.y_offset += 16;
} else if self.height() == 1
&& ctx.ghost(
ctx.pos() + (16, 16),
builder,
|x, y| pos == (x - 16, y - 16),
|id| id == $id,
) {
builder.draw_texture(ctx.pos() + (0, 16), CONNECTION_UV, (16, 9));
if !tail {
builder.draw_texture(ctx.pos() - (16, 0) + (0, 16), CONNECTION_UV, (8, 16));
}
ctx.y_offset += 16;
}
if ctx.ghost(ctx.pos() + (16, 16), builder, |x, y| pos == (x - 16, y - 8), |id| id == $id) {} else if self.height() == 1 && ctx.ghost(ctx.pos() + (16, 16), builder, |x, y| pos == (x - 16, y - 16), |id| id == $id) {}

ctx.y_offset += 16;
}
Expand All @@ -241,29 +214,14 @@ macro_rules! array {
}

let pos = ctx.pos();
if ctx.ghost(ctx.pos(), builder, |x, y| pos == (x, y), |id| id == $id) {
builder.draw_texture(ctx.pos() - (16, 0), CONNECTION_UV, (16, 16));
if !tail {
builder.draw_texture(ctx.pos() - (32, 0), CONNECTION_UV, (8, 16));
}
ctx.y_offset += 16;
}

let ghost_tail_mod = if let Some((id, x, y, _)) = ctx.ghost
&& ctx.pos() + (0, 16 - *remaining_scroll * 16 - 8) == (x, y)
&& id == $id
{
false
} else {
true
};
ctx.ghost(ctx.pos(), builder, |x, y| pos == (x, y), |id| id == $id);

builder.draw_texture(
ctx.pos() - (16, 0),
CONNECTION_UV,
(
16,
(!(idx == self.len() - 1 && ghost_tail_mod)) as usize * 7 + 9,
(idx != self.len() - 1) as usize * 7 + 9,
),
);
if !tail {
Expand All @@ -283,17 +241,7 @@ macro_rules! array {
ctx.y_offset += 16;

let pos = ctx.pos();
if ctx.ghost(ctx.pos(), builder, |x, y| pos == (x, y + 8), |id| id == $id) {
builder.draw_texture(
ctx.pos() - (16, 0),
CONNECTION_UV,
(16, (idx != self.len() - 1) as usize * 7 + 9),
);
if !tail {
builder.draw_texture(ctx.pos() - (32, 0), CONNECTION_UV, (8, 16));
}
ctx.y_offset += 16;
}
ctx.ghost(ctx.pos(), builder, |x, y| pos == (x, y + 8), |id| id == $id);
}

ctx.x_offset -= 16;
Expand Down
127 changes: 7 additions & 120 deletions src/elements/chunk.rs
Original file line number Diff line number Diff line change
Expand Up @@ -365,28 +365,7 @@ impl NbtRegion {
}

let pos = ctx.pos();
if ctx.ghost(
ctx.pos() + (16, 16),
builder,
|x, y| pos == (x - 16, y - 8),
|id| id == NbtChunk::ID,
) {
builder.draw_texture(
ctx.pos() + (0, 16),
CONNECTION_UV,
(16, (self.height() != 1) as usize * 7 + 9),
);
ctx.y_offset += 16;
} else if self.height() == 1
&& ctx.ghost(
ctx.pos() + (16, 16),
builder,
|x, y| pos == (x - 16, y - 16),
|id| id == NbtChunk::ID,
) {
builder.draw_texture(ctx.pos() + (0, 16), CONNECTION_UV, (16, 9));
ctx.y_offset += 16;
}
if ctx.ghost(ctx.pos() + (16, 16), builder, |x, y| pos == (x - 16, y - 8), |id| id == NbtChunk::ID) {} else if self.height() == 1 && ctx.ghost(ctx.pos() + (16, 16), builder, |x, y| pos == (x - 16, y - 16), |id| id == NbtChunk::ID) {}

ctx.y_offset += 16;
}
Expand Down Expand Up @@ -451,31 +430,15 @@ impl NbtRegion {
}

let pos = ctx.pos();
if ctx.ghost(
ctx.pos(),
builder,
|x, y| pos == (x, y),
|id| id == NbtChunk::ID,
) {
builder.draw_texture(ctx.pos() - (16, 0), CONNECTION_UV, (16, 16));
ctx.y_offset += 16;
}

let ghost_tail_mod = if let Some((_, x, y, _)) = ctx.ghost
&& ctx.pos() + (0, height * 16 - remaining_scroll * 16 - 8) == (x, y)
{
false
} else {
true
};
ctx.ghost(ctx.pos(), builder, |x, y| pos == (x, y), |id| id == NbtChunk::ID);

if remaining_scroll == 0 {
builder.draw_texture(
ctx.pos() - (16, 0),
CONNECTION_UV,
(
16,
(idx != self.len() - 1 || !ghost_tail_mod) as usize * 7 + 9,
(idx != self.len() - 1) as usize * 7 + 9,
),
);
}
Expand All @@ -488,24 +451,12 @@ impl NbtRegion {
value.render(
builder,
&mut remaining_scroll,
idx == self.len() - 1 && ghost_tail_mod,
idx == self.len() - 1,
ctx,
);

let pos = ctx.pos();
if ctx.ghost(
ctx.pos(),
builder,
|x, y| pos == (x, y + 8),
|id| id == NbtChunk::ID,
) {
builder.draw_texture(
ctx.pos() - (16, 0),
CONNECTION_UV,
(16, (idx != self.len() - 1) as usize * 7 + 9),
);
ctx.y_offset += 16;
}
ctx.ghost(ctx.pos(), builder, |x, y| pos == (x, y + 8), |id| id == NbtChunk::ID);
}
}
}
Expand Down Expand Up @@ -804,36 +755,6 @@ impl NbtChunk {
let _ = write!(builder, "{name}");
}

let pos = ctx.pos();
if ctx.ghost(
ctx.pos() + (16, 16),
builder,
|x, y| pos == (x - 16, y - 8),
|id| id != Self::ID,
) {
builder.draw_texture(
ctx.pos() + (0, 16),
CONNECTION_UV,
(16, (self.height() != 1) as usize * 7 + 9),
);
if !tail {
builder.draw_texture(ctx.pos() - (16, 0) + (0, 16), CONNECTION_UV, (8, 16));
}
ctx.y_offset += 16;
} else if self.height() == 1
&& ctx.ghost(
ctx.pos() + (16, 16),
builder,
|x, y| pos == (x - 16, y - 16),
|id| id != Self::ID,
) {
builder.draw_texture(ctx.pos() + (0, 16), CONNECTION_UV, (16, 9));
if !tail {
builder.draw_texture(ctx.pos() - (16, 0) + (0, 16), CONNECTION_UV, (8, 16));
}
ctx.y_offset += 16;
}

ctx.y_offset += 16;
y_before += 16;
}
Expand Down Expand Up @@ -885,32 +806,13 @@ impl NbtChunk {
continue;
}

let pos = ctx.pos();
if ctx.ghost(
ctx.pos(),
builder,
|x, y| pos == (x, y),
|id| id != Self::ID,
) {
builder.draw_texture(ctx.pos() - (16, 0), CONNECTION_UV, (16, 16));
ctx.y_offset += 16;
}

let ghost_tail_mod = if let Some((_, x, y, _)) = ctx.ghost
&& ctx.pos() + (0, height * 16 - *remaining_scroll * 16 - 8) == (x, y)
{
false
} else {
true
};

if *remaining_scroll == 0 {
builder.draw_texture(
ctx.pos() - (16, 0),
CONNECTION_UV,
(
16,
(idx != self.len() - 1 || !ghost_tail_mod) as usize * 7 + 9,
(idx != self.len() - 1) as usize * 7 + 9,
),
);
}
Expand All @@ -922,24 +824,9 @@ impl NbtChunk {
remaining_scroll,
builder,
Some(key),
tail && idx == self.len() - 1 && ghost_tail_mod,
tail && idx == self.len() - 1,
ctx,
);

let pos = ctx.pos();
if ctx.ghost(
ctx.pos(),
builder,
|x, y| pos == (x, y + 8),
|id| id != Self::ID,
) {
builder.draw_texture(
ctx.pos() - (16, 0),
CONNECTION_UV,
(16, (idx != self.len() - 1) as usize * 7 + 9),
);
ctx.y_offset += 16;
}
}

if !tail {
Expand Down
Loading

0 comments on commit ab8e7e4

Please sign in to comment.