gumps

package
v0.0.0-...-b0deb01 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 10, 2023 License: AGPL-3.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	GUMPIDDecorate uo.Serial = 1
	GUMPIDRegions  uo.Serial = 2
)

Static GUMP IDs, these shouldn't be needed often.

Variables

This section is empty.

Functions

func Edit

func Edit(m game.Mobile, o game.Object)

Edit opens the editing GUMP for the object if any

func InjectMethods

func InjectMethods(fn func(game.NetState, string))

InjectMethods is responsible for injecting methods for cross-package communication.

func MungHTMLForGUMP

func MungHTMLForGUMP(in string) string

MungHTMLForGUMP manipulates the input line-by-line in the following way: 1. All leading and trailing whitespace is removed 2. The trailing newline is replaced with a single space 3. Consecutive whitespace is collapsed into a single space

func TypeCodeByName

func TypeCodeByName(name string) uo.Serial

TypeCodeByName returns the type code for the given name.

Types

type BaseGUMP

type BaseGUMP struct {
	// contains filtered or unexported fields
}

BaseGUMP represents a generic GUMP and is the basis for all other GUMPs.

func (*BaseGUMP) AlphaRegion

func (g *BaseGUMP) AlphaRegion(x, y, w, h int)

AlphaRegion is supposed to add a checkered transparent region to the GUMP. However ClassicUO - at least as of version 0.1.11.39 - adds this region but also makes the entire GUMP 50% alpha.

func (*BaseGUMP) Background

func (g *BaseGUMP) Background(x, y, w, h int, bg uo.GUMP)

Background creates a 3x3 background tiled to the given dimensions.

func (*BaseGUMP) Checkbox

func (g *BaseGUMP) Checkbox(x, y int, normal, pressed uo.GUMP, id uint32, checked bool)

Checkbox creates a checkbox button.

func (*BaseGUMP) CroppedLabel

func (g *BaseGUMP) CroppedLabel(x, y, w, h int, hue uo.Hue, text string)

CroppedLabel like Label but within a cropped area.

func (*BaseGUMP) EndGroup

func (g *BaseGUMP) EndGroup()

EndGroup ends the current RadioButton group. RadioButton groups must be book- ended by the EndGroup function otherwise they will not work on pages after 1 according to the POL GUMP documentation. No idea if this is an issue in ClassicUO.

func (*BaseGUMP) Group

func (g *BaseGUMP) Group(n uint32)

Group starts a RadioButton group. RadioButton groups must be book-ended by the EndGroup function otherwise they will not work on pages after 1 according to the POL GUMP documentation. No idea if this is an issue in ClassicUO.

func (*BaseGUMP) HTML

func (g *BaseGUMP) HTML(x, y, w, h int, html string, background, scrollbar bool)

HTML creates an HTML view.

According to the POL GUMP documentation these are the HTML tags that are supported: <B></B>..................................... Bold <BIG></BIG>................................. Bigger font <SMALL></SMALL>............................. Smaller font <EM></EM>................................... Emphasis <I></I>..................................... Italicized <U></U>..................................... Underlined <H1></H1>................................... Heading 1 - largest <H2></H2>................................... Heading 2 <H3></H3>................................... Heading 3 <H4></H4>................................... Heading 4 <H5></H5>................................... Heading 5 <H6></H6>................................... Heading 6 - smallest <a href=""></a>............................. Hyperlink <div align="right"></DIV>................... Division on the right <div align="left"></DIV>.................... Division on the left <left></left>............................... Left-align text <P>......................................... Paragraph block <CENTER></CENTER>........................... Center-align text <BR></BR>................................... Line break <BASEFONT color=#ffffff size=1-7></BASEFONT> Set default font?

func (*BaseGUMP) Image

func (g *BaseGUMP) Image(x, y int, gump uo.GUMP, hue uo.Hue)

Image places a GUMP image.

func (*BaseGUMP) InsertLine

func (g *BaseGUMP) InsertLine(l string) int

InsertLine adds l to the GUMP's list of text lines and returns the reference number.

func (*BaseGUMP) InvalidateLayout

func (g *BaseGUMP) InvalidateLayout()

InvalidateLayout implements the GUMP interface.

func (*BaseGUMP) Item

func (g *BaseGUMP) Item(x, y int, item uo.Graphic, hue uo.Hue)

Item places an item graphic.

func (*BaseGUMP) Label

func (g *BaseGUMP) Label(x, y int, hue uo.Hue, text string)

Label places text on the GUMP. NOTE: Newline characters are not supported.

func (*BaseGUMP) NoClose

func (g *BaseGUMP) NoClose()

NoClose flags the GUMP as not closable with right-click.

func (*BaseGUMP) NoDispose

func (g *BaseGUMP) NoDispose()

NoDispose flags the GUMP as not closable with the escape key. This is the default for most GUMPs.

func (*BaseGUMP) NoMove

func (g *BaseGUMP) NoMove()

NoMove disables the ability to close the GUMP to be moved on screen.

func (*BaseGUMP) NoResize

func (g *BaseGUMP) NoResize()

NoResize disables the ability to resize certain GUMPs.

func (*BaseGUMP) Packet

func (g *BaseGUMP) Packet(x, y int, sender, typeCode uo.Serial) serverpacket.Packet

Packet implements the GUMP interface.

func (*BaseGUMP) Page

func (g *BaseGUMP) Page(page uint32)

Page begins the numbered page.

func (*BaseGUMP) PageButton

func (g *BaseGUMP) PageButton(x, y int, normal, pressed uo.GUMP, page uint32)

PageButton creates a button that will change pages.

func (*BaseGUMP) RadioButton

func (g *BaseGUMP) RadioButton(x, y int, normal, pressed uo.GUMP, id uint32, on bool)

RadioButton creates a radio button switch. See Group and EndGroup.

func (*BaseGUMP) ReplyButton

func (g *BaseGUMP) ReplyButton(x, y int, normal, pressed uo.GUMP, id uint32)

ReplyButton creates a button that will generate a reply packet.

func (*BaseGUMP) SetTypeCode

func (g *BaseGUMP) SetTypeCode(c uo.Serial)

SetTypeCode implements the GUMP interface.

func (*BaseGUMP) TextEntry

func (g *BaseGUMP) TextEntry(x, y, w, h int, hue uo.Hue, text string, limit int, id uint32)

TextEntry creates a text entry area. If limit is less than 1 no limit will be enforced.

func (*BaseGUMP) TiledImage

func (g *BaseGUMP) TiledImage(x, y, w, h int, gump uo.GUMP)

TiledImage places a tiled GUMP image.

func (*BaseGUMP) TypeCode

func (g *BaseGUMP) TypeCode() uo.Serial

TypeCode implements the GUMP interface.

type GUMP

type GUMP interface {
	// Layout executes all of the layout functions that comprise this GUMP.
	// Must be called before Packet().
	Layout(target, param game.Object)
	// InvalidateLayout resets the internal state so that Layout() may be called
	// again.
	InvalidateLayout()
	// Packet returns a newly created serverpacket.Packet for this GUMP.
	Packet(x, y int, sender, serial uo.Serial) serverpacket.Packet
	// HandleReply is called to process all replies for this GUMP. HandleReply
	// is not expected to handle GUMP close requests. The server keeping track
	// of open GUMPs should do that. Additionally the server needs to call
	// Layout again and send the new GUMP packet back to the client.
	HandleReply(n game.NetState, p *clientpacket.GUMPReply)
	// TypeCode returns the GUMP's type code.
	TypeCode() uo.Serial
	// SetTypeCode sets the GUMP's type code.
	SetTypeCode(uo.Serial)
}

GUMP is the interface all GUMP objects implement.

func New

func New(name string) GUMP

New creates a new GUMP by name

type SGFlag

type SGFlag uint8

SGFlag describes the flags that a StandardGUMP object understands.

const (
	SGFlagNoClose       SGFlag = 0b00000001 // Prevent the GUMP from closing
	SGFlagNoMinimize    SGFlag = 0b00000010 // Does not support minimizing
	SGFlagNoPageButtons SGFlag = 0b00000100 // Do not generate page buttons
	SGFlagNoMove        SGFlag = 0b00001000 // Do not allow GUMP to be moved
)

type SGGemButton

type SGGemButton uint8

SGGemButton is an enumeration of the available gem buttons available to the GemButton() function.

const (
	SGGemButtonOptions   SGGemButton = 0
	SGGemButtonLogOut    SGGemButton = 1
	SGGemButtonJournal   SGGemButton = 2
	SGGemButtonSkills    SGGemButton = 3
	SGGemButtonChat      SGGemButton = 4
	SGGemButtonPeace     SGGemButton = 5
	SGGemButtonWar       SGGemButton = 6
	SGGemButtonStatus    SGGemButton = 7
	SGGemButtonCharacter SGGemButton = 8
	SGGemButtonHelp      SGGemButton = 9
	SGGemButtonAuto      SGGemButton = 10
	SGGemButtonManual    SGGemButton = 11
	SGGemButtonCancel    SGGemButton = 12
	SGGemButtonApply     SGGemButton = 13
	SGGemButtonDefault   SGGemButton = 14
	SGGemButtonOK        SGGemButton = 15
	SGGemButtonStrategy  SGGemButton = 16
	SGGemButtonAdd       SGGemButton = 17
	SGGemButtonDelete    SGGemButton = 18
)

All valid values for SGGemButton

type StandardGUMP

type StandardGUMP struct {
	// contains filtered or unexported fields
}

StandardGUMP provides a set of layout methods built on top of BaseGUMP's layout methods that make it a little more convenient to build GUMPs with the standard theme. The methods of this struct accept coordinates and dimensions in cells, not pixels. A cell is 32x32 pixels.

func (*StandardGUMP) CheckSwitch

func (g *StandardGUMP) CheckSwitch(x, y, w, h int, hue uo.Hue, text string, id uint32, checked bool)

CheckSwitch creates a checkbox element with a numbered switch and a label.

func (*StandardGUMP) CheckedReplyButton

func (g *StandardGUMP) CheckedReplyButton(x, y, w, h int, hue uo.Hue, text string, id uint32)

CheckedReplyButton creates a small gem button with the text to the right. The dimensions given are for the total width including the button. This means that the text is cropped to an area w-1xh. This button will generate a GUMP reply packet and close the GUMP. This differs from ReplyButton in that the gem button will contain a check mark.

func (*StandardGUMP) DebugCheckBackground

func (g *StandardGUMP) DebugCheckBackground()

DebugCheckBackground creates a checked background to illustrate the size and position of each cell.

func (*StandardGUMP) GemButton

func (g *StandardGUMP) GemButton(x, y int, which SGGemButton, id uint32)

GemButton creates a standardized button from the gem theme with a word baked into the button image. The button is always two cells wide by one cell tall.

func (*StandardGUMP) Group

func (g *StandardGUMP) Group()

Group starts a new RadioSwitch group.

func (*StandardGUMP) HTML

func (g *StandardGUMP) HTML(x, y, w, h int, html string, scrollbar bool)

HTML creates an HTML view without background.

func (*StandardGUMP) HorizontalBar

func (g *StandardGUMP) HorizontalBar(x, y, w int)

HorizontalBar creates a horizontal element within the background that may be used to separate vertical sections of a GUMP.

func (*StandardGUMP) Image

func (g *StandardGUMP) Image(x, y, v, h int, hue uo.Hue, id uo.GUMP)

Image places the given GUMP image at the location with the given offsets.

func (*StandardGUMP) InvalidateLayout

func (g *StandardGUMP) InvalidateLayout()

InvalidateLayout implements the GUMP interface.

func (*StandardGUMP) Item

func (g *StandardGUMP) Item(x, y, v, h int, hue uo.Hue, id uo.Graphic)

Item places the given item image at the location with the given offsets.

func (*StandardGUMP) Packet

func (g *StandardGUMP) Packet(x, y int, sender, typeCode uo.Serial) serverpacket.Packet

Packet implements the GUMP interface.

func (*StandardGUMP) PageButton

func (g *StandardGUMP) PageButton(x, y, w, h int, hue uo.Hue, text string, page uint32)

PageButton creates a small gem button with the text to the right. The dimensions given are for the total width including the button. This means that the text is cropped to an area w-1xh. This button will hide the currently visible page and show the indicated page. No packets are generated. The standard scroll interface has page buttons included on the right-hand side of the scroll that can be used to sequentially cycle through the pages forward and backward. Only use this function if a different use case is required.

func (*StandardGUMP) RadioSwitch

func (g *StandardGUMP) RadioSwitch(x, y, w, h int, hue uo.Hue, text string, id uint32, checked bool)

RadioSwitch creates a radio button element with a numbered switch and a label.

func (*StandardGUMP) ReplyButton

func (g *StandardGUMP) ReplyButton(x, y, w, h int, hue uo.Hue, text string, id uint32)

ReplyButton creates a small gem button with the text to the right. The dimensions given are for the total width including the button. This means that the text is cropped to an area w-1xh. This button will generate a GUMP reply packet and close the GUMP.

func (*StandardGUMP) Separator

func (g *StandardGUMP) Separator(y int)

Separator like HorizontalBar but forces the bar to cover the entire width of the GUMP.

func (*StandardGUMP) SetTypeCode

func (g *StandardGUMP) SetTypeCode(c uo.Serial)

SetTypeCode implements the GUMP interface.

func (*StandardGUMP) StandardReplyHandler

func (g *StandardGUMP) StandardReplyHandler(p *clientpacket.GUMPReply) bool

StandardReplyHandler returns true if the reply was totally handled by this function and should be ignored. This function alters the packet in ways required for the proper function of the GUMP, therefore this function must be called first thing in any HandleReply function.

func (*StandardGUMP) Text

func (g *StandardGUMP) Text(x, y, w int, hue uo.Hue, text string)

Text creates a cropped label element. Text elements are always one line tall and do not respect newlines. If more functionality is needed see HTML().

func (*StandardGUMP) TextEntry

func (g *StandardGUMP) TextEntry(x, y, w int, hue uo.Hue, text string, limit int, id uint32)

TextEntry creates a text entry element. Text entries are always one line tall and does not support newlines. The width of the text entry must be at least 2.

func (*StandardGUMP) TypeCode

func (g *StandardGUMP) TypeCode() uo.Serial

TypeCode implements the GUMP interface.

func (*StandardGUMP) Window

func (g *StandardGUMP) Window(w, h int, title string, flags SGFlag, numPages uint32)

Window creates a new Window for the GUMP. Window dimensions are given in cells and specifies the inner size of the window. If closable is true a close button is generated and the GUMP may be closed with right-clicking and - in some situations - the escape key. If minimizeable is true a minimize button is generated and the GUMP will have minimize behavior. If pageButtons is true page buttons are generated for every page.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL