1
1
mirror of https://github.com/OpenDiablo2/OpenDiablo2 synced 2024-12-24 19:18:12 -05:00

removed unused functions for text colorizing

This commit is contained in:
M. Sz 2020-12-14 11:40:19 +01:00
parent c6ab79c388
commit 84c036f8a3
3 changed files with 12 additions and 63 deletions

View File

@ -1,8 +1,6 @@
package d2gui
import (
"image/color"
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2interface"
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2math"
)
@ -37,28 +35,3 @@ func renderSegmented(animation d2interface.Animation, segmentsX, segmentsY, fram
func half(n int) int {
return n / 2
}
func rgbaColor(rgba uint32) color.RGBA {
result := color.RGBA{}
a, b, g, r := 0, 1, 2, 3
byteWidth := 8
byteMask := 0xff
for idx := 0; idx < 4; idx++ {
shift := idx * byteWidth
component := uint8(rgba>>shift) & uint8(byteMask)
switch idx {
case a:
result.A = component
case b:
result.B = component
case g:
result.G = component
case r:
result.R = component
}
}
return result
}

View File

@ -248,16 +248,16 @@ func (l *Layout) renderEntryDebug(entry *layoutEntry, target d2interface.Surface
target.PushTranslation(entry.x, entry.y)
defer target.Pop()
drawColor := rgbaColor(white)
drawColor := d2util.Color(white)
switch entry.widget.(type) {
case *Layout:
drawColor = rgbaColor(magenta)
drawColor = d2util.Color(magenta)
case *SpacerStatic, *SpacerDynamic:
drawColor = rgbaColor(grey2)
drawColor = d2util.Color(grey2)
case *Label:
drawColor = rgbaColor(green)
drawColor = d2util.Color(green)
case *Button:
drawColor = rgbaColor(yellow)
drawColor = d2util.Color(yellow)
}
target.DrawLine(entry.width, 0, drawColor)
@ -487,7 +487,7 @@ func (l *Layout) createButton(renderer d2interface.Renderer, text string,
return nil, loadErr
}
textColor := rgbaColor(grey)
textColor := d2util.Color(grey)
textWidth, textHeight := font.GetTextMetrics(text)
textX := half(buttonWidth) - half(textWidth)
textY := half(buttonHeight) - half(textHeight) + config.textOffset

View File

@ -14,6 +14,7 @@ import (
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2enum"
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2interface"
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2math"
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2util"
)
const (
@ -491,39 +492,14 @@ func parseCommand(command string) []string {
return params
}
func rgbaColor(rgba uint32) color.RGBA {
result := color.RGBA{}
a, b, g, r := 0, 1, 2, 3
byteWidth := 8
byteMask := 0xff
for idx := 0; idx < 4; idx++ {
shift := idx * byteWidth
component := uint8(rgba>>shift) & uint8(byteMask)
switch idx {
case a:
result.A = component
case b:
result.B = component
case g:
result.G = component
case r:
result.R = component
}
}
return result
}
func createTerminal() (*terminal, error) {
terminal := &terminal{
lineCount: termRowCount,
bgColor: rgbaColor(darkGrey),
fgColor: rgbaColor(lightGrey),
infoColor: rgbaColor(lightBlue),
warningColor: rgbaColor(yellow),
errorColor: rgbaColor(red),
bgColor: d2util.Color(darkGrey),
fgColor: d2util.Color(lightGrey),
infoColor: d2util.Color(lightBlue),
warningColor: d2util.Color(yellow),
errorColor: d2util.Color(red),
actions: make(map[string]termActionEntry),
}