LRESULT CALLBACK EditBoxChanged(HWND hwnd,UINT message, WPARAM wParam, LPARAM lParam,UINT_PTR uIdSubclass, DWORD_PTR dwRefData) { char formel[255]; switch(message) { case WM_CHAR: switch(wParam) { case VK_RETURN: // Formel überprüfen und hinzufügen, wenn korrekt GetWindowText(items[3].handle,formel,255); if(strlen(formel) > 0) { INFO("Füge Formel zum Verlauf hinzu!"); list[getListCount(items[4].handle)].text = malloc(sizeof(char*) * 255); strcpy(list[getListCount(items[4].handle)].text,formel); SendMessage(items[4].handle,LB_ADDSTRING,(WPARAM) NULL,(LONG)formel); int Count = getListCount(items[4].handle); sprintf(formel,"Einträge: %d",Count); SetWindowText(items[1].handle,formel); SetWindowText(hwnd,""); if(PostThreadMessage(ThreadIds[0],TH_HANDLE,0x0,0x0) == FALSE) { ERR("Nachricht konnte nicht gesendet werden!"); } return TRUE; } else { WARN("Es wurde versucht eine leere Formel einzugeben!"); MessageBox(hwnd,"Leere Formeln werden nicht akzeptiert!","Formeleingabe", MB_ICONEXCLAMATION | MB_OK); SetFocus(items[3].handle); return false; } break; }; break; } return DefSubclassProc(hwnd,message,wParam,lParam); }
void GFF4Struct::loadStructs(GFF4File &parent, Field &field) { if (field.offset == 0xFFFFFFFF) return; const GFF4File::StructTemplate &tmplt = parent.getStructTemplate(field.structIndex); Common::SeekableReadStream &data = parent.getStream(field.offset); const uint32 structCount = getListCount(data, field); const uint32 structSize = field.isReference ? 4 : tmplt.size; const uint32 structStart = data.pos(); field.structs.resize(structCount, 0); for (uint32 i = 0; i < structCount; i++) { const uint32 offset = getDataOffset(field.isReference, structStart + i * structSize); if (offset == 0xFFFFFFFF) continue; GFF4Struct *strct = parent.findStruct(generateID(offset, &tmplt)); if (!strct) strct = new GFF4Struct(parent, offset, tmplt); strct->_refCount++; field.structs[i] = strct; } }
bool GFF4Struct::getTalkString(uint32 field, Common::Encoding encoding, std::vector<uint32> &strRefs, std::vector<Common::UString> &strs) const { const Field *f; Common::SeekableReadStream *data = getField(field, f); if (!data) return false; if (f->type != kIFieldTypeTlkString) throw Common::Exception("GFF4: Field is not of TalkString type"); const uint32 count = getListCount(*data, *f); strRefs.resize(count); strs.resize(count); std::vector<uint32> offsets; offsets.resize(count); for (uint32 i = 0; i < count; i++) { strRefs[i] = getUint(*data, kIFieldTypeUint32); const uint32 offset = getUint(*data, kIFieldTypeUint32); if ((offset != 0xFFFFFFFF) && (offset != 0)) strs[i] = getString(*data, encoding, _parent->getDataOffset() + offset); } return true; }
/* * Do some basic list manipulations and output to log for * script comparison. Only testing the macros we use. */ int main(int argc, char *argv[]) { PTEST_NODE pNode = NULL; START(argc, argv, "win_lists"); LIST_INIT(&TestListHead); UT_ASSERT_rt(LIST_EMPTY(&TestListHead)); pNode = allocNode(); pNode->dummy = 0; LIST_INSERT_HEAD(&TestListHead, pNode, ListEntry); UT_ASSERTeq_rt(1, getListCount()); dump_list(); /* Remove one node */ LIST_REMOVE(pNode, ListEntry); UT_ASSERTeq_rt(0, getListCount()); dump_list(); free(pNode); /* Add a bunch of nodes */ for (int i = 1; i < 10; i++) { pNode = allocNode(); pNode->dummy = i; LIST_INSERT_HEAD(&TestListHead, pNode, ListEntry); } UT_ASSERTeq_rt(9, getListCount()); dump_list(); /* Remove all of them */ while (!LIST_EMPTY(&TestListHead)) { PTEST_NODE pNode = (PTEST_NODE)LIST_FIRST(&TestListHead); LIST_REMOVE(pNode, ListEntry); free(pNode); } UT_ASSERTeq_rt(0, getListCount()); dump_list(); DONE(NULL); }
float GFF4Struct::getFloat(uint32 field, std::vector<float> &list) const { const Field *f; Common::SeekableReadStream *data = getField(field, f); if (!data) return false; const uint32 count = getListCount(*data, *f); list.resize(count); for (uint32 i = 0; i < count; i++) list[i] = getFloat(*data, f->type); return true; }
Common::SeekableReadStream *GFF4Struct::getData(uint32 field) const { const Field *f; Common::SeekableReadStream *data = getField(field, f); if (!data) return 0; const uint32 count = getListCount(*data, *f); const uint32 size = getFieldSize(f->type); if ((size == 0) || (count == 0)) return 0; const uint32 dataBegin = data->pos(); const uint32 dataEnd = data->pos() + (count * size); return new Common::SeekableSubReadStream(data, dataBegin, dataEnd); }
bool GFF4Struct::getVectorMatrix(uint32 field, std::vector< std::vector<float> > &list) const { const Field *f; Common::SeekableReadStream *data = getField(field, f); if (!data) return false; const uint32 length = getVectorMatrixLength(*f, 16); const uint32 count = getListCount(*data, *f); list.resize(count); for (uint32 i = 0; i < count; i++) { list[i].resize(length); for (uint32 j = 0; j < length; j++) list[i][j] = getFloat(*data, kIFieldTypeFloat32); } return true; }
bool GFF4Struct::getString(uint32 field, Common::Encoding encoding, std::vector<Common::UString> &list) const { const Field *f; Common::SeekableReadStream *data = getField(field, f); if (!data) { if (f && !f->isList) { list.push_back(""); return true; } return false; } const uint32 count = getListCount(*data, *f); list.resize(count); for (uint32 i = 0; i < count; i++) list[i] = getString(*data, *f, encoding); return true; }