LRESULT CEsmRefCellPage::OnRecordDrop (LPARAM lParam, LPARAM wParam) {
  DEFINE_FUNCTION("CEsmRefCellPage::OnRecordDrop()");
  CEsmCell*	  pCell = (CEsmCell *) m_pRecInfo->pRecord;
  CString	  Buffer;
  CMWEditDoc*     pSourceDoc = (CMWEditDoc *) lParam;
  esmrecinfo_t*   pRecInfo = (esmrecinfo_t *) wParam;
  CEsmSubCellRef* pNewCellRef;
  cellrefdata_t*  pCellRefData;

	/* Ensure we only drag from the current document */
  if (pSourceDoc != GetDocument()) return (0);
  
	/* Only accept certain types */
  if (!IsESMRecordModel(pRecInfo->pRecord->GetType())) return (0);
  //return (0);

	/* Add a new item to the cell */
  CreatePointer(pNewCellRef, CEsmSubCellRef);
  pNewCellRef->CreateNew((CEsmCell *) m_pRecInfo->pRecord);
  pNewCellRef->SetIsActive(true);
  pNewCellRef->SetIndex(pCell->GetNextRefIndex(), 0);
  pNewCellRef->SetRefName(pRecInfo->pRecord->GetID());

  pCellRefData = AddNewCellRef(pNewCellRef);

	/* Update the reference list */
  m_CellRefList.AddItem(pNewCellRef);
  return (0);
 }
void CEsmRefCellPage::OnCellrefCreatecopy() {
  DEFINE_FUNCTION("CEsmRefCellPage::OnCellrefDelete()");
  CEsmCell*	  pCell = (CEsmCell *) m_pRecInfo->pRecord;
  POSITION	  SelPos;
  CEsmSubCellRef* pOldCellRef;
  CEsmSubCellRef* pNewCellRef;
  cellrefdata_t*  pCellRefData;
  int		  SelectedIndex;
  
	/* Copy all selected records */
  SelPos = m_CellRefList.GetFirstSelectedItemPosition();

  while (SelPos != NULL) {
    SelectedIndex = m_CellRefList.GetNextSelectedItem(SelPos);
    pOldCellRef = (CEsmSubCellRef *) m_CellRefList.GetItemData(SelectedIndex);
    if (pOldCellRef == NULL) continue;

    CreatePointer(pNewCellRef, CEsmSubCellRef);
    pNewCellRef->Copy(pOldCellRef);
    pNewCellRef->SetIsActive(true);
    pNewCellRef->SetIndex(pCell->GetNextRefIndex(), 0);
    pCellRefData = AddNewCellRef(pNewCellRef);

	/* Update the reference list */
    m_CellRefList.AddItem(pNewCellRef);
   }

	/* Update the display */
  UpdateCellRefList();
 }
Пример #3
0
void CEsmActivatorDlg::GetControlData (void) {
  DEFINE_FUNCTION("CEsmActivatorDlg::GetControlData()");
  CString	Buffer;  
  
	/* Update the armor pointer and data */
  m_pActivator = (CEsmActivator *) GetRecInfo()->pRecord;
  ASSERT(m_pActivator != NULL);
  
	/* Armor ID, if changed */
  if (m_IDText.GetModify()) {
    m_IDText.GetWindowText(Buffer);
    m_pActivator->SetID(TrimStringSpace(Buffer));
   }

	/* Armor name */
  m_NameText.GetWindowText(Buffer);
  m_pActivator->SetName(TrimStringSpace(Buffer));

	/* Item script */
  m_ScriptList.GetWindowText(Buffer);
  m_pActivator->SetScript(TrimStringSpace(Buffer));
  	
	/* Model filename */
  m_ModelButton.GetWindowText(Buffer);
  m_pActivator->SetModel(TrimStringSpace(Buffer));

	/* Record flags */
  m_pActivator->SetPersist(m_PersistCheck.GetCheck() != 0);
  m_pActivator->SetBlocked(m_BlockedCheck.GetCheck() != 0);
 }
Пример #4
0
CEsmFile* CMWEditApp::LoadMaster (const TCHAR* pString, CEsmLoadDlg* pLoadDlg) {
  DEFINE_FUNCTION("CMWEditApp::LoadMaster()");
  CEsmFile* pFile;
  bool	    Result;

	/* Find an existing file */
  pFile = FindMaster(pString);

  if (pFile != NULL) {
    pLoadDlg->SetFilename(pString);
    pLoadDlg->SetProgress(100.0f);
    return (pFile);
   }
  
	/* Create a new file */  
  CreatePointer(pFile, CEsmFile);
  m_EsmMasters.Add(pFile);
  pFile->SetMaster(true);

	/* Progress dialog initialization */
  pLoadDlg->SetFilename(pString);
  pLoadDlg->SetSubLabel(_T("Loading..."));
  pLoadDlg->SetProgress(0.0f);
  pFile->SetCallback(g_EsmLoadDlgCallback, (long) pLoadDlg);

	/* Attempt to read the file */
  Result = pFile->Read(pString);

  if (!Result) {
    ErrorHandler.Notify("Master Read Error!");
   }
   
  return (pFile);

 }
cellrefdata_t* CEsmRefCellPage::CleanCellRef (CEsmSubCellRef* pCellRef) {
  DEFINE_FUNCTION("CEsmRefCellPage::CleanCellRef()");
  cellrefdata_t* pCellRefData;

	/* See if the record already exists in array */
  pCellRefData = FindNewCellRef(pCellRef);

  if (pCellRefData != NULL) {

		/* Delete a new reference sub-record outright */
    if (pCellRefData->IsNew) {
      m_ModCellRefs.DeleteElement(pCellRefData);
      DestroyPointer(pCellRefData->pNewCellRef);
      DestroyPointer(pCellRefData);
      return (pCellRefData);
     }
    
	/* Update the reference element to clean it */
    pCellRefData->Type = ESMCELLREF_MODTYPE_CLEAN;
    return (pCellRefData);
   }

	/* Add a new record to the modified array */
  CreatePointer(pCellRefData, cellrefdata_t);
  m_ModCellRefs.AddElement(pCellRefData);

	/* Initialize the new cell ref data */
  pCellRefData->IsNew = false;
  pCellRefData->Type  = ESMCELLREF_MODTYPE_CLEAN;
  pCellRefData->pNewCellRef = pCellRef;
  pCellRefData->pOldCellRef = pCellRef;

  return (pCellRefData);
 }
Пример #6
0
bool CEditUndoStack::GroupUndoInsertChar (CRichEditCtrl* pCtrl, CEditUndo* pUndo) {
  DEFINE_FUNCTION("CEditUndoStack::GroupUndoInsertChar()");
  int SelStart;
  int SelEnd;

  do {
    SelStart = pUndo->GetSelStart();
    SelEnd   = pUndo->GetSelEnd();

    pCtrl->SetSel(pUndo->GetSelStart(), pUndo->GetSelStart()+1);
    pCtrl->ReplaceSel(_T(""));
    pCtrl->SetSel(pUndo->GetSelStart(), pUndo->GetSelEnd());
    DestroyPointer(pUndo);

    pUndo = m_UndoStack.GetAt(m_UndoStack.GetNumElements() - 1);
    if (pUndo == NULL) break;

    if (pUndo->GetAction() != EDITUNDO_INSERTCHAR) break;
    if (!__iscsym(pUndo->GetChar())) break;
    if (abs(pUndo->GetSelStart() - SelStart) >= 2) break;

    m_UndoStack.DeleteElement(m_UndoStack.GetNumElements() - 1, false);
  } while (pUndo != NULL);

  return (true);
}
LRESULT CEsmRefCellPage::OnRecordEdit (LPARAM lParam, LPARAM wParam) {
  DEFINE_FUNCTION("CEsmRefCellPage::OnRecordEdit()");
  CEsmSubCellRef* pOldCellRef;
  CEsmSubCellRef* pNewCellRef;
  CEsmCellRefDlg  RefDialog;
  cellrefdata_t*  pCellRefData;
  bool		  Result;
  bool		  IsNew;
  bool		  NewAllocated;

	/* Ignore if no record currently selected */
  if (lParam < 0) return (0);
  pOldCellRef = (CEsmSubCellRef *) m_CellRefList.GetItemData(lParam);
  if (pOldCellRef == NULL) return (0);

	/* See if the reference record is already 'new' */
  pCellRefData = FindNewCellRef(pOldCellRef);

  if (pCellRefData == NULL) {
    if (pOldCellRef->IsDeleted()) return (0);
    IsNew = false;
    NewAllocated = true;
    CreatePointer(pNewCellRef, CEsmSubCellRef);
    pNewCellRef->Copy(pOldCellRef);
   }
  else {
    if (pOldCellRef->IsDeleted()) return (0);
    if (pCellRefData->Type == ESMCELLREF_MODTYPE_DEL) return (0);
    NewAllocated = false;
    IsNew = pCellRefData->IsNew;
    pNewCellRef = pCellRefData->pNewCellRef;
   }
  
	/* Display the modal edit dialogue */
  Result = RefDialog.DoModal(pNewCellRef, true, (CEsmCell *) m_pRecInfo->pRecord);

  if (!Result) {
    if (NewAllocated) {
      DestroyPointer(pNewCellRef);
     }
    return (0);
   }

	/* Create a new cell ref data record if required */ 
  if (pCellRefData == NULL) {
    pCellRefData = ModifyCellRef(pNewCellRef);
    pCellRefData->pOldCellRef = pOldCellRef;
    pNewCellRef->SetFRMRFlag(1);
   }
  else {
    pCellRefData->Type = ESMCELLREF_MODTYPE_MOD;
   }

	/* Update the display */
  UpdateCellRefList();
  return (0);
 }
Пример #8
0
 * Class CNifCopyDlg Method - void ClearCopyInfos (void);
 *
 * Unallocate any copy info records in the info array.
 *
 *=========================================================================*/
void CNifCopyDlg::ClearCopyInfos (void) {
  DEFINE_FUNCTION("CNifCopyDlg::ClearCopyInfos()");
  CNifCopyInfo* pCopyInfo;
  int		Index;

  for (Index = 0; Index < m_CopyInfos.GetNumElements(); Index++) {
    pCopyInfo = m_CopyInfos.GetAt(Index);
    DestroyPointer(pCopyInfo);
   }

  m_CopyInfos.RemoveAll();
 }
void CEsmRefCellPage::ClearCellRefArray (void) {
  DEFINE_FUNCTION("CEsmRefCellPage::ClearCellRefArray()");
  cellrefdata_t* pCellRefData;
  int		 Index;

  for (Index = 0; Index < m_ModCellRefs.GetSize(); Index++) {
    pCellRefData = m_ModCellRefs.GetAt(Index);
    DestroyPointer(pCellRefData);
   }

  m_ModCellRefs.RemoveAll();
 }
Пример #10
0
void CEditUndo::SetString (const TCHAR* pString) {
  DEFINE_FUNCTION("CEditUndo::SetString()");

  DestroyArrayPointer(m_pString);
  m_StringLength = 0;

  if (pString) {
    m_StringLength = _tcslen(pString);
    CreateArrayPointer(m_pString, TCHAR, m_StringLength + 4);
    strnncpy(m_pString, pString, m_StringLength+1);
  }

}
Пример #11
0
 *=========================================================================*/
CNifCopyInfo* CNifCopyDlg::AddCopyInfo (void) {
  DEFINE_FUNCTION("CNifCopyDlg::AddCopyInfo()");
  CNifCopyInfo* pNewInfo;

	/* Allocate the new pointer */
  CreatePointer(pNewInfo, CNifCopyInfo);
  m_CopyInfos.Add(pNewInfo);

	/* Initialize the new info */
  pNewInfo->CsvColIndex       = -1;
  pNewInfo->pSourceTexture    = NULL;
  pNewInfo->pMaterialProperty = NULL;

  return (pNewInfo);
 }
Пример #12
0
void CEsmRefCellPage::OnCellrefUndelete() {
  DEFINE_FUNCTION("CEsmRefCellPage::OnCellrefDelete()");
  POSITION	  SelPos;
  int		  SelectedIndex;
  
	/* Delete all selected records */
  SelPos = m_CellRefList.GetFirstSelectedItemPosition();

  while (SelPos != NULL) {
    SelectedIndex = m_CellRefList.GetNextSelectedItem(SelPos);
    DeleteIndex(SelectedIndex, false);
   }

	/* Update the display */
  UpdateCellRefList();
 }
Пример #13
0
cellrefdata_t* CEsmRefCellPage::AddNewCellRef (CEsmSubCellRef* pCellRef) {
  DEFINE_FUNCTION("CEsmRefCellPage::CleanCellRef()");
  cellrefdata_t* pCellRefData;

	/* Add a new record to the modified array */
  CreatePointer(pCellRefData, cellrefdata_t);
  m_ModCellRefs.AddElement(pCellRefData);

	/* Initialize the new cell ref data */
  pCellRefData->IsNew = true;
  pCellRefData->Type  = ESMCELLREF_MODTYPE_NEW;
  pCellRefData->pOldCellRef = NULL;
  pCellRefData->pNewCellRef = pCellRef;

  return (pCellRefData);
 }
Пример #14
0
void CEditUndoStack::CreateEntireText (const TCHAR* pString) {
  DEFINE_FUNCTION("CEditUndoStack::CreateDeleteString()");
  CEditUndo* pUndo;

  CreatePointer(pUndo, CEditUndo);
  m_UndoStack.Add(pUndo);

  pUndo->SetString(pString);
  pUndo->SetAction(EDITUNDO_ENTIRETEXT);
  pUndo->SetSelStart(0);
  pUndo->SetSelEnd(0);

  if (m_UndoStack.GetNumElements() > m_Limit) {
    m_UndoStack.DeleteElement(0);
  }
}
Пример #15
0
void CEditUndoStack::CreateDeleteString (const TCHAR* pString, const int StartSel, const int EndSel) {
  DEFINE_FUNCTION("CEditUndoStack::CreateDeleteString()");
  CEditUndo* pUndo;

  CreatePointer(pUndo, CEditUndo);
  m_UndoStack.Add(pUndo);

  pUndo->SetString(pString);
  pUndo->SetAction(EDITUNDO_DELETESTRING);
  pUndo->SetSelStart(StartSel);
  pUndo->SetSelEnd(EndSel);

  if (m_UndoStack.GetNumElements() > m_Limit) {
    m_UndoStack.DeleteElement(0);
  }
}
Пример #16
0
void CEditUndoStack::CreateInsertChar (const TCHAR Char, const int StartSel, const int EndSel) {
  DEFINE_FUNCTION("CEditUndoStack::CreateInsertChar()");
  CEditUndo* pUndo;

  CreatePointer(pUndo, CEditUndo);
  m_UndoStack.Add(pUndo);

  pUndo->SetChar(Char);
  pUndo->SetAction(EDITUNDO_INSERTCHAR);
  pUndo->SetSelStart(StartSel);
  pUndo->SetSelEnd(EndSel);

  if (m_UndoStack.GetNumElements() > m_Limit) {
    m_UndoStack.DeleteElement(0);
  }
}
Пример #17
0
void CEsmCreatureDlg::GetControlData (void) {
  DEFINE_FUNCTION("CEsmCreatureDlg::GetControlData()");
  CString	Buffer;  
  
	/* Update the armor pointer and data */
  m_pCreature = (CEsmCreature *) GetRecInfo()->pRecord;
  ASSERT(m_pCreature != NULL);

  	/* Object ID, if changed */
  if (m_IDText.GetModify()) {
    m_IDText.GetWindowText(Buffer);
    m_pCreature->SetID(TrimStringSpace(Buffer));
   }
  
  m_Page1.GetControlData();
  m_Page2.GetControlData();
  m_Page3.GetControlData();
  m_Page4.GetControlData();
  m_Page5.GetControlData();
 }
void CEsmBirthSignDlg::GetControlData (void) {
  DEFINE_FUNCTION("CEsmBirthSignDlg::GetControlData()");
  CEsmSubName32* pSpellRec;
  esmrecinfo_t*  pRecInfo;
  CString	 Buffer;  
  int		 Index;
  
	/* Update the armor pointer and data */
  m_pBirthSign = (CEsmBirthSign *) GetRecInfo()->pRecord;
  ASSERT(m_pBirthSign != NULL);
 
	/* Item ID, if changed */
  if (m_IDText.GetModify()) {
    m_IDText.GetWindowText(Buffer);
    m_pBirthSign->SetID(TrimStringSpace(Buffer));
   }

	/* Item name */
  m_NameText.GetWindowText(Buffer);
  m_pBirthSign->SetName(TrimStringSpace(Buffer));
	
	/* Item description */
  m_DescText.GetWindowText(Buffer);
  m_pBirthSign->SetDescription(TrimStringSpace(Buffer));

	/* Texture button */
  m_TextureButton.GetWindowText(Buffer);
  m_pBirthSign->SetTexture(Buffer);
 
	/* Spells and abilities */
  m_pBirthSign->DeleteSubRecords(MWESM_SUBREC_NPCS);

  for (Index = 0; Index < m_SpellList.GetItemCount(); Index++) {
    pRecInfo = (esmrecinfo_t *) m_SpellList.GetItemData(Index);
    if (pRecInfo == NULL) continue;
    pSpellRec = (CEsmSubName32 *) m_pBirthSign->AllocateSubRecord(MWESM_SUBREC_NPCS);
    pSpellRec->CreateNew();
    pSpellRec->SetName(pRecInfo->pRecord->GetID());
   }

 }
Пример #19
0
void CEsmBodyPartDlg::GetControlData (void) {
  DEFINE_FUNCTION("CEsmBodyPartDlg::GetControlData()");
  bodypartdata_t* pBodyData;
  CString	  Buffer;  
  int		  ListIndex;

	/* Update the armor pointer and data */
  m_pBodyPart = (CEsmBodyPart *) GetRecInfo()->pRecord;
  if (m_pBodyPart == NULL) return;
  pBodyData = m_pBodyPart->GetBodyData();
  if (pBodyData == NULL) return;

	/* Item ID, if changed */
  if (m_IDText.GetModify()) {
    m_IDText.GetWindowText(Buffer);
    m_pBodyPart->SetID(TrimStringSpace(Buffer));
   }

	/* Model filename */
  m_ModelButton.GetWindowText(Buffer);
  m_pBodyPart->SetModel(TrimStringSpace(Buffer));

	/* Record flags */
  m_pBodyPart->SetBlocked(m_BlockedCheck.GetCheck() != 0);
  pBodyData->Vampire = m_VampireCheck.GetCheck();
  m_pBodyPart->SetPlayable(m_PlayableCheck.GetCheck() != 0);
  m_pBodyPart->SetFemale(m_FemaleCheck.GetCheck() != 0);

	/* Body part list */
  ListIndex = m_PartList.GetCurSel();
  if (ListIndex >= 0) pBodyData->Part = (byte)m_PartList.GetItemData(ListIndex);

  	/* Body part type list */
  ListIndex = m_PartTypeList.GetCurSel();
  if (ListIndex >= 0) pBodyData->PartType = (byte)m_PartTypeList.GetItemData(ListIndex);

	/* Get race */	
  m_RaceList.GetWindowText(Buffer);
  m_pBodyPart->SetRace(Buffer);
 }
Пример #20
0
void CEsmNpcDlg::GetControlData (void) {
  DEFINE_FUNCTION("CEsmNpcDlg::GetControlData()");
  CString	Buffer;  
  
	/* Update the object pointer and data */
  m_pNpc = (CEsmNpc *) GetRecInfo()->pRecord;
  ASSERT(m_pNpc != NULL);

  	/* Object ID, if changed */
  if (m_IDText.GetModify()) {
    m_IDText.GetWindowText(Buffer);
    m_pNpc->SetID(TrimStringSpace(Buffer));
   }

	/* Reallocate NPC data as required */
  m_pNpc->CreateNPCData(m_Page1.IsAutoCalc());

  m_Page1.GetControlData();
  m_Page2.GetControlData();
  m_Page3.GetControlData();
  m_Page4.GetControlData();
  m_Page5.GetControlData();
 }
Пример #21
0
 }
/*===========================================================================
 *		End of Class Method CEsmRefCellPage::DeleteCellRef()
 *=========================================================================*/


/*===========================================================================
 *
 * Class CEsmRefCellPage Method - void DeleteIndex (ListIndex, Delete);
 *
 * Deletes or undeletes the given list record.
 *
 *=========================================================================*/
void CEsmRefCellPage::DeleteIndex (const int ListIndex, const bool Delete) {
  DEFINE_FUNCTION("CEsmRefCellPage::DeleteIndex()");
  CEsmSubCellRef* pOldCellRef;
  CEsmSubCellRef* pNewCellRef;
  CEsmCellRefDlg  RefDialog;
  cellrefdata_t*  pCellRefData;
  
	/* Get the given cell reference object */
  pOldCellRef = (CEsmSubCellRef *) m_CellRefList.GetItemData(ListIndex);
  if (pOldCellRef == NULL) return;

	/* See if the reference record is already 'new' */
  pCellRefData = FindNewCellRef(pOldCellRef);

  if (pCellRefData == NULL) {
    CreatePointer(pNewCellRef, CEsmSubCellRef);
    pNewCellRef->Copy(pOldCellRef);
   }
  else {
    pNewCellRef = pCellRefData->pNewCellRef;
   }

	/* Create a new cell ref data record if required */ 
  if (pCellRefData == NULL) {
    pCellRefData = DeleteCellRef(pNewCellRef);
    pCellRefData->pOldCellRef = pOldCellRef;
    pCellRefData->pNewCellRef = pNewCellRef;
   }
  else {
    pCellRefData->Type = ESMCELLREF_MODTYPE_DEL;
   }

	/* Delete or undelete the reference */
  pCellRefData->pNewCellRef->SetDelete(Delete);
  pCellRefData->pNewCellRef->SetFRMRFlag(1);
 }
Пример #22
0
cellrefdata_t* CEsmRefCellPage::ModifyCellRef (CEsmSubCellRef* pCellRef) {
  DEFINE_FUNCTION("CEsmRefCellPage::DeleteCellRef()");
  cellrefdata_t* pCellRefData;

	/* See if the record already exists in array */
  pCellRefData = FindNewCellRef(pCellRef);

  if (pCellRefData != NULL) {
    pCellRefData->Type = ESMCELLREF_MODTYPE_MOD;
    return (pCellRefData);
   }

	/* Add a new record to the modified array */
  CreatePointer(pCellRefData, cellrefdata_t);
  m_ModCellRefs.AddElement(pCellRefData);

	/* Initialize the new cell ref data */
  pCellRefData->IsNew = false;
  pCellRefData->Type  = ESMCELLREF_MODTYPE_MOD;
  pCellRefData->pNewCellRef = pCellRef;
  pCellRefData->pOldCellRef = pCellRef;

  return (pCellRefData);
 }
Пример #23
0
static cg_blend_string_color_source_info_t blending_color_sources[] = {
    DEFINE_COLOR_SOURCE(SRC_COLOR, 9), DEFINE_COLOR_SOURCE(DST_COLOR, 9),
    DEFINE_COLOR_SOURCE(CONSTANT, 8)
};

#undef DEFINE_COLOR_SOURCE

#define DEFINE_FUNCTION(NAME, NAME_LEN, ARGC)                                  \
    { /*.type = */                                                             \
        CG_BLEND_STRING_FUNCTION_##NAME,                                       \
        /*.name = */ #NAME,                                                \
        /*.name_len = */ NAME_LEN,                                         \
        /*.argc = */ ARGC                                                  \
    }

static cg_blend_string_function_info_t blend_functions[] = { DEFINE_FUNCTION(
                                                                 ADD, 3, 2) };

#undef DEFINE_FUNCTION

uint32_t
cg_blend_string_error_domain(void)
{
    return c_quark_from_static_string("cg-blend-string-error-quark");
}

void
_cg_blend_string_split_rgba_statement(cg_blend_string_statement_t *statement,
                                      cg_blend_string_statement_t *rgb,
                                      cg_blend_string_statement_t *a)
{
    int i;
Пример #24
0
void
YogBuiltins_boot(YogEnv* env, YogHandle* builtins)
{
    SAVE_LOCALS(env);
    YogVal errno_ = YUNDEF;
    YogVal e = YUNDEF;
    PUSH_LOCALS2(env, errno_, e);

#define DEFINE_FUNCTION(name, f)    do { \
    YogPackage_define_function(env, HDL2VAL(builtins), name, f); \
} while (0)
    DEFINE_FUNCTION("classmethod", classmethod);
    DEFINE_FUNCTION("disable_gc_stress", disable_gc_stress);
    DEFINE_FUNCTION("enable_gc_stress", enable_gc_stress);
    DEFINE_FUNCTION("get_current_thread", get_current_thread);
    DEFINE_FUNCTION("include_module", include_module);
    DEFINE_FUNCTION("join_path", join_path);
    DEFINE_FUNCTION("property", property);
    DEFINE_FUNCTION("puts", puts_);
    DEFINE_FUNCTION("raise_exception", raise_exception);
#undef DEFINE_FUNCTION
#define DEFINE_FUNCTION2(name, f, ...) do { \
    YogPackage_define_function2(env, builtins, (name), (f), __VA_ARGS__); \
} while (0)
    DEFINE_FUNCTION2("import_package", import_package, "name", NULL);
    DEFINE_FUNCTION2("load_lib", load_lib, "path", NULL);
    DEFINE_FUNCTION2("locals", locals, NULL);
    DEFINE_FUNCTION2("major_gc", major_gc, NULL);
    DEFINE_FUNCTION2("minor_gc", minor_gc, NULL);
    DEFINE_FUNCTION2("mkdir", mkdir_, "path", NULL);
    DEFINE_FUNCTION2("print", print, "*", NULL);
#undef DEFINE_FUNCTION2

#define REGISTER_CLASS(c)   do { \
    YogVal klass = env->vm->c; \
    ID name = PTR_AS(YogClass, klass)->name; \
    YogObj_set_attr_id(env, HDL2VAL(builtins), name, klass); \
} while (0)
    REGISTER_CLASS(cArray);
    REGISTER_CLASS(cBinary);
    REGISTER_CLASS(cBuffer);
    REGISTER_CLASS(cCoroutine);
    REGISTER_CLASS(cDatetime);
    REGISTER_CLASS(cDict);
    REGISTER_CLASS(cDir);
    REGISTER_CLASS(cFile);
    REGISTER_CLASS(cInt);
    REGISTER_CLASS(cObject);
    REGISTER_CLASS(cPath);
    REGISTER_CLASS(cPointer);
    REGISTER_CLASS(cProcess);
    REGISTER_CLASS(cRegexp);
    REGISTER_CLASS(cSet);
    REGISTER_CLASS(cString);
    REGISTER_CLASS(cStructClass);
    REGISTER_CLASS(cSymbol);
    REGISTER_CLASS(cThread);
    REGISTER_CLASS(cUnionClass);
    REGISTER_CLASS(eAttributeError);
    REGISTER_CLASS(eException);
    REGISTER_CLASS(eImportError);
    REGISTER_CLASS(eIndexError);
    REGISTER_CLASS(eKeyError);
    REGISTER_CLASS(eNotImplementedError);
    REGISTER_CLASS(eSyntaxError);
    REGISTER_CLASS(eSystemError);
    REGISTER_CLASS(eValueError);
#undef REGISTER_CLASS
#define REGISTER_MODULE(m) do { \
    YogVal mod = env->vm->m; \
    ID name = PTR_AS(YogModule, mod)->name; \
    YogObj_set_attr_id(env, HDL2VAL(builtins), name, mod); \
} while (0)
    REGISTER_MODULE(mComparable);
    REGISTER_MODULE(mEnumerable);
#undef REGISTER_MODULE

    e = YogEnv_new(env);
    YogObj_set_attr(env, HDL2VAL(builtins), "ENV", e);
    YogObj_set_attr(env, HDL2VAL(builtins), "ENCODINGS", env->vm->encodings);
    YogVal enc = env->vm->default_encoding;
    YogObj_set_attr(env, HDL2VAL(builtins), "DEFAULT_ENCODING", enc);
    YogVal STDIN = create_stdio(env, stdin);
    YogObj_set_attr(env, HDL2VAL(builtins), "STDIN", STDIN);
    YogVal STDOUT = create_stdio(env, stdout);
    YogObj_set_attr(env, HDL2VAL(builtins), "STDOUT", STDOUT);
    YogVal STDERR = create_stdio(env, stderr);
    YogObj_set_attr(env, HDL2VAL(builtins), "STDERR", STDERR);

    set_path_separator(env, builtins);

#define REGISTER_ERRNO(e) do { \
    errno_ = YogVal_from_int(env, (e)); \
    YogObj_set_attr(env, HDL2VAL(builtins), #e, errno_); \
} while (0)
#include "errno.inc"
#undef REGISTER_ERRNO

    const char* src = 
#include "builtins.inc"
    ;
    YogMisc_eval_source(env, builtins, src);

    RETURN_VOID(env);
}
Пример #25
0
  /*.name = */"TEXTURE_N",
  /*.name_len = */0
};

#undef DEFINE_COLOR_SOURCE

#define DEFINE_FUNCTION(NAME, NAME_LEN, ARGC) \
  { /*.type = */COGL_BLEND_STRING_FUNCTION_ ## NAME, \
    /*.name = */#NAME, \
    /*.name_len = */NAME_LEN, \
    /*.argc = */ARGC }

/* NB: These must be sorted so any name that's a subset of another
 * comes later than the longer name. */
static CoglBlendStringFunctionInfo tex_combine_functions[] = {
  DEFINE_FUNCTION (REPLACE, 7, 1),
  DEFINE_FUNCTION (MODULATE, 8, 2),
  DEFINE_FUNCTION (ADD_SIGNED, 10, 2),
  DEFINE_FUNCTION (ADD, 3, 2),
  DEFINE_FUNCTION (INTERPOLATE, 11, 3),
  DEFINE_FUNCTION (SUBTRACT, 8, 2),
  DEFINE_FUNCTION (DOT3_RGBA, 9, 2),
  DEFINE_FUNCTION (DOT3_RGB, 8, 2)
};

static CoglBlendStringFunctionInfo blend_functions[] = {
  DEFINE_FUNCTION (ADD, 3, 2)
};

#undef DEFINE_FUNCTION
Пример #26
0
void CEsmArmorDlg::GetControlData (void) {
  DEFINE_FUNCTION("CEsmArmorDlg::GetControlData()");
  armordata_t*	pArmorData;
  CString	Buffer;  
  int		Index;

	/* Update the armor pointer and data */
  m_pArmor = (CEsmArmor *) GetRecInfo()->pRecord;
  if (m_pArmor == NULL) return;
  pArmorData = m_pArmor->GetArmorData();
  ASSERT(pArmorData != NULL);

	/* Armor ID, if changed */
  if (m_IDText.GetModify()) {
    m_IDText.GetWindowText(Buffer);
    m_pArmor->SetID(TrimStringSpace(Buffer));
   }

	/* Armor name */
  m_NameText.GetWindowText(Buffer);
  m_pArmor->SetName(TrimStringSpace(Buffer));

	/* Armor type */
  Index = m_TypeList.GetCurSel();
  if (Index >= 0) pArmorData->Type = m_TypeList.GetItemData(Index);

	/* Armor rating */
  m_RatingText.GetWindowText(Buffer);
  pArmorData->Rating = atoi(Buffer);

	/* Armor health */
  m_HealthText.GetWindowText(Buffer);
  pArmorData->Health = atoi(Buffer);

	/* Armor weight */
  m_WeightText.GetWindowText(Buffer);
  pArmorData->Weight = (float) atof(Buffer);

	/* Armor value */
  m_ValueText.GetWindowText(Buffer);
  pArmorData->Value = atoi(Buffer);

	/* Enchant points */
  m_EnchantText.GetWindowText(Buffer);
  pArmorData->EnchantPts = atoi(Buffer);

	/* Item script */
  m_ScriptList.GetWindowText(Buffer);
  m_pArmor->SetScript(TrimStringSpace(Buffer));

  	/* Item enchant */
  m_EnchantList.GetWindowText(Buffer);
  m_pArmor->SetEnchant(TrimStringSpace(Buffer));

	/* Model filename */
  m_ModelButton.GetWindowText(Buffer);
  m_pArmor->SetModel(TrimStringSpace(Buffer));

  	/* Icon filename */
  m_IconButton.GetWindowText(Buffer);
  m_pArmor->SetIcon(TrimStringSpace(Buffer));

	/* Record flags */
  m_pArmor->SetPersist(m_PersistCheck.GetCheck() != 0);
  m_pArmor->SetBlocked(m_BlockedCheck.GetCheck() != 0);

  GetBipedData();
 }
Пример #27
0
void CEsmEffectDlg::GetControlData (void) {
  DEFINE_FUNCTION("CEsmEffectDlg::GetControlData()");
  CString Buffer;  
  int	  Index;

	/* Update the armor pointer and data */
  m_pEffect = (CEsmMagicEffect *) GetRecInfo()->pRecord;
  if (m_pEffect == NULL) return;

	/* Item description */
  m_DescText.GetWindowText(Buffer);
  m_pEffect->SetDescription(TrimStringSpace(Buffer));

	/* Base cost */
  m_BaseCostText.GetWindowText(Buffer);
  m_pEffect->SetBaseCost((float) atof(Buffer));

  	/* Size */
  m_SizeText.GetWindowText(Buffer);
  m_pEffect->SetSize((float) atof(Buffer));

  	/* Max Size */
  m_MaxSizeText.GetWindowText(Buffer);
  m_pEffect->SetMaxSize((float) atof(Buffer));

  	/* Speed */
  m_SpeedText.GetWindowText(Buffer);
  m_pEffect->SetSpeed((float) atof(Buffer));

	/* Speel school */
  Index = m_SchoolList.GetCurSel();
  if (Index >= 0) m_pEffect->SetSchool(m_SchoolList.GetItemData(Index));

	/* Cast sound/visual */
  m_CastSoundList.GetWindowText(Buffer);
  m_pEffect->SetCastSound(TrimStringSpace(Buffer));
  m_CastVisualList.GetWindowText(Buffer);
  m_pEffect->SetCastVisual(TrimStringSpace(Buffer));

  	/* Bolt sound/visual */
  m_BoltSoundList.GetWindowText(Buffer);
  m_pEffect->SetBoltSound(TrimStringSpace(Buffer));
  m_BoltVisualList.GetWindowText(Buffer);
  m_pEffect->SetBoltVisual(TrimStringSpace(Buffer));

  	/* Area sound/visual */
  m_AreaSoundList.GetWindowText(Buffer);
  m_pEffect->SetAreaSound(TrimStringSpace(Buffer));
  m_AreaVisualList.GetWindowText(Buffer);
  m_pEffect->SetAreaVisual(TrimStringSpace(Buffer));

  	/* Hit sound/visual */
  m_HitSoundList.GetWindowText(Buffer);
  m_pEffect->SetHitSound(TrimStringSpace(Buffer));
  m_HitVisualList.GetWindowText(Buffer);
  m_pEffect->SetHitVisual(TrimStringSpace(Buffer));

	/* Particle/effect icons */
  m_ParticleButton.GetWindowText(Buffer);
  m_pEffect->SetParticle(TrimStringSpace(Buffer));
  m_IconButton.GetWindowText(Buffer);
  m_pEffect->SetIcon(TrimStringSpace(Buffer));

	/* Set the lighting color */
  m_RedText.GetWindowText(Buffer);
  m_pEffect->SetRed(atoi(Buffer));
  m_GreenText.GetWindowText(Buffer);
  m_pEffect->SetGreen(atoi(Buffer));
  m_BlueText.GetWindowText(Buffer);
  m_pEffect->SetBlue(atoi(Buffer));

	/* Record flags */
  m_pEffect->SetEnchanting(m_EnchantCheck.GetCheck() != 0);
  m_pEffect->SetSpellMaking(m_SpellCheck.GetCheck() != 0);
  m_pEffect->SetNegative(m_NegativeCheck.GetCheck() != 0);
 }
Пример #28
0
 *		End of Class Method CEsmWeaponDlg::DoDataExchange()
 *=========================================================================*/


/*===========================================================================
 *
 * Class CEsmWeaponDlg Method - void GetControlData (void);
 *
 *=========================================================================*/
void CEsmWeaponDlg::GetControlData (void) {
  DEFINE_FUNCTION("CEsmWeaponDlg::GetControlData()");
  weapondata_t*	pWeaponData;
  CString	Buffer;  
  int		Index;

	/* Update the Weapon pointer and data */
  m_pWeapon = (CEsmWeapon *) GetRecInfo()->pRecord;
  if (m_pWeapon == NULL) return;
  pWeaponData = m_pWeapon->GetWeaponData();
  ASSERT(pWeaponData != NULL);

	/* Weapon ID, if changed */
  if (m_IDText.GetModify()) {
    m_IDText.GetWindowText(Buffer);
    m_pWeapon->SetID(TrimStringSpace(Buffer));
   }

	/* Weapon name */
  m_NameText.GetWindowText(Buffer);
  m_pWeapon->SetName(TrimStringSpace(Buffer));

	/* Weapon type */
  Index = m_TypeList.GetCurSel();
  if (Index >= 0) pWeaponData->Type = (short)m_TypeList.GetItemData(Index);

	/* Weapon speed */
  m_SpeedText.GetWindowText(Buffer);
  pWeaponData->Speed = (float) atof(Buffer);

  	/* Weapon reach */
  m_ReachText.GetWindowText(Buffer);
  pWeaponData->Reach = (float) atof(Buffer);

	/* Weapon health */
  m_HealthText.GetWindowText(Buffer);
  pWeaponData->Health = (short) atoi(Buffer);

	/* Weapon weight */
  m_WeightText.GetWindowText(Buffer);
  pWeaponData->Weight = (float) atof(Buffer);

	/* Weapon value */
  m_ValueText.GetWindowText(Buffer);
  pWeaponData->Value = atoi(Buffer);

	/* Enchant points */
  m_EnchantText.GetWindowText(Buffer);
  pWeaponData->EnchantPts = atoi(Buffer);

	/* Item script */
  m_ScriptList.GetWindowText(Buffer);
  
  switch (pWeaponData->Type) {
    case MWESM_WEAPONTYPE_THROWN:
    case MWESM_WEAPONTYPE_BOLT:
    case MWESM_WEAPONTYPE_ARROW:
	m_pWeapon->SetScript(NULL);
	break;
    default:
	m_pWeapon->SetScript(TrimStringSpace(Buffer));
	break;
  }

  	/* Item enchant */
  m_EnchantList.GetWindowText(Buffer);
  m_pWeapon->SetEnchant(TrimStringSpace(Buffer));

	/* Model filename */
  m_ModelButton.GetWindowText(Buffer);
  m_pWeapon->SetModel(TrimStringSpace(Buffer));

  	/* Icon filename */
  m_IconButton.GetWindowText(Buffer);
  m_pWeapon->SetIcon(TrimStringSpace(Buffer));

	/* Damage */
  m_ChopMinText.GetWindowText(Buffer);
  pWeaponData->ChopMin = (byte)atoi(Buffer);
  m_ChopMaxText.GetWindowText(Buffer);
  pWeaponData->ChopMax = (byte)atoi(Buffer);
  m_SlashMinText.GetWindowText(Buffer);
  pWeaponData->SlashMin = (byte)atoi(Buffer);
  m_SlashMaxText.GetWindowText(Buffer);
  pWeaponData->SlashMax = (byte)atoi(Buffer);
  m_ThrustMinText.GetWindowText(Buffer);
  pWeaponData->ThrustMin = (byte)atoi(Buffer);
  m_ThrustMaxText.GetWindowText(Buffer);
  pWeaponData->ThrustMax = (byte)atoi(Buffer);

	/* Record flags */
  m_pWeapon->SetPersist(m_PersistCheck.GetCheck() != 0);
  m_pWeapon->SetBlocked(m_BlockedCheck.GetCheck() != 0);

  if (m_IgnoreResistCheck.GetCheck())
    pWeaponData->Flags = MWESM_WEAPONFLAG_IGNORERESIST;
  else
    pWeaponData->Flags = 0;

 }
void CEsmSpellDlg::SetEffectData (const int EffectIndex, CEsmSubENAM* pEffectRecord) {

    DEFINE_FUNCTION("CEsmSpellDlg::SetEffectData()");

    const esmeffectdata_t* pEffectData = NULL;

    CString	   Buffer;

    enchanteffect_t* pSpellData = NULL;



    /* Try and get the enchant/effect data */

    if (pEffectRecord != NULL) {

        pSpellData = pEffectRecord->GetEnchantData();

        ASSERT(pSpellData != NULL);

        pEffectData = GetESMEffectData(pSpellData->EffectID);

        m_pEffectInfo[EffectIndex] = GetDocument()->GetEffectRecord(pSpellData->EffectID);

    }



    /* Disable the controls if the record is not valid */

    if (pSpellData == NULL || pEffectData == NULL) {

        m_pEffectInfo[EffectIndex] = NULL;

        m_EffectList[EffectIndex].SelectString(-1, _T(""));

        m_RangeList[EffectIndex].SelectString(-1, _T(""));

        m_SkillList[EffectIndex].EnableWindow(FALSE);

        m_DurationText[EffectIndex].EnableWindow(FALSE);

        m_Magnitude1Text[EffectIndex].EnableWindow(FALSE);

        m_Magnitude2Text[EffectIndex].EnableWindow(FALSE);

        m_AreaText[EffectIndex].EnableWindow(FALSE);

        m_DurationText[EffectIndex].SetModify(FALSE);

        m_Magnitude1Text[EffectIndex].SetModify(FALSE);

        m_Magnitude2Text[EffectIndex].SetModify(FALSE);

        m_AreaText[EffectIndex].SetModify(FALSE);

        return;

    }



    /* Select the effect ID */

    FindComboListItem(m_EffectList[EffectIndex], pSpellData->EffectID, true);



    /* Set the effect magnitude */

    if (pEffectData->HasMagnitude()) {

        Buffer.Format(_T("%d"), (int)pSpellData->MagMin);

        m_Magnitude1Text[EffectIndex].EnableWindow(TRUE);

        m_Magnitude1Text[EffectIndex].SetWindowText(Buffer);

        m_Magnitude1Text[EffectIndex].SetModify(FALSE);

        Buffer.Format(_T("%d"), (int)pSpellData->MagMax);

        m_Magnitude2Text[EffectIndex].EnableWindow(TRUE);

        m_Magnitude2Text[EffectIndex].SetWindowText(Buffer);

        m_Magnitude2Text[EffectIndex].SetModify(FALSE);

    }

    else {

        m_Magnitude1Text[EffectIndex].EnableWindow(FALSE);

        m_Magnitude1Text[EffectIndex].SetWindowText(_T(""));

        m_Magnitude1Text[EffectIndex].SetModify(FALSE);

        m_Magnitude2Text[EffectIndex].EnableWindow(FALSE);

        m_Magnitude2Text[EffectIndex].SetWindowText(_T(""));

        m_Magnitude2Text[EffectIndex].SetModify(FALSE);

    }



    /* Set the effect duration */

    if (pEffectData->HasDuration()) {

        Buffer.Format(_T("%d"), (int)pSpellData->Duration);

        m_DurationText[EffectIndex].EnableWindow(!m_DisableCost);

        m_DurationText[EffectIndex].SetWindowText(Buffer);

        m_DurationText[EffectIndex].SetModify(FALSE);

    }

    else {

        m_DurationText[EffectIndex].EnableWindow(FALSE);

        m_DurationText[EffectIndex].SetWindowText(_T(""));

        m_DurationText[EffectIndex].SetModify(FALSE);

    }



    /* Set the effect range */

    if (pEffectData->IsSelfOnly()) {

        FillEsmEnchantRangeCombo(m_RangeList[EffectIndex]);

        m_RangeList[EffectIndex].EnableWindow(TRUE);

        m_RangeList[EffectIndex].SetCurSel(0);

        m_AreaText[EffectIndex].EnableWindow(TRUE);

        m_AreaText[EffectIndex].SetWindowText(_T(""));

    }

    else if (pEffectData->IsNotSelf()) {

        FillEsmEnchantRangeCombo(m_RangeList[EffectIndex], true);

        m_RangeList[EffectIndex].EnableWindow(!m_DisableCost);

        FindComboListItem(m_RangeList[EffectIndex], pSpellData->RangeType, true);

        m_AreaText[EffectIndex].EnableWindow(TRUE);

    }

    else {

        FillEsmEnchantRangeCombo(m_RangeList[EffectIndex]);

        m_RangeList[EffectIndex].EnableWindow(TRUE);

        FindComboListItem(m_RangeList[EffectIndex], pSpellData->RangeType, true);

        m_AreaText[EffectIndex].EnableWindow(TRUE);

    }



    /* Set the effect area */

    Buffer.Format(_T("%d"), (int)pSpellData->Area);

    m_AreaText[EffectIndex].SetWindowText(Buffer);

    m_AreaText[EffectIndex].SetModify(FALSE);



    /* Disable the area/range controls if required */

    if (m_DisableCost) {

        m_RangeList[EffectIndex].EnableWindow(FALSE);

        m_RangeList[EffectIndex].SelectString(-1, _T("Self"));

        m_AreaText[EffectIndex].EnableWindow(FALSE);

    }



    /* Set the initial effect cost and total cost labels */

    Buffer.Format(_T("%d"), 0);

    m_CostLabel[EffectIndex].SetWindowText(Buffer);

    Buffer.Format(_T("%d"), 0);

    m_TotalCostText[EffectIndex].SetWindowText(Buffer);



    /* Fill in the skill/attribute list as required */

    if (IsESMSkillEffect(pSpellData->EffectID)) {

        m_SkillList[EffectIndex].EnableWindow(TRUE);

        FillEsmSkillsCombo(m_SkillList[EffectIndex]);

        FindComboListItem(m_SkillList[EffectIndex], pSpellData->SkillID, true);

    }

    else if (IsESMAttributeEffect(pSpellData->EffectID)) {

        m_SkillList[EffectIndex].EnableWindow(TRUE);

        FillEsmAttributesCombo(m_SkillList[EffectIndex]);

        FindComboListItem(m_SkillList[EffectIndex], pSpellData->AttributeID, true);

    }

    else {

        m_SkillList[EffectIndex].EnableWindow(FALSE);

    }



    UpdateSpellCost(EffectIndex);

}
void CEsmSpellDlg::GetControlData (void) {

    DEFINE_FUNCTION("CEsmSpellDlg::GetControlData()");

    spelldata_t*	pSpellData;

    CString	Buffer;

    int		ListIndex;



    /* Update the armor pointer and data */

    m_pSpell = (CEsmSpell *) GetRecInfo()->pRecord;

    if (m_pSpell == NULL) return;

    pSpellData = m_pSpell->GetSpellData();

    ASSERT(pSpellData != NULL);



    /* Item ID, if changed */

    if (m_IDText.GetModify()) {

        m_IDText.GetWindowText(Buffer);

        m_pSpell->SetID(TrimStringSpace(Buffer));

    }



    /* Spell type */

    ListIndex = m_TypeList.GetCurSel();

    if (ListIndex >= 0) m_pSpell->SetSpellType(m_TypeList.GetItemData(ListIndex));



    /* Spell cost */

    m_CostText.GetWindowText(Buffer);

    pSpellData->SpellCost = atoi(Buffer);



    /* Item name */

    m_NameText.GetWindowText(Buffer);

    m_pSpell->SetName(TrimStringSpace(Buffer));



    /* Record flags */

    if (m_AutoCalcCheck.GetCheck())

        pSpellData->Flags |= MWESM_SPELLFLAG_AUTOCALC;

    else

        pSpellData->Flags &= ~MWESM_SPELLFLAG_AUTOCALC;



    if (m_SucceedCheck.GetCheck())

        pSpellData->Flags |= MWESM_SPELLFLAG_SUCCEEDS;

    else

        pSpellData->Flags &= ~MWESM_SPELLFLAG_SUCCEEDS;



    if (m_PCStartCheck.GetCheck())

        pSpellData->Flags |= MWESM_SPELLFLAG_PCSTART;

    else

        pSpellData->Flags &= ~MWESM_SPELLFLAG_PCSTART;



    m_pSpell->SetBlocked(m_BlockedCheck.GetCheck() != 0);



    GetEffectData();

}