Пример #1
0
// NewFonts returns a new instance of Fonts.
func NewFonts(library io.StoreLibrary) (fonts *Fonts, err error) {
	var gamescr chunk.Store

	gamescr, err = library.ChunkStore("gamescr.res")

	if err == nil {
		fonts = &Fonts{gamescr: gamescr}
	}

	return
}
Пример #2
0
func NewPalettes(library io.StoreLibrary) (palettes *Palettes, err error) {
	var gamepal chunk.Store

	gamepal, err = library.ChunkStore("gamepal.res")

	if err == nil {
		palettes = &Palettes{gamepal: gamepal}
	}

	return
}
Пример #3
0
// NewArchive creates a new archive wrapper for given store name. This wrapper is
// applicable for the "starting game" archive, as well as savegames.
func NewArchive(library io.StoreLibrary, storeName string) (archive *Archive, err error) {
	var store chunk.Store

	store, err = library.ChunkStore(storeName)

	if err == nil {
		archive = &Archive{store: store}
	}

	return
}
Пример #4
0
func NewTextures(library io.StoreLibrary) (textures *Textures, err error) {
	var cybstrng [model.LanguageCount]chunk.Store
	var images chunk.Store

	for i := 0; i < model.LanguageCount && err == nil; i++ {
		cybstrng[i], err = library.ChunkStore(localized[i].cybstrng)
	}
	if err == nil {
		images, err = library.ChunkStore("texture.res")
	}

	if err == nil {
		textures = &Textures{cybstrng: cybstrng, images: images, cp: text.DefaultCodepage()}
	}

	return
}
Пример #5
0
// NewGameObjects returns a new instance of GameObjects.
func NewGameObjects(library io.StoreLibrary) (gameObjects *GameObjects, err error) {
	var cybstrng [model.LanguageCount]chunk.Store
	var objart chunk.Store
	var objProperties objprop.Store

	if err == nil {
		objart, err = library.ChunkStore("objart.res")
	}
	if err == nil {
		objProperties, err = library.ObjpropStore("objprop.dat")
	}
	for i := 0; i < model.LanguageCount && err == nil; i++ {
		cybstrng[i], err = library.ChunkStore(localized[i].cybstrng)
	}
	if err == nil {
		gameObjects = &GameObjects{
			cybstrng:       cybstrng,
			cp:             text.DefaultCodepage(),
			desc:           objprop.StandardProperties(),
			objProperties:  objProperties,
			objart:         objart,
			objIconOffsets: make(map[res.ObjectID]int),
			mapIconOffsets: make(map[res.ObjectID]int)}

		offset := 1
		for classIndex, classDesc := range gameObjects.desc {
			for subclassIndex, subclassDesc := range classDesc.Subclasses {
				for typeIndex := uint32(0); typeIndex < subclassDesc.TypeCount; typeIndex++ {
					objID := res.MakeObjectID(res.ObjectClass(classIndex), res.ObjectSubclass(subclassIndex), res.ObjectType(typeIndex))
					commonProperties := gameObjects.commonProperties(objID)
					extraImages := int(commonProperties.Extra >> 4)

					gameObjects.objIconOffsets[objID] = offset
					offset = offset + 3 + extraImages
					gameObjects.mapIconOffsets[objID] = offset - 1
				}
			}
		}
	}

	return
}