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

Method SetContents

card.go:2309–2384  ·  view source on GitHub ↗
(contentType string)

Source from the content-addressed store, hash-verified

2307}
2308
2309func (card *Card) SetContents(contentType string) {
2310
2311 if contentType == ContentTypeNull {
2312 return
2313 }
2314
2315 prevContents := card.Contents
2316
2317 if existingContents, exists := card.ContentsLibrary[contentType]; exists {
2318 card.Contents = existingContents
2319 } else {
2320
2321 for _, prop := range card.Properties.Props {
2322 prop.InUse = false
2323 }
2324
2325 switch contentType {
2326 case ContentTypeCheckbox:
2327 card.Contents = NewCheckboxContents(card)
2328 case ContentTypeNumbered:
2329 card.Contents = NewNumberedContents(card)
2330 case ContentTypeNote:
2331 card.Contents = NewNoteContents(card)
2332 case ContentTypePinboard:
2333 card.Contents = NewPinboardContents(card)
2334 case ContentTypeSound:
2335 card.Contents = NewSoundContents(card)
2336 case ContentTypeImage:
2337 card.Contents = NewImageContents(card)
2338 case ContentTypeTimer:
2339 card.Contents = NewTimerContents(card)
2340 case ContentTypeMap:
2341 card.Contents = NewMapContents(card)
2342 case ContentTypeSubpage:
2343 card.Contents = NewSubPageContents(card)
2344 case ContentTypeLink:
2345 card.Contents = NewLinkContents(card)
2346 case ContentTypeTable:
2347 card.Contents = NewTableContents(card)
2348 case ContentTypeInternet:
2349 webCard := NewInternetContents(card)
2350 if webCard == nil {
2351 // Web card couldn't be created, probably because of browser shenanigans
2352 card.Contents = NewCheckboxContents(card)
2353 } else {
2354 card.Contents = webCard
2355 }
2356 default:
2357 panic("Creation of card contents that haven't been implemented: " + contentType)
2358 }
2359
2360 w := card.Rect.W
2361 if w <= 0 {
2362 w = card.Contents.DefaultSize().X
2363 }
2364 h := card.Rect.H
2365 if h <= 0 {
2366 h = card.Contents.DefaultSize().Y

Callers 5

HandleDroppedFilesMethod · 0.95
NewCardFunction · 0.95
DeserializeMethod · 0.95
UpdateTextureMethod · 0.80
ConstructMenusFunction · 0.80

Calls 15

RecreateMethod · 0.95
NewCheckboxContentsFunction · 0.85
NewNumberedContentsFunction · 0.85
NewNoteContentsFunction · 0.85
NewPinboardContentsFunction · 0.85
NewSoundContentsFunction · 0.85
NewImageContentsFunction · 0.85
NewTimerContentsFunction · 0.85
NewMapContentsFunction · 0.85
NewSubPageContentsFunction · 0.85
NewLinkContentsFunction · 0.85
NewTableContentsFunction · 0.85

Tested by

no test coverage detected