MCPcopy Create free account
hub / github.com/SolarLune/masterplan / ReceiveMessage

Method ReceiveMessage

contents.go:3352–3386  ·  view source on GitHub ↗
(msg *Message)

Source from the content-addressed store, hash-verified

3350}
3351
3352func (mc *MapContents) ReceiveMessage(msg *Message) {
3353
3354 if msg.Type == MessageThemeChange || msg.Type == MessageRenderTextureRefresh {
3355 mc.UpdateTexture()
3356 } else if msg.Type == MessageUndoRedo {
3357
3358 // Recreate texture first so the MapData has the correct size before deserialization
3359 mc.RecreateTexture()
3360 if msg.Type == MessageUndoRedo {
3361 mc.MapData.Clip() // We call Clip() here so if you undo or redo and the size changes, values outside of that range are deleted
3362 }
3363 mc.MapData.Deserialize(mc.Card.Properties.Get("contents").AsString())
3364 mc.Card.Properties.Get("contents").SetRaw(mc.MapData.Serialize())
3365 mc.UpdateTexture()
3366
3367 } else if msg.Type == MessageCardResizeCompleted {
3368
3369 // Recreate texture first so the MapData has the correct size before deserialization
3370 mc.RecreateTexture()
3371
3372 px := mc.Card.RectPreResize.X - mc.Card.Rect.X
3373 py := mc.Card.RectPreResize.Y - mc.Card.Rect.Y
3374 if px != 0 || py != 0 {
3375 mc.MapData.Push(int(px/globals.GridSize), int(py/globals.GridSize), false)
3376 }
3377 mc.MapData.Clip() // We call Clip() here so if you undo or redo and the size changes, values outside of that range are deleted
3378
3379 mc.UpdateTexture()
3380
3381 } else if msg.Type == MessageContentSwitched {
3382 mc.Card.Draggable = true
3383 mc.Tool = MapEditToolNone
3384 }
3385
3386}
3387
3388func (mc *MapContents) Color() Color {
3389 return getThemeColor(GUIMapColor) // No color for maps

Callers

nothing calls this directly

Calls 9

UpdateTextureMethod · 0.95
RecreateTextureMethod · 0.95
ClipMethod · 0.80
AsStringMethod · 0.80
SetRawMethod · 0.80
PushMethod · 0.80
DeserializeMethod · 0.45
GetMethod · 0.45
SerializeMethod · 0.45

Tested by

no test coverage detected