MCPcopy Create free account
hub / github.com/DescentDevelopers/Descent3 / Load

Method Load

Descent3/newui_core.cpp:714–772  ·  view source on GitHub ↗

loads bitmap and returns the object

Source from the content-addressed store, hash-verified

712
713// loads bitmap and returns the object
714UIBitmapItem *newuiResources::Load(const char *filename) {
715 UIBitmapItem *bmitem;
716 int i, free_slot = -1;
717
718 // do search for bitmap.
719 for (i = 0; i < N_NEWUI_BMPS_TOTAL; i++) {
720 if (m_list[i].n_count == 0) {
721 if (free_slot == -1) {
722 free_slot = i;
723 }
724 } else {
725 if (stricmp(filename, m_list[i].filename) == 0) {
726 break;
727 }
728 }
729 }
730 if (i == N_NEWUI_BMPS_TOTAL) {
731 // perform load.
732 int bm, chw, chh;
733
734 if (free_slot == -1) {
735 // reached limit.
736 Int3();
737 return NULL;
738 }
739 i = free_slot;
740
741 bm = bm_AllocLoadFileBitmap(IGNORE_TABLE(filename), 0);
742 if (bm < 0) {
743 Error("NewUI: Failed to load bitmap %s", filename);
744 }
745
746 chw = bm_w(bm, 0);
747 chh = bm_h(bm, 0);
748
749 if ((chw == 32 && chh == 32) || (chw == 64 && chh == 64) || (chw == 128 && chh == 128)) {
750 m_list[i].bm_handle = bm;
751 m_list[i].chunked = 0;
752 } else {
753 // chunk it.
754 bm_CreateChunkedBitmap(bm, &m_list[i].chunk);
755 bm_FreeBitmap(bm);
756 m_list[i].chunked = 1;
757 }
758
759 m_list[i].n_count = 0;
760 m_list[i].filename = mem_strdup(filename);
761 }
762
763 m_list[i].n_count++;
764
765 if (m_list[i].chunked) {
766 bmitem = new UIBitmapItem(&m_list[i].chunk);
767 } else {
768 bmitem = new UIBitmapItem(m_list[i].bm_handle);
769 }
770
771 return bmitem;

Callers 3

newui_LoadBitmapFunction · 0.45
CreateMethod · 0.45
InitStatesMethod · 0.45

Calls 6

bm_AllocLoadFileBitmapFunction · 0.85
ErrorFunction · 0.85
bm_wFunction · 0.85
bm_hFunction · 0.85
bm_CreateChunkedBitmapFunction · 0.85
bm_FreeBitmapFunction · 0.85

Tested by

no test coverage detected