mirror of
https://github.com/OpenDiablo2/OpenDiablo2
synced 2024-12-25 11:36:26 -05:00
removed unused functions for text colorizing
This commit is contained in:
parent
c6ab79c388
commit
84c036f8a3
@ -1,8 +1,6 @@
|
|||||||
package d2gui
|
package d2gui
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"image/color"
|
|
||||||
|
|
||||||
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2interface"
|
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2interface"
|
||||||
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2math"
|
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2math"
|
||||||
)
|
)
|
||||||
@ -37,28 +35,3 @@ func renderSegmented(animation d2interface.Animation, segmentsX, segmentsY, fram
|
|||||||
func half(n int) int {
|
func half(n int) int {
|
||||||
return n / 2
|
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
|
|
||||||
}
|
|
||||||
|
@ -248,16 +248,16 @@ func (l *Layout) renderEntryDebug(entry *layoutEntry, target d2interface.Surface
|
|||||||
target.PushTranslation(entry.x, entry.y)
|
target.PushTranslation(entry.x, entry.y)
|
||||||
defer target.Pop()
|
defer target.Pop()
|
||||||
|
|
||||||
drawColor := rgbaColor(white)
|
drawColor := d2util.Color(white)
|
||||||
switch entry.widget.(type) {
|
switch entry.widget.(type) {
|
||||||
case *Layout:
|
case *Layout:
|
||||||
drawColor = rgbaColor(magenta)
|
drawColor = d2util.Color(magenta)
|
||||||
case *SpacerStatic, *SpacerDynamic:
|
case *SpacerStatic, *SpacerDynamic:
|
||||||
drawColor = rgbaColor(grey2)
|
drawColor = d2util.Color(grey2)
|
||||||
case *Label:
|
case *Label:
|
||||||
drawColor = rgbaColor(green)
|
drawColor = d2util.Color(green)
|
||||||
case *Button:
|
case *Button:
|
||||||
drawColor = rgbaColor(yellow)
|
drawColor = d2util.Color(yellow)
|
||||||
}
|
}
|
||||||
|
|
||||||
target.DrawLine(entry.width, 0, drawColor)
|
target.DrawLine(entry.width, 0, drawColor)
|
||||||
@ -487,7 +487,7 @@ func (l *Layout) createButton(renderer d2interface.Renderer, text string,
|
|||||||
return nil, loadErr
|
return nil, loadErr
|
||||||
}
|
}
|
||||||
|
|
||||||
textColor := rgbaColor(grey)
|
textColor := d2util.Color(grey)
|
||||||
textWidth, textHeight := font.GetTextMetrics(text)
|
textWidth, textHeight := font.GetTextMetrics(text)
|
||||||
textX := half(buttonWidth) - half(textWidth)
|
textX := half(buttonWidth) - half(textWidth)
|
||||||
textY := half(buttonHeight) - half(textHeight) + config.textOffset
|
textY := half(buttonHeight) - half(textHeight) + config.textOffset
|
||||||
|
@ -14,6 +14,7 @@ import (
|
|||||||
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2enum"
|
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2enum"
|
||||||
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2interface"
|
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2interface"
|
||||||
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2math"
|
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2math"
|
||||||
|
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2util"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@ -491,39 +492,14 @@ func parseCommand(command string) []string {
|
|||||||
return params
|
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) {
|
func createTerminal() (*terminal, error) {
|
||||||
terminal := &terminal{
|
terminal := &terminal{
|
||||||
lineCount: termRowCount,
|
lineCount: termRowCount,
|
||||||
bgColor: rgbaColor(darkGrey),
|
bgColor: d2util.Color(darkGrey),
|
||||||
fgColor: rgbaColor(lightGrey),
|
fgColor: d2util.Color(lightGrey),
|
||||||
infoColor: rgbaColor(lightBlue),
|
infoColor: d2util.Color(lightBlue),
|
||||||
warningColor: rgbaColor(yellow),
|
warningColor: d2util.Color(yellow),
|
||||||
errorColor: rgbaColor(red),
|
errorColor: d2util.Color(red),
|
||||||
actions: make(map[string]termActionEntry),
|
actions: make(map[string]termActionEntry),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user