This repository has been archived by the owner on Jul 28, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
49 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package model | ||
|
||
import ( | ||
"fmt" | ||
) | ||
|
||
// ResourceKey is the reference of a specific game resource. | ||
type ResourceKey struct { | ||
Type ResourceType | ||
Index uint16 | ||
} | ||
|
||
// MakeResourceKey returns a combined resource identifier. | ||
func MakeResourceKey(resourceType ResourceType, index uint16) ResourceKey { | ||
return ResourceKey{resourceType, index} | ||
} | ||
|
||
// ResourceKeyFromInt returns a resource identifier wrapping the provided integer. | ||
func ResourceKeyFromInt(value int) ResourceKey { | ||
return ResourceKey{ | ||
Type: ResourceType(uint16((value >> 16) & 0xFFFF)), | ||
Index: uint16(value & 0xFFFF)} | ||
} | ||
|
||
// ToInt returns a single integer representation of the ID. | ||
func (id ResourceKey) ToInt() int { | ||
return (int(id.Type) << 16) | int(id.Index) | ||
} | ||
|
||
// String implements the Stringer interface. | ||
func (id ResourceKey) String() string { | ||
return fmt.Sprintf("0x%04X:%03d", uint16(id.Type), id.Index) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package model | ||
|
||
// ResourceType is an enumeration of resource clusters. | ||
type ResourceType uint16 | ||
|
||
const ( | ||
// ResourceTypeMfdDataImages refers to the bitmaps used in the MFD data displays, such as logs. | ||
ResourceTypeMfdDataImages = ResourceType(0x0028) | ||
) |