forked from PixelGuys/Cubyz
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
4 changed files
with
96 additions
and
2 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
const std = @import("std"); | ||
|
||
const main = @import("root"); | ||
const Vec2f = main.vec.Vec2f; | ||
|
||
const gui = @import("../gui.zig"); | ||
const GuiComponent = gui.GuiComponent; | ||
const GuiWindow = gui.GuiWindow; | ||
const Button = @import("../components/Button.zig"); | ||
const VerticalList = @import("../components/VerticalList.zig"); | ||
|
||
pub var window = GuiWindow { | ||
.contentSize = Vec2f{128, 256}, | ||
}; | ||
|
||
const padding: f32 = 8; | ||
|
||
pub fn onOpen() void { | ||
const list = VerticalList.init(.{padding, 16 + padding}, 300, 16); | ||
list.add(Button.initText(.{0, 0}, 128, "Invite Player TODO", .{})); | ||
list.add(Button.initText(.{0, 0}, 128, "Settings", gui.openWindowCallback("settings"))); | ||
list.add(Button.initText(.{0, 0}, 128, "Exit to Menu TODO", .{})); | ||
list.finish(.center); | ||
window.rootComponent = list.toComponent(); | ||
window.contentSize = window.rootComponent.?.pos() + window.rootComponent.?.size() + @as(Vec2f, @splat(padding)); | ||
gui.updateWindowPositions(); | ||
} | ||
|
||
pub fn onClose() void { | ||
if(window.rootComponent) |*comp| { | ||
comp.deinit(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
const std = @import("std"); | ||
|
||
const main = @import("root"); | ||
const Texture = main.graphics.Texture; | ||
const Vec2f = main.vec.Vec2f; | ||
|
||
const gui = @import("../gui.zig"); | ||
const GuiComponent = gui.GuiComponent; | ||
const GuiWindow = gui.GuiWindow; | ||
const Button = @import("../components/Button.zig"); | ||
const Label = GuiComponent.Label; | ||
const MutexComponent = GuiComponent.MutexComponent; | ||
const TextInput = GuiComponent.TextInput; | ||
const VerticalList = @import("../components/VerticalList.zig"); | ||
|
||
pub var window: GuiWindow = GuiWindow { | ||
.relativePosition = .{ | ||
.{ .attachedToFrame = .{.selfAttachmentPoint = .upper, .otherAttachmentPoint = .upper} }, | ||
.{ .attachedToFrame = .{.selfAttachmentPoint = .upper, .otherAttachmentPoint = .upper} }, | ||
}, | ||
.scale = 0.5, | ||
.contentSize = Vec2f{64, 64}, | ||
.showTitleBar = false, | ||
.hasBackground = false, | ||
.isHud = true, | ||
.hideIfMouseIsGrabbed = true, | ||
}; | ||
|
||
const padding: f32 = 8; | ||
const messageTimeout: i32 = 10000; | ||
const messageFade = 1000; | ||
|
||
var mutexComponent: MutexComponent = .{}; | ||
var history: main.List(*Label) = undefined; | ||
var expirationTime: main.List(i32) = undefined; | ||
var historyStart: u32 = 0; | ||
var fadeOutEnd: u32 = 0; | ||
var input: *TextInput = undefined; | ||
var hideInput: bool = true; | ||
|
||
var pauseIcon: Texture = undefined; | ||
|
||
pub fn init() void { | ||
pauseIcon = Texture.initFromFile("assets/cubyz/ui/pause_icon.png"); | ||
} | ||
|
||
pub fn deinit() void { | ||
pauseIcon.deinit(); | ||
} | ||
|
||
pub fn onOpen() void { | ||
const button = Button.initIcon(.{0, 0}, .{64, 64}, pauseIcon, true, gui.openWindowCallback("pause")); | ||
window.contentSize = button.size; | ||
window.rootComponent = button.toComponent(); | ||
} | ||
|
||
pub fn onClose() void { | ||
if(window.rootComponent) |*comp| { | ||
comp.deinit(); | ||
} | ||
} |