1
1
mirror of https://github.com/OpenDiablo2/OpenDiablo2 synced 2024-06-20 14:15:23 +00:00

Merge pull request #971 from gucio321/hotfix

code-cleanup: rgbaColor & terminal
This commit is contained in:
Tim Sarbin 2020-12-14 19:56:43 -05:00 committed by GitHub
commit 3a4e6005f6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 42 additions and 152 deletions

View File

@ -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
}

View File

@ -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

View File

@ -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 (
@ -347,25 +348,15 @@ func parseActionParams(actionType reflect.Type, actionParams []string) ([]reflec
} }
func (t *terminal) OutputRaw(text string, category d2enum.TermCategory) { func (t *terminal) OutputRaw(text string, category d2enum.TermCategory) {
var line string lines := d2util.SplitIntoLinesWithMaxWidth(text, termColCountMax)
for _, word := range strings.Split(text, " ") { for _, line := range lines {
if len(line) > 0 { // removes color token (this token ends with [0m )
line += " " l := strings.Split(line, "[0m ")
} line = l[len(l)-1]
lineLength := len(line) t.outputHistory = append(t.outputHistory, termHistoryEntry{line, category})
wordLength := len(word)
if lineLength+wordLength >= termColCountMax {
t.outputHistory = append(t.outputHistory, termHistoryEntry{line, category})
line = word
} else {
line += word
}
} }
t.outputHistory = append(t.outputHistory, termHistoryEntry{line, category})
} }
func (t *terminal) Outputf(format string, params ...interface{}) { func (t *terminal) Outputf(format string, params ...interface{}) {
@ -491,39 +482,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),
} }

View File

@ -180,7 +180,7 @@ const (
blankQuestButtonXSegments = 1 blankQuestButtonXSegments = 1
blankQuestButtonYSegments = 1 blankQuestButtonYSegments = 1
blankQuestButtonDisabledFrames = -1 blankQuestButtonDisabledFrames = 0
buttonMinipanelCharacterBaseFrame = 0 buttonMinipanelCharacterBaseFrame = 0
buttonMinipanelInventoryBaseFrame = 2 buttonMinipanelInventoryBaseFrame = 2
@ -900,7 +900,7 @@ func (v *Button) prerenderStates(btnSprite *Sprite, btnLayout *ButtonLayout, lab
label.SetPosition(xOffset, textY) label.SetPosition(xOffset, textY)
label.Render(v.normalSurface) label.Render(v.normalSurface)
if !btnLayout.HasImage || !btnLayout.AllowFrameChange { if !btnLayout.AllowFrameChange {
return return
} }
@ -1002,7 +1002,7 @@ func (v *Button) Render(target d2interface.Surface) {
if v.toggled { if v.toggled {
target.Render(v.toggledSurface) target.Render(v.toggledSurface)
} else { } else if v.buttonLayout.HasImage { // it allows to use SetEnabled(false) for non-image budons
target.Render(v.disabledSurface) target.Render(v.disabledSurface)
} }
case v.toggled && v.pressed: case v.toggled && v.pressed:

View File

@ -74,7 +74,7 @@ func (s *Sprite) RenderSegmented(target d2interface.Surface, segmentsX, segments
for x := 0; x < segmentsX; x++ { for x := 0; x < segmentsX; x++ {
idx := x + y*segmentsX + frameOffset*segmentsX*segmentsY idx := x + y*segmentsX + frameOffset*segmentsX*segmentsY
if err := s.animation.SetCurrentFrame(idx); err != nil { if err := s.animation.SetCurrentFrame(idx); err != nil {
s.Error("SetCurrentFrame error" + err.Error()) s.Errorf("Error while setting frame (%d): %s", idx, err)
} }
target.PushTranslation(s.x+currentX, s.y+currentY) target.PushTranslation(s.x+currentX, s.y+currentY)

View File

@ -1,7 +1,6 @@
package d2gamescreen package d2gamescreen
import ( import (
"image/color"
"math" "math"
"os" "os"
"strconv" "strconv"
@ -190,7 +189,7 @@ func (v *CharacterSelect) OnLoad(loading d2screen.LoadingState) {
v.characterNameLabel[i] = v.uiManager.NewLabel(d2resource.Font16, d2resource.PaletteUnits) v.characterNameLabel[i] = v.uiManager.NewLabel(d2resource.Font16, d2resource.PaletteUnits)
v.characterNameLabel[i].SetPosition(offsetX, offsetY) v.characterNameLabel[i].SetPosition(offsetX, offsetY)
v.characterNameLabel[i].Color[0] = rgbaColor(lightBrown) v.characterNameLabel[i].Color[0] = d2util.Color(lightBrown)
offsetY += labelHeight offsetY += labelHeight
@ -201,7 +200,7 @@ func (v *CharacterSelect) OnLoad(loading d2screen.LoadingState) {
v.characterExpLabel[i] = v.uiManager.NewLabel(d2resource.Font16, d2resource.PaletteStatic) v.characterExpLabel[i] = v.uiManager.NewLabel(d2resource.Font16, d2resource.PaletteStatic)
v.characterExpLabel[i].SetPosition(offsetX, offsetY) v.characterExpLabel[i].SetPosition(offsetX, offsetY)
v.characterExpLabel[i].Color[0] = rgbaColor(lightGreen) v.characterExpLabel[i].Color[0] = d2util.Color(lightGreen)
} }
v.refreshGameStates() v.refreshGameStates()
@ -267,31 +266,6 @@ func (v *CharacterSelect) loadCharScrollbar() {
v.charScrollbar.OnActivated(func() { v.onScrollUpdate() }) v.charScrollbar.OnActivated(func() { v.onScrollUpdate() })
} }
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 (v *CharacterSelect) createButtons(loading d2screen.LoadingState) { func (v *CharacterSelect) createButtons(loading d2screen.LoadingState) {
v.newCharButton = v.uiManager.NewButton(d2ui.ButtonTypeTall, strings.Join( v.newCharButton = v.uiManager.NewButton(d2ui.ButtonTypeTall, strings.Join(
d2util.SplitIntoLinesWithMaxWidth(v.asset.TranslateString("#831"), 13), "\n")) d2util.SplitIntoLinesWithMaxWidth(v.asset.TranslateString("#831"), 13), "\n"))
@ -411,7 +385,7 @@ func (v *CharacterSelect) Render(screen d2interface.Surface) {
} }
if v.showDeleteConfirmation { if v.showDeleteConfirmation {
screen.DrawRect(screenWidth, screenHeight, rgbaColor(blackHalfOpacity)) screen.DrawRect(screenWidth, screenHeight, d2util.Color(blackHalfOpacity))
v.okCancelBox.RenderSegmented(screen, 2, 1, 0) v.okCancelBox.RenderSegmented(screen, 2, 1, 0)
v.deleteCharConfirmLabel.Render(screen) v.deleteCharConfirmLabel.Render(screen)
} }

View File

@ -98,7 +98,7 @@ func (v *Cinematics) OnLoad(_ d2screen.LoadingState) {
v.cinematicsLabel = v.uiManager.NewLabel(d2resource.Font30, d2resource.PaletteStatic) v.cinematicsLabel = v.uiManager.NewLabel(d2resource.Font30, d2resource.PaletteStatic)
v.cinematicsLabel.Alignment = d2ui.HorizontalAlignCenter v.cinematicsLabel.Alignment = d2ui.HorizontalAlignCenter
v.cinematicsLabel.SetText(v.asset.TranslateLabel(d2enum.SelectCinematicLabel)) v.cinematicsLabel.SetText(v.asset.TranslateLabel(d2enum.SelectCinematicLabel))
v.cinematicsLabel.Color[0] = rgbaColor(lightBrown) v.cinematicsLabel.Color[0] = d2util.Color(lightBrown)
v.cinematicsLabel.SetPosition(cinematicsLabelX, cinematicsLabelY) v.cinematicsLabel.SetPosition(cinematicsLabelX, cinematicsLabelY)
} }

View File

@ -239,32 +239,32 @@ func (v *MainMenu) createLabels(loading d2screen.LoadingState) {
v.versionLabel = v.uiManager.NewLabel(d2resource.FontFormal12, d2resource.PaletteStatic) v.versionLabel = v.uiManager.NewLabel(d2resource.FontFormal12, d2resource.PaletteStatic)
v.versionLabel.Alignment = d2ui.HorizontalAlignRight v.versionLabel.Alignment = d2ui.HorizontalAlignRight
v.versionLabel.SetText("OpenDiablo2 - " + v.buildInfo.Branch) v.versionLabel.SetText("OpenDiablo2 - " + v.buildInfo.Branch)
v.versionLabel.Color[0] = rgbaColor(white) v.versionLabel.Color[0] = d2util.Color(white)
v.versionLabel.SetPosition(versionLabelX, versionLabelY) v.versionLabel.SetPosition(versionLabelX, versionLabelY)
v.commitLabel = v.uiManager.NewLabel(d2resource.FontFormal10, d2resource.PaletteStatic) v.commitLabel = v.uiManager.NewLabel(d2resource.FontFormal10, d2resource.PaletteStatic)
v.commitLabel.Alignment = d2ui.HorizontalAlignLeft v.commitLabel.Alignment = d2ui.HorizontalAlignLeft
v.commitLabel.SetText(v.buildInfo.Commit) v.commitLabel.SetText(v.buildInfo.Commit)
v.commitLabel.Color[0] = rgbaColor(white) v.commitLabel.Color[0] = d2util.Color(white)
v.commitLabel.SetPosition(commitLabelX, commitLabelY) v.commitLabel.SetPosition(commitLabelX, commitLabelY)
v.copyrightLabel = v.uiManager.NewLabel(d2resource.FontFormal12, d2resource.PaletteStatic) v.copyrightLabel = v.uiManager.NewLabel(d2resource.FontFormal12, d2resource.PaletteStatic)
v.copyrightLabel.Alignment = d2ui.HorizontalAlignCenter v.copyrightLabel.Alignment = d2ui.HorizontalAlignCenter
v.copyrightLabel.SetText(v.asset.TranslateLabel(d2enum.CopyrightLabel)) v.copyrightLabel.SetText(v.asset.TranslateLabel(d2enum.CopyrightLabel))
v.copyrightLabel.Color[0] = rgbaColor(lightBrown) v.copyrightLabel.Color[0] = d2util.Color(lightBrown)
v.copyrightLabel.SetPosition(copyrightX, copyrightY) v.copyrightLabel.SetPosition(copyrightX, copyrightY)
loading.Progress(thirtyPercent) loading.Progress(thirtyPercent)
v.copyrightLabel2 = v.uiManager.NewLabel(d2resource.FontFormal12, d2resource.PaletteStatic) v.copyrightLabel2 = v.uiManager.NewLabel(d2resource.FontFormal12, d2resource.PaletteStatic)
v.copyrightLabel2.Alignment = d2ui.HorizontalAlignCenter v.copyrightLabel2.Alignment = d2ui.HorizontalAlignCenter
v.copyrightLabel2.SetText(v.asset.TranslateLabel(d2enum.AllRightsReservedLabel)) v.copyrightLabel2.SetText(v.asset.TranslateLabel(d2enum.AllRightsReservedLabel))
v.copyrightLabel2.Color[0] = rgbaColor(lightBrown) v.copyrightLabel2.Color[0] = d2util.Color(lightBrown)
v.copyrightLabel2.SetPosition(copyright2X, copyright2Y) v.copyrightLabel2.SetPosition(copyright2X, copyright2Y)
v.openDiabloLabel = v.uiManager.NewLabel(d2resource.FontFormal10, d2resource.PaletteStatic) v.openDiabloLabel = v.uiManager.NewLabel(d2resource.FontFormal10, d2resource.PaletteStatic)
v.openDiabloLabel.Alignment = d2ui.HorizontalAlignCenter v.openDiabloLabel.Alignment = d2ui.HorizontalAlignCenter
v.openDiabloLabel.SetText("OpenDiablo2 is neither developed by, nor endorsed by Blizzard or its parent company Activision") v.openDiabloLabel.SetText("OpenDiablo2 is neither developed by, nor endorsed by Blizzard or its parent company Activision")
v.openDiabloLabel.Color[0] = rgbaColor(lightYellow) v.openDiabloLabel.Color[0] = d2util.Color(lightYellow)
v.openDiabloLabel.SetPosition(od2LabelX, od2LabelY) v.openDiabloLabel.SetPosition(od2LabelX, od2LabelY)
loading.Progress(fiftyPercent) loading.Progress(fiftyPercent)
@ -276,19 +276,19 @@ func (v *MainMenu) createLabels(loading d2screen.LoadingState) {
v.tcpJoinGameLabel = v.uiManager.NewLabel(d2resource.Font16, d2resource.PaletteUnits) v.tcpJoinGameLabel = v.uiManager.NewLabel(d2resource.Font16, d2resource.PaletteUnits)
v.tcpJoinGameLabel.Alignment = d2ui.HorizontalAlignCenter v.tcpJoinGameLabel.Alignment = d2ui.HorizontalAlignCenter
v.tcpJoinGameLabel.SetText(strings.Join(d2util.SplitIntoLinesWithMaxWidth(v.asset.TranslateLabel(d2enum.TCPIPEnterHostIPLabel), 27), "\n")) v.tcpJoinGameLabel.SetText(strings.Join(d2util.SplitIntoLinesWithMaxWidth(v.asset.TranslateLabel(d2enum.TCPIPEnterHostIPLabel), 27), "\n"))
v.tcpJoinGameLabel.Color[0] = rgbaColor(gold) v.tcpJoinGameLabel.Color[0] = d2util.Color(gold)
v.tcpJoinGameLabel.SetPosition(joinGameX, joinGameY) v.tcpJoinGameLabel.SetPosition(joinGameX, joinGameY)
v.machineIP = v.uiManager.NewLabel(d2resource.Font24, d2resource.PaletteUnits) v.machineIP = v.uiManager.NewLabel(d2resource.Font24, d2resource.PaletteUnits)
v.machineIP.Alignment = d2ui.HorizontalAlignCenter v.machineIP.Alignment = d2ui.HorizontalAlignCenter
v.machineIP.SetText(v.asset.TranslateLabel(d2enum.TCPIPYourIPLabel) + "\n" + v.getLocalIP()) v.machineIP.SetText(v.asset.TranslateLabel(d2enum.TCPIPYourIPLabel) + "\n" + v.getLocalIP())
v.machineIP.Color[0] = rgbaColor(lightYellow) v.machineIP.Color[0] = d2util.Color(lightYellow)
v.machineIP.SetPosition(machineIPX, machineIPY) v.machineIP.SetPosition(machineIPX, machineIPY)
if v.errorLabel != nil { if v.errorLabel != nil {
v.errorLabel.SetPosition(errorLabelX, errorLabelY) v.errorLabel.SetPosition(errorLabelX, errorLabelY)
v.errorLabel.Alignment = d2ui.HorizontalAlignCenter v.errorLabel.Alignment = d2ui.HorizontalAlignCenter
v.errorLabel.Color[0] = rgbaColor(red) v.errorLabel.Color[0] = d2util.Color(red)
} }
} }

View File

@ -666,7 +666,7 @@ func (menu *KeyBindingMenu) onDefaultClicked() error {
func (menu *KeyBindingMenu) onAcceptClicked() error { func (menu *KeyBindingMenu) onAcceptClicked() error {
for gameEvent, change := range menu.changesToBeSaved { for gameEvent, change := range menu.changesToBeSaved {
menu.keyMap.SetPrimaryBinding(gameEvent, change.primary) menu.keyMap.SetPrimaryBinding(gameEvent, change.primary)
menu.keyMap.SetSecondaryBinding(gameEvent, change.primary) menu.keyMap.SetSecondaryBinding(gameEvent, change.secondary)
} }
menu.changesToBeSaved = make(map[d2enum.GameEvent]*bindingChange) menu.changesToBeSaved = make(map[d2enum.GameEvent]*bindingChange)

View File

@ -2,7 +2,6 @@ package d2player
import ( import (
"fmt" "fmt"
"image/color"
"strings" "strings"
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2enum" "github.com/OpenDiablo2/OpenDiablo2/d2common/d2enum"
@ -216,13 +215,13 @@ func (s *QuestLog) Load() {
s.questName = s.uiManager.NewLabel(d2resource.Font16, d2resource.PaletteStatic) s.questName = s.uiManager.NewLabel(d2resource.Font16, d2resource.PaletteStatic)
s.questName.Alignment = d2ui.HorizontalAlignCenter s.questName.Alignment = d2ui.HorizontalAlignCenter
s.questName.Color[0] = rgbaColor(white) s.questName.Color[0] = d2util.Color(white)
s.questName.SetPosition(questNameLabelX, questNameLabelY) s.questName.SetPosition(questNameLabelX, questNameLabelY)
s.panelGroup.AddWidget(s.questName) s.panelGroup.AddWidget(s.questName)
s.questDescr = s.uiManager.NewLabel(d2resource.Font16, d2resource.PaletteStatic) s.questDescr = s.uiManager.NewLabel(d2resource.Font16, d2resource.PaletteStatic)
s.questDescr.Alignment = d2ui.HorizontalAlignLeft s.questDescr.Alignment = d2ui.HorizontalAlignLeft
s.questDescr.Color[0] = rgbaColor(white) s.questDescr.Color[0] = d2util.Color(white)
s.questDescr.SetPosition(questDescrLabelX, questDescrLabelY) s.questDescr.SetPosition(questDescrLabelX, questDescrLabelY)
s.panelGroup.AddWidget(s.questDescr) s.panelGroup.AddWidget(s.questDescr)
@ -286,6 +285,7 @@ func (s *QuestLog) loadQuestIconsForAct(act int) *d2ui.WidgetGroup {
var icon *d2ui.Sprite var icon *d2ui.Sprite
for n := 0; n < questsInAct; n++ { for n := 0; n < questsInAct; n++ {
cw := n
x, y := s.getPositionForSocket(n) x, y := s.getPositionForSocket(n)
socket, err := s.uiManager.NewSprite(d2resource.QuestLogSocket, d2resource.PaletteSky) socket, err := s.uiManager.NewSprite(d2resource.QuestLogSocket, d2resource.PaletteSky)
@ -298,6 +298,7 @@ func (s *QuestLog) loadQuestIconsForAct(act int) *d2ui.WidgetGroup {
button := s.uiManager.NewButton(d2ui.ButtonTypeBlankQuestBtn, "") button := s.uiManager.NewButton(d2ui.ButtonTypeBlankQuestBtn, "")
button.SetPosition(x+questOffsetX, y+questOffsetY) button.SetPosition(x+questOffsetX, y+questOffsetY)
button.SetEnabled(s.questStatus[s.cordsToQuestID(act, cw)] != d2enum.QuestStatusNotStarted)
buttons = append(buttons, button) buttons = append(buttons, button)
icon, err = s.makeQuestIconForAct(act, n) icon, err = s.makeQuestIconForAct(act, n)
@ -383,7 +384,7 @@ func (s *QuestLog) setQuestLabel() {
s.questName.SetText(s.asset.TranslateString(fmt.Sprintf("qstsa%dq%d", s.selectedTab+1, s.selectedQuest))) s.questName.SetText(s.asset.TranslateString(fmt.Sprintf("qstsa%dq%d", s.selectedTab+1, s.selectedQuest)))
status := s.questStatus[s.cordsToQuestID(s.selectedTab+1, s.selectedQuest)] status := s.questStatus[s.cordsToQuestID(s.selectedTab+1, s.selectedQuest)-1]
switch status { switch status {
case d2enum.QuestStatusCompleted: case d2enum.QuestStatusCompleted:
s.questDescr.SetText( s.questDescr.SetText(
@ -393,6 +394,8 @@ func (s *QuestLog) setQuestLabel() {
questDescriptionLenght), questDescriptionLenght),
"\n"), "\n"),
) )
case d2enum.QuestStatusCompleting:
s.questDescr.SetText("")
case d2enum.QuestStatusNotStarted: case d2enum.QuestStatusNotStarted:
s.questDescr.SetText("") s.questDescr.SetText("")
default: default:
@ -527,32 +530,6 @@ func (s *QuestLog) renderStaticPanelFrames(target d2interface.Surface) {
} }
} }
// copy from character select (github.com/OpenDiablo2/OpenDiablo2/d2game/d2gamescreen/character_select.go)
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 (s *QuestLog) cordsToQuestID(act, number int) int { func (s *QuestLog) cordsToQuestID(act, number int) int {
key := (act-1)*d2enum.NormalActQuestsNumber + number key := (act-1)*d2enum.NormalActQuestsNumber + number
if act > d2enum.Act4 { if act > d2enum.Act4 {