hide other windows when not paused
This commit is contained in:
parent
aa3ad851cf
commit
a71acc22a0
@ -84,67 +84,71 @@ func (g *Game) imgui() {
|
||||
}
|
||||
}
|
||||
|
||||
if imgui.BeginV("Player", nil, imgui.WindowFlagsAlwaysAutoResize) {
|
||||
pos := g.player.Position()
|
||||
vel := g.player.Speed()
|
||||
igwrap.Text("Pos: (%.5f, %.5f, %.5f), Vel: (%.5f, %.5f, %.5f)", pos[0], pos[1], pos[2], vel[0], vel[1], vel[2])
|
||||
igwrap.Text("VelXZ=%.5f, VelXYZ=%.5f", math.Sqrt(vel[0]*vel[0]+vel[2]*vel[2]), vel.Length())
|
||||
}
|
||||
imgui.End()
|
||||
if g.paused {
|
||||
imgui.ShowDemoWindow(nil)
|
||||
|
||||
if igwrap.Begin("Logs", &g.gui.showLog, imgui.WindowFlagsMenuBar) {
|
||||
if imgui.BeginMenuBar() {
|
||||
if imgui.Button("Clear") {
|
||||
logs = ""
|
||||
if imgui.BeginV("Player", nil, imgui.WindowFlagsAlwaysAutoResize) {
|
||||
pos := g.player.Position()
|
||||
vel := g.player.Speed()
|
||||
igwrap.Text("Pos: (%.5f, %.5f, %.5f), Vel: (%.5f, %.5f, %.5f)", pos[0], pos[1], pos[2], vel[0], vel[1], vel[2])
|
||||
igwrap.Text("VelXZ=%.5f, VelXYZ=%.5f", math.Sqrt(vel[0]*vel[0]+vel[2]*vel[2]), vel.Length())
|
||||
}
|
||||
imgui.End()
|
||||
|
||||
if igwrap.Begin("Logs", &g.gui.showLog, imgui.WindowFlagsMenuBar) {
|
||||
if imgui.BeginMenuBar() {
|
||||
if imgui.Button("Clear") {
|
||||
logs = ""
|
||||
}
|
||||
if imgui.Button("Add Logs") {
|
||||
for i := 0; i < 8; i++ {
|
||||
log.Print("Added logs")
|
||||
}
|
||||
}
|
||||
imgui.Checkbox("Autoscroll", &g.gui.logFollow)
|
||||
imgui.EndMenuBar()
|
||||
}
|
||||
if imgui.Button("Add Logs") {
|
||||
for i := 0; i < 8; i++ {
|
||||
log.Print("Added logs")
|
||||
|
||||
imgui.BeginChildV("LogScroll", imgui.Vec2{}, true, 0)
|
||||
imgui.Text(logs)
|
||||
if g.gui.logFollow && imgui.ScrollY() >= imgui.ScrollMaxY() {
|
||||
imgui.SetScrollHereY(1.0)
|
||||
}
|
||||
imgui.EndChild()
|
||||
imgui.End()
|
||||
}
|
||||
|
||||
if imgui.Begin("Actions") {
|
||||
|
||||
imgui.Text("Chunks")
|
||||
imgui.Separator()
|
||||
imgui.InputText("Load Filename", &g.gui.loadChunkFile)
|
||||
imgui.SliderInt2("Load ID", &g.gui.loadChunkID, -10, 10)
|
||||
if imgui.ButtonV("Load", imgui.Vec2{X: -2, Y: 0}) {
|
||||
c := &world.Chunk{}
|
||||
f, err := os.Open(g.gui.loadChunkFile)
|
||||
if err != nil {
|
||||
log.Print("LoadChunk: ", err)
|
||||
} else {
|
||||
c.LoadFromGobIndexed(f, int(g.gui.loadChunkID[0]), int(g.gui.loadChunkID[1]))
|
||||
g.world.SetChunk(int(g.gui.loadChunkID[0]), int(g.gui.loadChunkID[1]), c)
|
||||
}
|
||||
}
|
||||
imgui.Checkbox("Autoscroll", &g.gui.logFollow)
|
||||
imgui.EndMenuBar()
|
||||
}
|
||||
imgui.Separator()
|
||||
imgui.InputText("Save Filename", &g.gui.saveChunkFile)
|
||||
imgui.SliderInt2("Save ID", &g.gui.saveChunkID, -10, 10)
|
||||
if imgui.ButtonV("Save", imgui.Vec2{X: -2, Y: 0}) {
|
||||
c := g.world.Chunks[itype.Vec2i{int(g.gui.saveChunkID[0]), int(g.gui.saveChunkID[1])}]
|
||||
f, _ := os.Create(g.gui.saveChunkFile)
|
||||
c.WriteToGob(f)
|
||||
f.Close()
|
||||
}
|
||||
imgui.Separator()
|
||||
|
||||
imgui.BeginChildV("LogScroll", imgui.Vec2{}, true, 0)
|
||||
imgui.Text(logs)
|
||||
if g.gui.logFollow && imgui.ScrollY() >= imgui.ScrollMaxY() {
|
||||
imgui.SetScrollHereY(1.0)
|
||||
}
|
||||
imgui.EndChild()
|
||||
imgui.End()
|
||||
}
|
||||
|
||||
if imgui.Begin("Actions") {
|
||||
|
||||
imgui.Text("Chunks")
|
||||
imgui.Separator()
|
||||
imgui.InputText("Load Filename", &g.gui.loadChunkFile)
|
||||
imgui.SliderInt2("Load ID", &g.gui.loadChunkID, -10, 10)
|
||||
if imgui.ButtonV("Load", imgui.Vec2{X: -2, Y: 0}) {
|
||||
c := &world.Chunk{}
|
||||
f, err := os.Open(g.gui.loadChunkFile)
|
||||
if err != nil {
|
||||
log.Print("LoadChunk: ", err)
|
||||
} else {
|
||||
c.LoadFromGobIndexed(f, int(g.gui.loadChunkID[0]), int(g.gui.loadChunkID[1]))
|
||||
g.world.SetChunk(int(g.gui.loadChunkID[0]), int(g.gui.loadChunkID[1]), c)
|
||||
}
|
||||
}
|
||||
imgui.Separator()
|
||||
imgui.InputText("Save Filename", &g.gui.saveChunkFile)
|
||||
imgui.SliderInt2("Save ID", &g.gui.saveChunkID, -10, 10)
|
||||
if imgui.ButtonV("Save", imgui.Vec2{X: -2, Y: 0}) {
|
||||
c := g.world.Chunks[itype.Vec2i{int(g.gui.saveChunkID[0]), int(g.gui.saveChunkID[1])}]
|
||||
f, _ := os.Create(g.gui.saveChunkFile)
|
||||
c.WriteToGob(f)
|
||||
f.Close()
|
||||
}
|
||||
imgui.Separator()
|
||||
|
||||
}
|
||||
imgui.End()
|
||||
|
||||
imgui.BackgroundDrawList().AddRectFilledV(imgui.Vec2{X: float32(io.DisplaySize[0]/2 - 12), Y: float32(io.DisplaySize[1]/2 - 1)}, imgui.Vec2{X: float32(io.DisplaySize[0]/2 + 12), Y: float32(io.DisplaySize[1]/2 + 1)}, imgui.Packed(color.White), 0, 0)
|
||||
imgui.BackgroundDrawList().AddRectFilledV(imgui.Vec2{X: float32(io.DisplaySize[0]/2 - 1), Y: float32(io.DisplaySize[1]/2 - 12)}, imgui.Vec2{X: float32(io.DisplaySize[0]/2 + 1), Y: float32(io.DisplaySize[1]/2 + 12)}, imgui.Packed(color.White), 0, 0)
|
||||
|
||||
|
@ -16,7 +16,6 @@ import (
|
||||
"edgaru089.ml/go/gl01/internal/world/worldgen"
|
||||
"github.com/go-gl/glfw/v3.3/glfw"
|
||||
"github.com/go-gl/mathgl/mgl64"
|
||||
"github.com/inkyblackness/imgui-go/v4"
|
||||
)
|
||||
|
||||
const (
|
||||
@ -307,7 +306,6 @@ func (g *Game) Update(win *glfw.Window, delta time.Duration) {
|
||||
|
||||
io.Diagnostics.Times.Logic = clock.Restart()
|
||||
|
||||
imgui.ShowDemoWindow(nil)
|
||||
g.imgui()
|
||||
io.Diagnostics.Times.GUI = clock.Restart()
|
||||
}
|
||||
|
@ -335,11 +335,13 @@ func (g *Game) Render(win *glfw.Window) {
|
||||
g.ResizeDisplay(io.DisplaySize)
|
||||
}
|
||||
|
||||
imgui.SliderFloat3("Sun", &sun, -1, 1)
|
||||
if g.paused {
|
||||
imgui.SliderFloat3("Sun", &sun, -1, 1)
|
||||
imgui.SliderFloat("Water Alpha", &alpha, 0, 1)
|
||||
imgui.SliderFloat("Gamma", &gamma, 1.6, 2.8)
|
||||
imgui.SliderFloat("Exposure", &exposure, 0, 2)
|
||||
}
|
||||
normalSun := itype.Vec3f(sun).Normalize()
|
||||
imgui.SliderFloat("Water Alpha", &alpha, 0, 1)
|
||||
imgui.SliderFloat("Gamma", &gamma, 1.6, 2.8)
|
||||
imgui.SliderFloat("Exposure", &exposure, 0, 2)
|
||||
|
||||
gl.Enable(gl.CULL_FACE)
|
||||
gl.Enable(gl.DEPTH_TEST)
|
||||
|
Loading…
Reference in New Issue
Block a user