1- package ui
1+ // Package infowindow provides a window for displaying information about Eve objects.
2+ package infowindow
23
34import (
45 "context"
@@ -109,7 +110,8 @@ type Settings interface {
109110 PreferMarketTab () bool
110111}
111112
112- // InfoWindow represents a dedicated window for showing information similar to the in-game info windows.
113+ // InfoWindow represents a dedicated window for showing information about Eve objects
114+ // similar to the in-game info window.
113115type InfoWindow struct {
114116 cs CS
115117 eis EIS
@@ -125,50 +127,64 @@ type InfoWindow struct {
125127 w fyne.Window
126128}
127129
128- type InfoWindowParams struct {
129- cs CS
130- eis EIS
131- eus EUS
132- isMobile bool
133- js * janiceservice.JaniceService
134- scs SCS
135- settings Settings
136- u UIService
137- w fyne.Window
130+ type Params struct {
131+ CharacterService CS
132+ EveImageService EIS
133+ EveUniverseService EUS
134+ IsMobile bool
135+ JaniceService * janiceservice.JaniceService
136+ StatusCacheService SCS
137+ Settings Settings
138+ UIService UIService
139+ Window fyne.Window
138140}
139141
140- // NewInfoWindow returns a configured InfoWindow.
141- func NewInfoWindow (arg InfoWindowParams ) * InfoWindow {
142+ // New returns a configured InfoWindow.
143+ func New (arg Params ) * InfoWindow {
142144 iw := & InfoWindow {
143- cs : arg .cs ,
144- eis : arg .eis ,
145- eus : arg .eus ,
146- isMobile : arg .isMobile ,
147- js : arg .js ,
148- scs : arg .scs ,
149- settings : arg .settings ,
150- u : arg .u ,
151- w : arg .w ,
145+ cs : arg .CharacterService ,
146+ eis : arg .EveImageService ,
147+ eus : arg .EveUniverseService ,
148+ isMobile : arg .IsMobile ,
149+ js : arg .JaniceService ,
150+ scs : arg .StatusCacheService ,
151+ settings : arg .Settings ,
152+ u : arg .UIService ,
153+ w : arg .Window ,
154+ }
155+ if iw .cs == nil ||
156+ iw .eis == nil ||
157+ iw .eus == nil ||
158+ iw .js == nil ||
159+ iw .scs == nil ||
160+ iw .settings == nil ||
161+ iw .u == nil ||
162+ iw .w == nil {
163+ panic (app .ErrInvalid )
152164 }
153165 return iw
154166}
155167
156168// ShowEveEntity shows a new info window for an EveEntity.
157169func (iw * InfoWindow ) ShowEveEntity (ee * app.EveEntity ) {
158- iw .show (eveEntity2InfoVariant (ee ), int64 ( ee .ID ) )
170+ iw .show (eveEntity2InfoVariant (ee ), ee .ID )
159171}
160172
161173// Show shows a new info window for an EveEntity.
162174func (iw * InfoWindow ) Show (c app.EveEntityCategory , id int64 ) {
163- iw .show (eveEntity2InfoVariant (& app.EveEntity {Category : c }), int64 ( id ) )
175+ iw .show (eveEntity2InfoVariant (& app.EveEntity {Category : c }), id )
164176}
165177
166178func (iw * InfoWindow ) ShowLocation (id int64 ) {
167179 iw .show (infoLocation , id )
168180}
169181
170182func (iw * InfoWindow ) ShowRace (id int64 ) {
171- iw .show (infoRace , int64 (id ))
183+ iw .show (infoRace , id )
184+ }
185+
186+ func (iw * InfoWindow ) ShowTypeWithCharacter (typeID , characterID int64 ) {
187+ iw .showWithCharacterID (infoInventoryType , typeID , characterID )
172188}
173189
174190// infoWidget defines common functionality for all info widgets.
@@ -219,30 +235,30 @@ func (iw *InfoWindow) showWithCharacterID(v infoVariant, entityID int64, charact
219235 switch v {
220236 case infoAlliance :
221237 title = "Alliance"
222- page = newAllianceInfo (iw , int64 ( entityID ) )
238+ page = newAllianceInfo (iw , entityID )
223239 case infoCharacter :
224240 title = "Character"
225- page = newCharacterInfo (iw , int64 ( entityID ) )
241+ page = newCharacterInfo (iw , entityID )
226242 case infoConstellation :
227243 title = "Constellation"
228- page = newConstellationInfo (iw , int64 ( entityID ) )
244+ page = newConstellationInfo (iw , entityID )
229245 case infoCorporation :
230246 title = "Corporation"
231- page = newCorporationInfo (iw , int64 ( entityID ) )
247+ page = newCorporationInfo (iw , entityID )
232248 case infoInventoryType :
233- x := newInventoryTypeInfo (iw , int64 ( entityID ) , characterID )
249+ x := newInventoryTypeInfo (iw , entityID , characterID )
234250 x .setTitle = func (s string ) { ab .SetTitle (makeAppBarTitle (s )) }
235251 page = x
236252 title = "Item"
237253 case infoRace :
238254 title = "Race"
239- page = newRaceInfo (iw , int64 ( entityID ) )
255+ page = newRaceInfo (iw , entityID )
240256 case infoRegion :
241257 title = "Region"
242- page = newRegionInfo (iw , int64 ( entityID ) )
258+ page = newRegionInfo (iw , entityID )
243259 case infoSolarSystem :
244260 title = "Solar System"
245- page = newSolarSystemInfo (iw , int64 ( entityID ) )
261+ page = newSolarSystemInfo (iw , entityID )
246262 case infoLocation :
247263 title = "Location"
248264 page = newLocationInfo (iw , entityID )
@@ -295,7 +311,7 @@ func (iw *InfoWindow) showWithCharacterID(v infoVariant, entityID int64, charact
295311 }()
296312}
297313
298- func (iw * InfoWindow ) showZoomWindow (title string , id int64 , load loadFuncAsync , w fyne.Window ) {
314+ func (iw * InfoWindow ) showZoomWindow (title string , id int64 , load func ( int64 , int , func (fyne. Resource )) , w fyne.Window ) {
299315 w2 , created := iw .u .GetOrCreateWindow (fmt .Sprintf ("zoom-window-%d" , id ), title )
300316 if ! created {
301317 w2 .Show ()
@@ -458,7 +474,7 @@ func eveEntity2InfoVariant(ee *app.EveEntity) infoVariant {
458474
459475}
460476
461- func infoWindowSupportedEveEntities () set.Set [app.EveEntityCategory ] {
477+ func InfoWindowSupportedEveEntities () set.Set [app.EveEntityCategory ] {
462478 return set .Collect (maps .Keys (eveEntityCategory2InfoVariant ))
463479
464480}
@@ -1290,7 +1306,7 @@ func (a *locationInfo) update(ctx context.Context) error {
12901306 if o .Variant () != app .EveLocationStation {
12911307 return nil
12921308 }
1293- ss , err := a .iw .eus .GetStationServicesESI (ctx , int64 ( a .id ) )
1309+ ss , err := a .iw .eus .GetStationServicesESI (ctx , a .id )
12941310 if err != nil {
12951311 return err
12961312 }
@@ -2284,7 +2300,7 @@ func (a *inventoryTypeInfo) makeRequirementsTab(requiredSkills []requiredSkill)
22842300 list .OnSelected = func (id widget.ListItemID ) {
22852301 defer list .UnselectAll ()
22862302 r := requiredSkills [id ]
2287- a .iw .show (infoInventoryType , int64 ( r .typeID ) )
2303+ a .iw .show (infoInventoryType , r .typeID )
22882304 }
22892305 return container .NewTabItem ("Requirements" , list )
22902306}
@@ -2453,7 +2469,7 @@ func (w *attributeList) set(items []attributeItem) {
24532469}
24542470
24552471func (w * attributeList ) CreateRenderer () fyne.WidgetRenderer {
2456- supportedCategories := infoWindowSupportedEveEntities ()
2472+ supportedCategories := InfoWindowSupportedEveEntities ()
24572473 l := widget .NewList (
24582474 func () int {
24592475 return len (w .items )
@@ -2609,7 +2625,7 @@ func newEntityItem(id int64, category, text string, v infoVariant) entityItem {
26092625
26102626func newEntityItemFromEvePlanet (o * app.EvePlanet ) entityItem {
26112627 return entityItem {
2612- id : int64 ( o .ID ) ,
2628+ id : o .ID ,
26132629 category : "Planet" ,
26142630 text : o .Name ,
26152631 infoVariant : infoNotSupported ,
@@ -2619,22 +2635,22 @@ func newEntityItemFromEvePlanet(o *app.EvePlanet) entityItem {
26192635func newEntityItemFromEveSolarSystem (o * app.EveSolarSystem ) entityItem {
26202636 ee := o .EveEntity ()
26212637 return entityItem {
2622- id : int64 ( ee .ID ) ,
2638+ id : ee .ID ,
26232639 category : ee .CategoryDisplay (),
26242640 textSegments : o .DisplayRichText (),
26252641 infoVariant : eveEntity2InfoVariant (ee ),
26262642 }
26272643}
26282644
26292645func newEntityItemFromEveEntity (ee * app.EveEntity ) entityItem {
2630- return newEntityItem (int64 ( ee .ID ) , ee .CategoryDisplay (), ee .Name , eveEntity2InfoVariant (ee ))
2646+ return newEntityItem (ee .ID , ee .CategoryDisplay (), ee .Name , eveEntity2InfoVariant (ee ))
26312647}
26322648
26332649func newEntityItemFromEveEntityWithText (ee * app.EveEntity , text string ) entityItem {
26342650 if text == "" {
26352651 text = ee .Name
26362652 }
2637- return newEntityItem (int64 ( ee .ID ) , ee .CategoryDisplay (), text , eveEntity2InfoVariant (ee ))
2653+ return newEntityItem (ee .ID , ee .CategoryDisplay (), text , eveEntity2InfoVariant (ee ))
26382654}
26392655
26402656// entityList is a list widget for showing entities.
0 commit comments