Skip to content
This repository has been archived by the owner on Jul 28, 2018. It is now read-only.

Commit

Permalink
added access to general bitmaps
Browse files Browse the repository at this point in the history
  • Loading branch information
dertseha committed Jun 14, 2017
1 parent 5e02346 commit 57c43a3
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 0 deletions.
7 changes: 7 additions & 0 deletions DataStore.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,13 @@ type DataStore interface {
// Font queries a specific font.
Font(projectID string, fontID int, onSuccess func(font *Font), onFailure FailureFunc)

// Bitmap queries the data of a bitmap resource.
Bitmap(projectID string, key ResourceKey,
onSuccess func(ResourceKey, *RawBitmap), onFailure FailureFunc)
// SetBitmap requests to set the data of a bitmap resource.
SetBitmap(projectID string, key ResourceKey, bmp *RawBitmap,
onSuccess func(ResourceKey, *RawBitmap), onFailure FailureFunc)

// GameObjects queries the basic properties of all objects in the project.
GameObjects(projectID string, onSuccess func(objects []GameObject), onFailure FailureFunc)
// GameObjectIcon queries the icon bitmap of a game object.
Expand Down
33 changes: 33 additions & 0 deletions ResourceKey.go
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)
}
9 changes: 9 additions & 0 deletions ResourceType.go
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)
)

0 comments on commit 57c43a3

Please sign in to comment.