terminal printing

This commit is contained in:
M. Sz 2020-12-14 13:45:06 +01:00
parent 84c036f8a3
commit 25f405838a
3 changed files with 10 additions and 23 deletions

View File

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

View File

@ -1002,11 +1002,8 @@ func (v *Button) Render(target d2interface.Surface) {
if v.toggled {
target.Render(v.toggledSurface)
} else {
// it allows to use SetEnabled(false) for non-image budons
if v.buttonLayout.HasImage {
target.Render(v.disabledSurface)
}
} else if v.buttonLayout.HasImage { // it allows to use SetEnabled(false) for non-image budons
target.Render(v.disabledSurface)
}
case v.toggled && v.pressed:
target.Render(v.pressedToggledSurface)

View File

@ -285,6 +285,7 @@ func (s *QuestLog) loadQuestIconsForAct(act int) *d2ui.WidgetGroup {
var icon *d2ui.Sprite
for n := 0; n < questsInAct; n++ {
cw := n
x, y := s.getPositionForSocket(n)
socket, err := s.uiManager.NewSprite(d2resource.QuestLogSocket, d2resource.PaletteSky)
@ -297,8 +298,7 @@ func (s *QuestLog) loadQuestIconsForAct(act int) *d2ui.WidgetGroup {
button := s.uiManager.NewButton(d2ui.ButtonTypeBlankQuestBtn, "")
button.SetPosition(x+questOffsetX, y+questOffsetY)
cw := n
button.SetEnabled(!(s.questStatus[s.cordsToQuestID(act, cw)] == d2enum.QuestStatusNotStarted))
button.SetEnabled(s.questStatus[s.cordsToQuestID(act, cw)] != d2enum.QuestStatusNotStarted)
buttons = append(buttons, button)
icon, err = s.makeQuestIconForAct(act, n)