Example #1
0
func (sm *OnlineMenu) Draw(region gui.Region) {
	sm.region = region
	gl.Color4ub(255, 255, 255, 255)
	sm.layout.Background.Data().RenderNatural(region.X, region.Y)
	title := sm.layout.Title
	title.Texture.Data().RenderNatural(region.X+title.X, region.Y+title.Y)
	for _, button := range sm.buttons {
		button.RenderAt(sm.region.X, sm.region.Y)
	}

	d := base.GetDictionary(sm.layout.Text.Size)
	for _, glb := range []*gameListBox{&sm.layout.Active, &sm.layout.Unstarted} {
		glb.Scroll.Region().PushClipPlanes()
		sx := glb.Scroll.X
		sy := glb.Scroll.Top() - int(d.MaxHeight())
		for _, button := range glb.games {
			button.RenderAt(sx, sy)
			sy -= int(d.MaxHeight())
		}
		glb.Scroll.Region().PopClipPlanes()
	}

	gl.Color4ub(255, 255, 255, byte(255*sm.update_alpha))
	sx := sm.layout.User.Entry.X + sm.layout.User.Entry.Dx + 10
	sy := sm.layout.User.Button.Y
	d.RenderString("Name Updated", float64(sx), float64(sy), 0, d.MaxHeight(), gui.Left)

	if sm.layout.Error.err != "" {
		gl.Color4ub(255, 0, 0, 255)
		l := sm.layout.Error
		d := base.GetDictionary(l.Size)
		d.RenderString(fmt.Sprintf("ERROR: %s", l.err), float64(l.X), float64(l.Y), 0, d.MaxHeight(), gui.Left)
	}
}
Example #2
0
func (b *Button) RenderAt(x, y int) {
	gl.Color4ub(255, 255, 255, byte(b.shade*255))
	if b.Texture.Path != "" {
		b.Texture.Data().RenderNatural(b.X+x, b.Y+y)
		b.bounds.x = b.X + x
		b.bounds.y = b.Y + y
		b.bounds.dx = b.Texture.Data().Dx()
		b.bounds.dy = b.Texture.Data().Dy()
	} else {
		d := base.GetDictionary(b.Text.Size)
		b.bounds.x = b.X + x
		b.bounds.y = b.Y + y
		b.bounds.dx = int(d.StringWidth(b.Text.String))
		b.bounds.dy = int(d.MaxHeight())
		var just gui.Justification
		switch b.Text.Justification {
		case "center":
			just = gui.Center
			b.bounds.x -= b.bounds.dx / 2
		case "left":
			just = gui.Left
		case "right":
			just = gui.Right
			b.bounds.x -= b.bounds.dx
		default:
			just = gui.Center
			b.bounds.x -= b.bounds.dx / 2
			b.Text.Justification = "center"
		}
		d.RenderString(b.Text.String, float64(b.X+x), float64(b.Y+y), 0, d.MaxHeight(), just)
	}
}
Example #3
0
func (sm *OnlineMenu) Draw(region gui.Region) {
	sm.region = region
	gl.Color4ub(255, 255, 255, 255)
	sm.layout.Background.Data().RenderNatural(region.X, region.Y)
	title := sm.layout.Title
	title.Texture.Data().RenderNatural(region.X+title.X, region.Y+title.Y)
	for _, button := range sm.buttons {
		button.RenderAt(sm.region.X, sm.region.Y)
	}

	d := base.GetDictionary(sm.layout.Text.Size)
	for _, glb := range []*gameListBox{&sm.layout.Active, &sm.layout.Unstarted} {
		title_d := base.GetDictionary(glb.Title.Size)
		title_x := float64(glb.Scroll.X + glb.Scroll.Dx/2)
		title_y := float64(glb.Scroll.Y + glb.Scroll.Dy)
		gl.Disable(gl.TEXTURE_2D)
		gl.Color4ub(255, 255, 255, 255)
		title_d.RenderString(glb.Title.Text, title_x, title_y, 0, title_d.MaxHeight(), gui.Center)

		sx := glb.Scroll.X
		sy := glb.Scroll.Top()
		glb.Scroll.Region().PushClipPlanes()
		for _, game := range glb.games {
			sy -= int(d.MaxHeight())
			game.join.RenderAt(sx, sy)
			gl.Disable(gl.TEXTURE_2D)
			gl.Color4ub(255, 255, 255, 255)
			d.RenderString(game.name, float64(sx+50), float64(sy), 0, d.MaxHeight(), gui.Left)
			if game.delete != nil {
				game.delete.RenderAt(sx+50+glb.Scroll.Dx-100, sy)
			}
		}
		glb.Scroll.Region().PopClipPlanes()
	}

	gl.Color4ub(255, 255, 255, byte(255*sm.update_alpha))
	sx := sm.layout.User.Entry.X + sm.layout.User.Entry.Dx + 10
	sy := sm.layout.User.Button.Y
	d.RenderString("Name Updated", float64(sx), float64(sy), 0, d.MaxHeight(), gui.Left)

	if sm.layout.Error.err != "" {
		gl.Color4ub(255, 0, 0, 255)
		l := sm.layout.Error
		d := base.GetDictionary(l.Size)
		d.RenderString(fmt.Sprintf("ERROR: %s", l.err), float64(l.X), float64(l.Y), 0, d.MaxHeight(), gui.Left)
	}
}
Example #4
0
func (a *SummonAction) RenderOnFloor() {
	if a.ent == nil {
		return
	}
	ex, ey := a.ent.Pos()
	if dist(ex, ey, a.cx, a.cy) <= a.Range && a.ent.HasLos(a.cx, a.cy, 1, 1) {
		gl.Color4ub(255, 255, 255, 200)
	} else {
		gl.Color4ub(255, 64, 64, 200)
	}
	base.EnableShader("box")
	base.SetUniformF("box", "dx", 1)
	base.SetUniformF("box", "dy", 1)
	base.SetUniformI("box", "temp_invalid", 0)
	(&texture.Object{}).Data().Render(float64(a.cx), float64(a.cy), 1, 1)
	base.EnableShader("")
}
Example #5
0
func (sm *StartMenu) Draw(region gui.Region) {
	sm.region = region
	gl.Color4ub(255, 255, 255, 255)
	sm.layout.Background.Data().RenderNatural(sm.region.X, sm.region.Y)
	sm.layout.Menu.Texture.Data().RenderNatural(sm.region.X+sm.layout.Menu.X, sm.region.Y+sm.layout.Menu.Y)
	for _, button := range sm.buttons {
		button.RenderAt(sm.region.X, sm.region.Y)
	}
}
Example #6
0
func (a *AoeAttack) RenderOnFloor() {
	if a.ent == nil {
		return
	}
	ex, ey := a.ent.Pos()
	if dist(ex, ey, a.tx, a.ty) <= a.Range && a.ent.HasLos(a.tx, a.ty, 1, 1) {
		gl.Color4ub(255, 255, 255, 200)
	} else {
		gl.Color4ub(255, 64, 64, 200)
	}
	base.EnableShader("box")
	base.SetUniformF("box", "dx", float32(a.Diameter))
	base.SetUniformF("box", "dy", float32(a.Diameter))
	base.SetUniformI("box", "temp_invalid", 0)
	x := a.tx - (a.Diameter+1)/2
	y := a.ty - (a.Diameter+1)/2
	(&texture.Object{}).Data().Render(float64(x), float64(y), float64(a.Diameter), float64(a.Diameter))
	base.EnableShader("")
}
Example #7
0
func (cm *CreditsMenu) Draw(region gui.Region) {
	cm.region = region
	gl.Color4ub(255, 255, 255, 255)
	cm.layout.Background.Data().RenderNatural(region.X, region.Y)
	title := cm.layout.Title
	title.Texture.Data().RenderNatural(region.X+title.X, region.Y+title.Y)
	for _, button := range cm.buttons {
		button.RenderAt(cm.region.X, cm.region.Y)
	}

	d := base.GetDictionary(cm.layout.Credits.Size)
	sx := cm.layout.Credits.Scroll.X
	sy := cm.layout.Credits.Scroll.Top()
	cm.layout.Credits.Scroll.Region().PushClipPlanes()
	gl.Disable(gl.TEXTURE_2D)
	gl.Color4ub(255, 255, 255, 255)
	for _, line := range cm.layout.Credits.Lines {
		sy -= int(d.MaxHeight())
		d.RenderString(line, float64(sx), float64(sy), 0, d.MaxHeight(), gui.Left)
	}
	cm.layout.Credits.Scroll.Region().PopClipPlanes()
}
Example #8
0
func (te *TextEntry) RenderAt(x, y int) {
	te.Button.RenderAt(x, y)
	d := base.GetDictionary(te.Button.Text.Size)
	x += te.Entry.X
	y += te.Button.Y
	x2 := x + te.Entry.Dx
	y2 := y + int(d.MaxHeight())
	te.Entry.bounds.x = x
	te.Entry.bounds.y = y
	te.Entry.bounds.dx = x2 - x
	te.Entry.bounds.dy = y2 - y
	gl.Disable(gl.TEXTURE_2D)
	if te.Entry.entering {
		gl.Color4ub(255, 255, 255, 255)
	} else {
		gl.Color4ub(255, 255, 255, 128)
	}
	gl.Begin(gl.QUADS)
	gl.Vertex2i(x-3, y-3)
	gl.Vertex2i(x-3, y2+3)
	gl.Vertex2i(x2+3, y2+3)
	gl.Vertex2i(x2+3, y-3)
	gl.End()
	gl.Color4ub(0, 0, 0, 255)
	gl.Begin(gl.QUADS)
	gl.Vertex2i(x, y)
	gl.Vertex2i(x, y2)
	gl.Vertex2i(x2, y2)
	gl.Vertex2i(x2, y)
	gl.End()

	gl.Color4ub(255, 255, 255, 255)
	d.RenderString(te.Entry.text, float64(x), float64(y), 0, d.MaxHeight(), gui.Left)

	if te.Entry.ghost.offset >= 0 {
		gl.Disable(gl.TEXTURE_2D)
		gl.Color4ub(255, 100, 100, 127)
		gl.Begin(gl.LINES)
		gl.Vertex2i(te.Entry.bounds.x+te.Entry.ghost.offset, te.Entry.bounds.y)
		gl.Vertex2i(te.Entry.bounds.x+te.Entry.ghost.offset, te.Entry.bounds.y+te.Entry.bounds.dy)
		gl.End()
	}
	if te.Entry.entering {
		gl.Disable(gl.TEXTURE_2D)
		gl.Color4ub(255, 100, 100, 255)
		gl.Begin(gl.LINES)
		gl.Vertex2i(te.Entry.bounds.x+te.Entry.cursor.offset, te.Entry.bounds.y)
		gl.Vertex2i(te.Entry.bounds.x+te.Entry.cursor.offset, te.Entry.bounds.y+te.Entry.bounds.dy)
		gl.End()
	}
}
Example #9
0
func (sm *OnlineMenu) Draw(region gui.Region) {
	sm.region = region
	gl.Color4ub(255, 255, 255, 255)
	sm.layout.Background.Data().RenderNatural(region.X, region.Y)
	title := sm.layout.Title
	title.Texture.Data().RenderNatural(region.X+title.X, region.Y+title.Y)
	for _, button := range sm.buttons {
		button.RenderAt(sm.region.X, sm.region.Y)
	}

	d := base.GetDictionary(sm.layout.Text.Size)
	for _, glb := range []*gameListBox{&sm.layout.Active, &sm.layout.Unstarted} {
		title_d := base.GetDictionary(glb.Title.Size)
		title_x := float64(glb.Scroll.X + glb.Scroll.Dx/2)
		title_y := float64(glb.Scroll.Y + glb.Scroll.Dy)
		gl.Disable(gl.TEXTURE_2D)
		gl.Color4ub(255, 255, 255, 255)
		title_d.RenderString(glb.Title.Text, title_x, title_y, 0, title_d.MaxHeight(), gui.Center)

		sx := glb.Scroll.X
		sy := glb.Scroll.Top()
		glb.Scroll.Region().PushClipPlanes()
		for _, game := range glb.games {
			sy -= int(d.MaxHeight())
			game.join.RenderAt(sx, sy)
			gl.Disable(gl.TEXTURE_2D)
			gl.Color4ub(255, 255, 255, 255)
			d.RenderString(game.name, float64(sx+50), float64(sy), 0, d.MaxHeight(), gui.Left)
			if game.delete != nil {
				game.delete.RenderAt(sx+50+glb.Scroll.Dx-100, sy)
			}
		}
		glb.Scroll.Region().PopClipPlanes()
	}

	gl.Color4ub(255, 255, 255, byte(255*sm.update_alpha))
	sx := sm.layout.User.Entry.X + sm.layout.User.Entry.Dx + 10
	sy := sm.layout.User.Button.Y
	d.RenderString("Name Updated", float64(sx), float64(sy), 0, d.MaxHeight(), gui.Left)

	if sm.hover_game != nil {
		game := sm.hover_game
		gl.Disable(gl.TEXTURE_2D)
		gl.Color4ub(255, 255, 255, 255)
		d := base.GetDictionary(sm.layout.GameStats.Size)
		x := float64(sm.layout.GameStats.X + sm.layout.GameStats.Dx/2)
		y := float64(sm.layout.GameStats.Y+sm.layout.GameStats.Dy) - d.MaxHeight()

		if game.game.Denizens_id == net_id {
			d.RenderString("You: Denizens", x, y, 0, d.MaxHeight(), gui.Center)
		} else {
			d.RenderString("You: Intruders", x, y, 0, d.MaxHeight(), gui.Center)
		}
		y -= d.MaxHeight()
		if game.game.Denizens_id == net_id {
			var opponent string
			if game.game.Intruders_name == "" {
				opponent = "no opponent yet"
			} else {
				opponent = fmt.Sprintf("Vs: %s", game.game.Intruders_name)
			}
			d.RenderString(opponent, x, y, 0, d.MaxHeight(), gui.Center)
		} else {
			d.RenderString(fmt.Sprintf("Vs: %s", game.game.Denizens_name), x, y, 0, d.MaxHeight(), gui.Center)
		}
		y -= d.MaxHeight()
		if (game.game.Denizens_id == net_id) == (len(game.game.Execs)%2 == 0) {
			d.RenderString("Your move", x, y, 0, d.MaxHeight(), gui.Center)
		} else {
			d.RenderString("Their move", x, y, 0, d.MaxHeight(), gui.Center)
		}
	}

	if sm.layout.Error.err != "" {
		gl.Color4ub(255, 0, 0, 255)
		l := sm.layout.Error
		d := base.GetDictionary(l.Size)
		d.RenderString(fmt.Sprintf("ERROR: %s", l.err), float64(l.X), float64(l.Y), 0, d.MaxHeight(), gui.Left)
	}
}