remove log window & hide demo by default
This commit is contained in:
@@ -2,7 +2,6 @@ package game
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"image/color"
|
"image/color"
|
||||||
"log"
|
|
||||||
"runtime"
|
"runtime"
|
||||||
|
|
||||||
"edgaru089.ink/go/gl01/internal/asset"
|
"edgaru089.ink/go/gl01/internal/asset"
|
||||||
@@ -15,7 +14,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type guiState struct {
|
type guiState struct {
|
||||||
showLog, showDebugInfo bool
|
showDemo bool
|
||||||
logFollow bool
|
logFollow bool
|
||||||
|
|
||||||
lastframeCgoCalls int64
|
lastframeCgoCalls int64
|
||||||
@@ -41,8 +40,7 @@ func (g *Game) initImgui(win *glfw.Window) {
|
|||||||
backend.Init(win)
|
backend.Init(win)
|
||||||
|
|
||||||
g.gui = guiState{
|
g.gui = guiState{
|
||||||
showLog: true,
|
showDemo: false,
|
||||||
showDebugInfo: false,
|
|
||||||
logFollow: true,
|
logFollow: true,
|
||||||
loadChunkFile: "chunk.gob",
|
loadChunkFile: "chunk.gob",
|
||||||
loadChunkID: [2]int32{0, 0},
|
loadChunkID: [2]int32{0, 0},
|
||||||
@@ -69,36 +67,18 @@ func (g *Game) imgui() {
|
|||||||
igwrap.TextBackground("CgoCalls:%d (%d lastframe), Goroutines:%d", g.gui.lastframeCgoCalls, io.Diagnostics.CgoCalls, runtime.NumGoroutine())
|
igwrap.TextBackground("CgoCalls:%d (%d lastframe), Goroutines:%d", g.gui.lastframeCgoCalls, io.Diagnostics.CgoCalls, runtime.NumGoroutine())
|
||||||
igwrap.TextBlank()
|
igwrap.TextBlank()
|
||||||
|
|
||||||
|
if imgui.SelectableV("Show Demo", g.gui.showDemo, 0, imgui.Vec2{imgui.CalcTextSize("Show Demo", false, 0).X, 0}) {
|
||||||
|
g.gui.showDemo = !g.gui.showDemo
|
||||||
|
}
|
||||||
|
|
||||||
imgui.End()
|
imgui.End()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if g.paused {
|
if g.paused {
|
||||||
imgui.ShowDemoWindow(nil)
|
if g.gui.showDemo {
|
||||||
|
imgui.ShowDemoWindow(&g.gui.showDemo)
|
||||||
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()
|
|
||||||
}
|
|
||||||
|
|
||||||
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()
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
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 - 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)
|
||||||
|
|||||||
@@ -46,6 +46,7 @@ func (g *Game) Init(win *glfw.Window) {
|
|||||||
|
|
||||||
win.SetCursorPos(float64(width)/2, float64(height)/2)
|
win.SetCursorPos(float64(width)/2, float64(height)/2)
|
||||||
|
|
||||||
|
io.ShowDebugInfo = true
|
||||||
g.paused = true
|
g.paused = true
|
||||||
//win.SetInputMode(glfw.CursorMode, glfw.CursorDisabled)
|
//win.SetInputMode(glfw.CursorMode, glfw.CursorDisabled)
|
||||||
win.SetCursorPosCallback(func(w *glfw.Window, xpos, ypos float64) {
|
win.SetCursorPosCallback(func(w *glfw.Window, xpos, ypos float64) {
|
||||||
|
|||||||
Reference in New Issue
Block a user