void CCMatchGameTypeInfo::AddAllMap()
{
	for (int i = 0; i < CCMATCH_MAP_MAX; i++)
	{
		AddMap(i);
	}
}
INT_PTR TestSplitBySourceDlgProc::DlgProc(TimeValue t, IParamMap2 *map, HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
	IParamBlock2* pblock = NULL;

	switch(msg) {
		case WM_INITDIALOG:
			if (NumMaps() == 0) { // first map to open
				GetPFSystemPool()->RegisterNotification(UpdateSources, this);
			}
			AddMap(map);
			if (map != NULL) pblock = map->GetParamBlock();
			if (pblock != NULL)	pblock->NotifyDependents( FOREVER, (PartID)map, kSplitBySource_RefMsg_InitDlg );
			break;
		case WM_DESTROY:
			RemoveMap(map);
			if (NumMaps() == 0) { // last map to close
				GetPFSystemPool()->UnRegisterNotification(UpdateSources, this);
			}
			break;
		case WM_COMMAND:
			switch(LOWORD(wParam)) {
				case IDC_SOURCELIST:
					SelectSources(hWnd, map->GetParamBlock());
					break;
				case kSplitBySource_message_update:
					UpdateSourceDlg(map);
					break;
			}
			break;
	}

	return FALSE;
}
Example #3
0
File: Game.cpp Project: dhewg/gemrb
/* Loads an area */
int Game::LoadMap(const char* ResRef, bool loadscreen)
{
	unsigned int i;
	Map *newMap;
	PluginHolder<MapMgr> mM(IE_ARE_CLASS_ID);
	ScriptEngine *sE = core->GetGUIScriptEngine();

	//this shouldn't happen
	if (!mM) {
		return -1;
	}

	int index = FindMap(ResRef);
	if (index>=0) {
		return index;
	}

	bool hide = false;
	if (loadscreen && sE) {
		hide = core->HideGCWindow();
		sE->RunFunction("LoadScreen", "StartLoadScreen");
		sE->RunFunction("LoadScreen", "SetLoadScreen");
	}
	DataStream* ds = gamedata->GetResource( ResRef, IE_ARE_CLASS_ID );
	if (!ds) {
		goto failedload;
	}
	if(!mM->Open(ds)) {
		goto failedload;
	}
	newMap = mM->GetMap(ResRef, IsDay());
	if (!newMap) {
		goto failedload;
	}

	core->LoadProgress(100);

	for (i = 0; i < PCs.size(); i++) {
		if (stricmp( PCs[i]->Area, ResRef ) == 0) {
			newMap->AddActor( PCs[i] );
		}
	}
	for (i = 0; i < NPCs.size(); i++) {
		if (stricmp( NPCs[i]->Area, ResRef ) == 0) {
			newMap->AddActor( NPCs[i] );
		}
	}
	if (hide) {
		core->UnhideGCWindow();
	}
	return AddMap( newMap );
failedload:
	if (hide) 
		core->UnhideGCWindow();
	core->LoadProgress(100);
	return -1;
}
STDMETHODIMP ESource::InitEvent(OLECHAR *Name,
                 LPCOLESTR  pCode,
                 DISPID     SinkDispID,
                 OrxScript *ORexxScript,
                 FILE      *LogFile)
{
    PEMAP      NewMap;
    HRESULT    RetCode;

    EventType = ParseProcedure;
    EventName = SysAllocString(Name);
    Engine = ORexxScript;
    Connected = true;
    ConnectionPoint = NULL;
    Container = NULL;
    logfile = LogFile;
    CodeLen = (int)wcslen(pCode);
    Code = (OLECHAR *) GlobalAlloc(GMEM_FIXED,(CodeLen+1)*sizeof(OLECHAR));
    if (!Code)
    {
        FPRINTF2(logfile," ParseProcedure Event ERROR Failed to initialize.  Out of memory.\n");
        return E_OUTOFMEMORY;
    }
    memcpy(Code,pCode,(CodeLen+1)*sizeof(OLECHAR));

    RetCode = AddMap("0",&NewMap);
    if (FAILED(RetCode))
    {
        GlobalFree(Code);
        Code = NULL;
        FPRINTF2(logfile," ParseProcedure Event ERROR Failed to initialize.  AddMap Failed.\n");
        return RetCode;
    }
    NewMap->SourceEventName = SysAllocString(Name);
    NewMap->Sink = SinkDispID;

    FPRINTF2(logfile,"created a new ParseProcedure Event Source. %p\n",this);
    FPRINTF2(DLLlogfile,"created a new Event Source.%p\n",this);
    return S_OK;
}
void ResourceManager::Init()
{
    AddMesh( MODEL_UNIT_SWORD, MESH_KEY_UNIT_SWORD );
    AddMesh( MODEL_UNIT_PIKE, MESH_KEY_UNIT_PIKE );
    AddMesh( MODEL_UNIT_ARROW, MESH_KEY_UNIT_ARROW );
    AddMesh( MODEL_UNIT_KNIGHT, MESH_KEY_UNIT_KNIGHT );
    AddMesh( MODEL_UNIT_GUARD, MESH_KEY_UNIT_GUARD );
    AddMesh( MODEL_UNIT_KING, MESH_KEY_UNIT_KING );

    AddMesh( MODEL_CORPS_DESTROY_A, MESH_KEY_CORPS_DESTROY_ENEMY );
    AddMesh( MODEL_CORPS_DEFENSE_A, MESH_KEY_CORPS_DEFENSE_ENEMY );
    AddMesh( MODEL_CORPS_RUSH_A, MESH_KEY_CORPS_RUSH_ENEMY );
    AddMesh( MODEL_CORPS_DESTROY_B, MESH_KEY_CORPS_DESTROY_MINE );
    AddMesh( MODEL_CORPS_DEFENSE_B, MESH_KEY_CORPS_DEFENSE_MINE );
    AddMesh( MODEL_CORPS_RUSH_B, MESH_KEY_CORPS_RUSH_MINE );

    AddMap( HEIGHT_MAP, HEIGHT_TEX, MAP_KEY_TEST );
    CreateMap( MAP_KEY_TEST );

    //////////////////////////////////////////////////////////////////////////
    // 쿼드트리를 적용하기 위해 하이트 맵은 2^n 형태의 크기로 만들어야 합니다.
    //
    // 주의! 실제 하이트맵 크기는 한 변이 2^n + 1 사이즈여야 합니다!
    //////////////////////////////////////////////////////////////////////////
    InitGroundMesh( 128, 128 );
    CreateRawGround( 128, 128, 5.0f );

    if ( FAILED( InitHeightMap( HEIGHT_MAP, 5.0f ) ) )
    {
        m_IsMapForQuadTreeReady = false;
    }
    else
    {
        m_IsMapForQuadTreeReady = true;
    }

    MapManager::GetInstance()->SetPixelSize( 5.0f );

    m_MapSize = 640;
    m_IsMapReady = true;

    InitSkyBoxMesh( 640 );

    SetSkyBoxTexture( SPRITE_SKYBOX_BACK, SKY_BOX_BACK );
    SetSkyBoxTexture( SPRITE_SKYBOX_FRONT, SKY_BOX_FRONT );
    SetSkyBoxTexture( SPRITE_SKYBOX_LEFT, SKY_BOX_LEFT );
    SetSkyBoxTexture( SPRITE_SKYBOX_RIGHT, SKY_BOX_RIGHT );
    SetSkyBoxTexture( SPRITE_SKYBOX_TOP, SKY_BOX_TOP );
    SetSkyBoxTexture( SPRITE_SKYBOX_BOTTOM, SKY_BOX_BOTTOM );

    InitCursor( CURSOR_MAX, MouseManager::GetInstance()->GetMousePositionX(), MouseManager::GetInstance()->GetMousePositionY() );
    CreateCursorImage( SPRITE_CURSOR_DEFAULT, CURSOR_DEFAULT );
    CreateCursorImage( SPRITE_CURSOR_ATTACK, CURSOR_ATTACK );
    CreateCursorImage( SPRITE_CURSOR_CLICK, CURSOR_CLICK );
    CreateCursorImage( SPRITE_CURSOR_OVER_CORPS, CURSOR_OVER_CORPS );
    CreateCursorImage( SPRITE_CURSOR_UNRECHEABLE, CURSOR_UNRECHEABLE );
    CreateCursorImage( SPRITE_CURSOR_CAMERA_ROTATING, CURSOR_CAMERA_ROTATING );
    CreateCursorImage( SPRITE_CURSOR_CORPS_MOVABLE, CURSOR_CORPS_MOVABLE );
    CreateCursorImage( SPRITE_CURSOR_CORPS_MOVABLE_CLICK, CURSOR_CORPS_MOVABLE_CLICK );
    CreateCursorImage( SPRITE_CURSOR_OVER_PICKED_CORPS, CURSOR_OVER_PICKED_CORPS );

    m_ISCursorReady = true;

    CreateSprite();

    ShaderCreate( SHADER_TYPE_MAX );
    ShaderImport( SELECT_SHADER, SHADER_SELECT );
    ShaderImport( FIGHT_SHADER, SHADER_FIGHT );
    ShaderImport( MAP_SHADER, SHADER_MAP );

    MeshTextureCreateBySize( CORPS_TEXTURE_MAX );
    MeshTextureImport( SPRITE_CORPS_TYPE_ARROW, CORPS_TEXTURE_ARROW );
    MeshTextureImport( SPRITE_CORPS_TYPE_GUARD, CORPS_TEXTURE_GUARD );
    MeshTextureImport( SPRITE_CORPS_TYPE_KING, CORPS_TEXTURE_KING );
    MeshTextureImport( SPRITE_CORPS_TYPE_KNIGHT, CORPS_TEXTURE_KNIGHT );
    MeshTextureImport( SPRITE_CORPS_TYPE_PIKE, CORPS_TEXTURE_PIKE );
    MeshTextureImport( SPRITE_CORPS_TYPE_SWORD, CORPS_TEXTURE_SWORD );
}
Example #6
0
BOOL BuildGUI(char *screenname) {
	Object **ar = Window_Objs;
  struct Screen *screen;
  BOOL OptionFrame = FALSE;
  LONG indicatorwidth = 100;

  UpdateStrings();

  // Kludge for Piccaso 96/BGUI.
  if(FindTask("Picasso96"))
  {
    PopUpMenus = FALSE;
  }

  BGUIBase = (void *)OpenLibrary("bgui.library", 41);
  if(BGUIBase == NULL) {
    Printf((char *) msgTextNoOpen, (ULONG) "bgui.library", 41);
    Printf("\n");
    return FALSE;
  }

  screen = LockPubScreen(screenname);

  indicatorwidth = max(indicatorwidth, 16 * screen->RastPort.Font->tf_XSize);
  if(screen->Height > 240) {
    OptionFrame = TRUE;
  }

  WO_Window = WindowObject,
    WINDOW_PubScreen,       screen,
    WINDOW_Title,           (char *) msgTextProgramName,
    WINDOW_CloseGadget,     FALSE,
    WINDOW_MenuStrip,       Menus,
    WINDOW_AutoAspect,      TRUE,
    WINDOW_AutoKeyLabel,    TRUE,
    WINDOW_ScaleWidth,      60,
    WINDOW_ScaleHeight,     20,
    WINDOW_HelpFile,        HELPFILE,
    WINDOW_HelpNode,        "AHI",
    WINDOW_IDCMPHook,      &IDCMPhook,
    WINDOW_IDCMPHookBits,   IDCMP_RAWKEY,

    WINDOW_MasterGroup, VGroupObject, NormalOffset,

/* TABS */

      StartMember, ar[ACTID_TABS] = MxObject,
        MX_Labels, PageNames,
        MX_TabsObject, TRUE,
        GA_ID, ACTID_TABS,
      EndObject, FixMinHeight, EndMember,

      StartMember, ar[ACTID_PAGE] = PageObject, NormalSpacing, 
        PAGE_NoBufferRP, TRUE,

/* PAGE 1 */

        PageMember, HGroupObject, NormalOffset, NormalSpacing, TabAboveFrame,

          StartMember, vgroup = VGroupObject, NormalSpacing,

            StartMember, ar[ACTID_UNIT] = CycleObject,
              CYC_Labels,    Units,
              CYC_Active,    state.UnitSelected,
              CYC_PopActive, PopUpMenus,
              CYC_Popup,     PopUpMenus,
              GA_ID,         ACTID_UNIT,
            EndObject, FixMinHeight, EndMember,

            StartMember, ar[ACTID_MODE] = ListviewObject,
//              LISTV_EntryArray,  Modes,
//              LISTV_Select,      state.ModeSelected,
              PGA_NewLook, TRUE,
              GA_ID, ACTID_MODE,
            EndObject, EndMember,

            StartMember, HGroupObject,
              ButtonFrame, FRM_Flags, FRF_RECESSED,
          
              StartMember, InfoObject,
                INFO_TextFormat,  (char *) msgProperties,
                INFO_FixTextWidth,TRUE,
                INFO_MinLines,    6,
              EndObject, FixMinWidth, EndMember,

              StartMember, ar[SHOWID_MODE] = InfoObject,
                INFO_MinLines,   6,
              EndObject,  EndMember,
            EndObject, FixMinHeight, EndMember,

          EndObject /* vgroup */, EndMember,

          StartMember, VGroupObject, NormalSpacing, 

            VarSpace(1),

            StartMember, VGroupObject,
              (OptionFrame ? GROUP_HorizOffset : TAG_IGNORE), GRSPACE_NORMAL,
              (OptionFrame ? GROUP_VertOffset  : TAG_IGNORE), GRSPACE_NORMAL,
              (OptionFrame ? GROUP_Spacing     : TAG_IGNORE), GRSPACE_NORMAL,
              (OptionFrame ? FRM_Type          : TAG_IGNORE), FRTYPE_RIDGE,
              (OptionFrame ? FRM_Flags         : TAG_IGNORE), FRF_RECESSED,
              (OptionFrame ? FRM_Title         : TAG_IGNORE), (char *) msgOptions,

              StartMember, HGroupObject,
                StartMember, ar[ACTID_FREQ] = SliderObject,
                  LAB_Label,    (char *) msgOptFrequency,
                  SLIDER_Min,   0,
                  SLIDER_Max,   state.Frequencies -1 ,
                  SLIDER_Level, state.FreqSelected,
                  PGA_NewLook, TRUE,
                  GA_ID, ACTID_FREQ,
                EndObject, EndMember,

                StartMember, ar[SHOWID_FREQ] = InfoObject,
                  INFO_TextFormat,    getFreq(),
                  INFO_VertOffset,    0,
                EndObject, FixWidth(indicatorwidth), EndMember,
              EndObject, FixMinHeight, EndMember,

              StartMember, HGroupObject,
                StartMember, ar[ACTID_CHANNELS] = SliderObject,
                  LAB_Label,    (char *) msgOptChannels,
                  SLIDER_Min,   1,
                  SLIDER_Max,   state.Channels,
                  SLIDER_Level, state.ChannelsSelected,
                  PGA_NewLook, TRUE,
                  GA_ID, ACTID_CHANNELS,
                EndObject, EndMember,

                StartMember, ar[SHOWID_CHANNELS] = InfoObject,
                  INFO_TextFormat,    getChannels(),
                  INFO_VertOffset,    0,
                EndObject, FixWidth(indicatorwidth), EndMember,
              EndObject, FixMinHeight, EndMember,

              StartMember, HGroupObject,
                StartMember, ar[ACTID_OUTVOL] = SliderObject,
                  LAB_Label,    (char *) msgOptVolume,
                  SLIDER_Min,   0,
                  SLIDER_Max,   state.OutVols-1 ,
                  SLIDER_Level, state.OutVolSelected,
                  PGA_NewLook, TRUE,
                  GA_ID, ACTID_OUTVOL,
                EndObject, EndMember,

                StartMember, ar[SHOWID_OUTVOL] = InfoObject,
                  INFO_TextFormat,    getOutVol(),
                  INFO_VertOffset,    0,
                EndObject, FixWidth(indicatorwidth), EndMember,
              EndObject, FixMinHeight, EndMember,

              StartMember, HGroupObject,
                StartMember, ar[ACTID_MONVOL] = SliderObject,
                  LAB_Label,    (char *) msgOptMonitor,
                  SLIDER_Min,   0,
                  SLIDER_Max,   state.MonVols-1 ,
                  SLIDER_Level, state.MonVolSelected,
                  PGA_NewLook, TRUE,
                  GA_ID, ACTID_MONVOL,
                EndObject, EndMember,

                StartMember, ar[SHOWID_MONVOL] = InfoObject,
                  INFO_TextFormat,    getMonVol(),
                  INFO_VertOffset,    0,
                EndObject, FixWidth(indicatorwidth), EndMember,
              EndObject, FixMinHeight, EndMember,

              StartMember, HGroupObject,
                StartMember, ar[ACTID_GAIN] = SliderObject,
                  LAB_Label,    (char *) msgOptGain,
                  SLIDER_Min,   0,
                  SLIDER_Max,   state.Gains-1 ,
                  SLIDER_Level, state.GainSelected,
                  PGA_NewLook, TRUE,
                  GA_ID, ACTID_GAIN,
                EndObject, EndMember,

                StartMember, ar[SHOWID_GAIN] = InfoObject,
                  INFO_TextFormat,    getGain(),
                  INFO_VertOffset,    0,
                EndObject, FixWidth(indicatorwidth), EndMember,
              EndObject, FixMinHeight, EndMember,

              StartMember, HGroupObject,
                StartMember, ar[ACTID_INPUT] = SliderObject,
                  LAB_Label,    (char *) msgOptInput,
                  SLIDER_Min,   0,
                  SLIDER_Max,   state.Inputs-1 ,
                  SLIDER_Level, state.InputSelected,
                  PGA_NewLook, TRUE,
                  GA_ID, ACTID_INPUT,
                EndObject, EndMember,

                StartMember, ar[SHOWID_INPUT] = InfoObject,
                  INFO_TextFormat,    getInput(),
                  INFO_VertOffset,    0,
                EndObject, FixWidth(indicatorwidth), EndMember,
              EndObject, FixMinHeight, EndMember,

              StartMember, HGroupObject,
                StartMember, ar[ACTID_OUTPUT] = SliderObject,
                  LAB_Label,    (char *) msgOptOutput,
                  SLIDER_Min,   0,
                  SLIDER_Max,   state.Outputs-1 ,
                  SLIDER_Level, state.OutputSelected,
                  PGA_NewLook, TRUE,
                  GA_ID, ACTID_OUTPUT,
                EndObject, EndMember,

                StartMember, ar[SHOWID_OUTPUT] = InfoObject,
                  INFO_TextFormat,    getOutput(),
                  INFO_VertOffset,    0,
                EndObject, FixWidth(indicatorwidth), EndMember,
              EndObject, FixMinHeight, EndMember,

            EndObject /* vgroup "Options" */, FixMinHeight, EndMember,

          VarSpace(1),

          EndObject /* vgroup */, EndMember,

        EndObject, /* (EndMember) page */

/* PAGE 2 */

        PageMember, HGroupObject, NormalSpacing, TabAboveFrame,

          VarSpace(1),

          StartMember, VGroupObject, NormalSpacing,

            VarSpace(1), 

            StartMember, VGroupObject, NormalOffset, NormalSpacing,
              RidgeFrame, FRM_Flags, FRF_RECESSED, FrameTitle((char *) msgGlobalOptions),

              StartMember, HGroupObject, NormalSpacing,
              StartMember, VGroupObject, NormalSpacing,

              StartMember, ar[ACTID_DEBUG] = CycleObject,
                LAB_Label,      (char *) msgGlobOptDebugLevel,
                LAB_Place,      PLACE_LEFT,
                CYC_Labels,     DebugLabels,
                CYC_Active,     globalprefs.ahigp_DebugLevel,
                CYC_PopActive,  PopUpMenus,
                CYC_Popup,      PopUpMenus,
                GA_ID,          ACTID_DEBUG,
              EndObject, FixMinHeight, EndMember,

              StartMember, ar[ACTID_ECHO] = CycleObject,
                LAB_Label,      (char *) msgGlobOptEcho,
                LAB_Place,      PLACE_LEFT,
                CYC_Labels,     EchoLabels,
                CYC_Active,     (globalprefs.ahigp_DisableEcho ? 2 : 0) |
                                (globalprefs.ahigp_FastEcho    ? 1 : 0),
                CYC_PopActive,  PopUpMenus,
                CYC_Popup,      PopUpMenus,
                GA_ID,          ACTID_ECHO,
              EndObject, FixMinHeight, EndMember,

              StartMember, ar[ACTID_SURROUND] = CycleObject,
                LAB_Label,      (char *) msgGlobOptSurround,
                LAB_Place,      PLACE_LEFT,
                CYC_Labels,     SurroundLabels,
                CYC_Active,     globalprefs.ahigp_DisableSurround,
                GA_ID,          ACTID_SURROUND,
              EndObject, FixMinHeight, EndMember,

              StartMember, ar[ACTID_CLIPMV] = CycleObject,
                LAB_Label,      (char *) msgGlobOptMasterVol,
                LAB_Place,      PLACE_LEFT,
                CYC_Labels,     ClipMVLabels,
                CYC_Active,     globalprefs.ahigp_ClipMasterVolume,
                GA_ID,          ACTID_CLIPMV,
              EndObject, FixMinHeight, EndMember,

              StartMember, ar[ACTID_CPULIMIT] = SliderObject,
                LAB_Label,    (char *) msgGlobOptCPULimit,
                SLIDER_Min,   0,
                SLIDER_Max,   100,
                SLIDER_Level, (globalprefs.ahigp_MaxCPU * 100 + 32768) >> 16,
                PGA_NewLook, TRUE,
                GA_ID, ACTID_CPULIMIT,
              EndObject, EndMember,

              EndObject /* vgroup */, EndMember,

              StartMember, VGroupObject, NormalSpacing,

                VarSpace(1),

                StartMember, ar[SHOWID_CPULIMIT] = IndicatorObject,\
                  INDIC_Min,              0,
                  INDIC_Max,              100,
                  INDIC_Level,            (globalprefs.ahigp_MaxCPU * 100 + 32768) / 65536,
                  INDIC_Justification,    IDJ_LEFT,
                  INDIC_FormatString,     "%ld%%",
                EndObject, FixMinWidth, FixMinHeight, EndMember,

              EndObject /* vgroup */, EndMember,
              EndObject /* hgroup */, EndMember,

            EndObject, FixMinWidth, FixMinHeight, EndMember,

            VarSpace(1),

          EndObject /* vgroup */ , FixMinWidth, EndMember,

          VarSpace(1),

        EndObject, /* (EndMember) page */

      EndObject /* page */, EndMember,


/* BUTTONS */
      StartMember, HGroupObject, NormalSpacing, NormalVOffset,

        StartMember, ar[ACTID_SAVE] = ButtonObject,
          ButtonFrame,
          LAB_Label, (char *) msgButtonSave,
          GA_ID,     ACTID_SAVE,
        EndObject, EndMember,

        StartMember, ar[ACTID_USE] = ButtonObject,
          ButtonFrame,
          LAB_Label, (char *) msgButtonUse,
          GA_ID,     ACTID_USE,
        EndObject, EndMember,

        StartMember, ar[ACTID_QUIT] = ButtonObject,
          ButtonFrame,
          LAB_Label, (char *) msgButtonCancel,
          GA_ID,     ACTID_QUIT,
        EndObject, EndMember,
      EndObject, FixMinHeight, EndMember,
    EndObject,
  EndObject;

  if(WO_Window) {
    AddMap( ar[ACTID_TABS], ar[ACTID_PAGE], pagemap );

    DoMethod( ar[ACTID_FREQ],     BASE_ADDHOOK, &GadgetHook );
    DoMethod( ar[ACTID_CHANNELS], BASE_ADDHOOK, &GadgetHook );
    DoMethod( ar[ACTID_OUTVOL],   BASE_ADDHOOK, &GadgetHook );
    DoMethod( ar[ACTID_MONVOL],   BASE_ADDHOOK, &GadgetHook );
    DoMethod( ar[ACTID_GAIN],     BASE_ADDHOOK, &GadgetHook );
    DoMethod( ar[ACTID_INPUT],    BASE_ADDHOOK, &GadgetHook );
    DoMethod( ar[ACTID_OUTPUT],   BASE_ADDHOOK, &GadgetHook );

    AddMap( ar[ACTID_CPULIMIT], ar[SHOWID_CPULIMIT], cpumap);

    window = WindowOpen(WO_Window);
  }

  if(screen) {
    UnlockPubScreen(NULL, screen);
  }

  if(window == NULL) {
    Printf((char *) msgTextNoWindow);
    Printf("\n");
    return FALSE;
  }

  openreq = FileReqObject,
    ASLFR_Window,        window,
    ASLFR_SleepWindow,   TRUE,
    ASLFR_RejectIcons,   TRUE,
    ASLFR_InitialDrawer, "SYS:Prefs/Presets",
  EndObject;

  savereq = FileReqObject,
    ASLFR_Window,        window,
    ASLFR_SleepWindow,   TRUE,
    ASLFR_RejectIcons,   TRUE,
    ASLFR_InitialDrawer, "SYS:Prefs/Presets",
    ASLFR_DoSaveMode,    TRUE,
  EndObject;

  if((openreq == NULL) || (savereq == NULL)) {
    Printf((char *) msgTextNoFileRequester);
    Printf("\n");
    return FALSE;
  }

  // Update the checkmark for "Create Icons?"
  {
    struct Menu     *menu = NULL;
    struct MenuItem *item;

    GetAttr( WINDOW_MenuStrip, WO_Window, (ULONG *) &menu);
    ClearMenuStrip(window);

    item = FindMenuItem(ACTID_ICONS);

    if(item) {
      if(SaveIcons)
        item->Flags |= CHECKED;
      else
        item->Flags &= ~CHECKED;
    }
    ResetMenuStrip(window, menu);
  }

  GUINewUnit();
  return TRUE;
}
Example #7
0
/* Loads an area */
int Game::LoadMap(const char* ResRef, bool loadscreen)
{
	unsigned int i, ret;
	Map *newMap;
	PluginHolder<MapMgr> mM(IE_ARE_CLASS_ID);
	ScriptEngine *sE = core->GetGUIScriptEngine();

	//this shouldn't happen
	if (!mM) {
		return -1;
	}

	int index = FindMap(ResRef);
	if (index>=0) {
		return index;
	}

	bool hide = false;
	if (loadscreen && sE) {
		hide = core->HideGCWindow();
		sE->RunFunction("LoadScreen", "StartLoadScreen");
		sE->RunFunction("LoadScreen", "SetLoadScreen");
	}
	DataStream* ds = gamedata->GetResource( ResRef, IE_ARE_CLASS_ID );
	if (!ds) {
		goto failedload;
	}
	if(!mM->Open(ds)) {
		goto failedload;
	}
	newMap = mM->GetMap(ResRef, IsDay());
	if (!newMap) {
		goto failedload;
	}

	core->LoadProgress(100);

	ret = AddMap( newMap );

	//spawn creatures on a map already in the game
	//this feature exists in all blackisle games but not in bioware games
	if (core->HasFeature(GF_SPAWN_INI)) {
		newMap->LoadIniSpawn();
	}

	for (i = 0; i < PCs.size(); i++) {
		if (stricmp( PCs[i]->Area, ResRef ) == 0) {
			newMap->AddActor( PCs[i], false );
		}
	}

	PlacePersistents(newMap, ResRef);

	if (hide) {
		core->UnhideGCWindow();
	}
	newMap->InitActors();

	return ret;
failedload:
	if (hide) {
		core->UnhideGCWindow();
	}
	core->LoadProgress(100);
	return -1;
}
Example #8
0
static void *
MapPhysAddress(unsigned long address, unsigned long size)
{
    unsigned long offset, delta;
    int pagesize = -1;
    void *vaddr;
    MapPtr mp;
#if defined(ISC) && defined(HAS_SVR3_MMAP)
    struct kd_memloc mloc;
#elif defined(__EMX__)
    APIRET rc;
    ULONG action;
    HFILE hfd;
#endif

    if ((mp = FindMap(address, size))) {
	mp->refcount++;
	return (void *)((unsigned long)mp->vaddr + mp->delta);
    }

#if defined(_SC_PAGESIZE) && defined(HAS_SC_PAGESIZE)
    pagesize = sysconf(_SC_PAGESIZE);
#endif
#ifdef _SC_PAGE_SIZE
    if (pagesize == -1)
	pagesize = sysconf(_SC_PAGE_SIZE);
#endif
#ifdef HAS_GETPAGESIZE
    if (pagesize == -1)
	pagesize = getpagesize();
#endif
#ifdef PAGE_SIZE
    if (pagesize == -1)
	pagesize = PAGE_SIZE;
#endif
    if (pagesize == -1)
	pagesize = 4096;

   delta = address % pagesize;
   offset = address - delta;

#if defined(ISC) && defined(HAS_SVR3_MMAP)
    if (mapFd < 0) {
	if ((mapFd = open("/dev/mmap", O_RDWR)) < 0)
	    return NULL;
    }
    mloc.vaddr = (char *)0;
    mloc.physaddr = (char *)offset;
    mloc.length = size + delta;
    mloc.ioflg=1;

    if ((vaddr = (void *)ioctl(mapFd, MAP, &mloc)) == (void *)-1)
	return NULL;
#elif defined (__EMX__)
    /*
     * Dragon warning here! /dev/pmap$ is never closed, except on progam exit.
     * Consecutive calling of this routine will make PMAP$ driver run out
     * of memory handles. Some umap/close mechanism should be provided
     */

    rc = DosOpen("/dev/pmap$", &hfd, &action, 0, FILE_NORMAL, FILE_OPEN,
		 OPEN_ACCESS_READWRITE | OPEN_SHARE_DENYNONE, (PEAOP2)NULL);
    if (rc != 0)
	return NULL;
    {
	struct map_ioctl {
		union {
			ULONG phys;
			void* user;
		} a;
		ULONG size;
	} pmap,dmap;
	ULONG plen,dlen;
#define XFREE86_PMAP	0x76
#define PMAP_MAP	0x44

	pmap.a.phys = offset;
	pmap.size = size + delta;
	rc = DosDevIOCtl(hfd, XFREE86_PMAP, PMAP_MAP,
			 (PULONG)&pmap, sizeof(pmap), &plen,
			 (PULONG)&dmap, sizeof(dmap), &dlen);
	if (rc == 0) {
		vaddr = dmap.a.user;
	}
   }
   if (rc != 0)
	return NULL;
#elif defined (Lynx)
    vaddr = (void *)smem_create("XF86DGA", (char *)offset, 
				size + delta, SM_READ|SM_WRITE);
#else
#ifndef MAP_FILE
#define MAP_FILE 0
#endif
    if (mapFd < 0) {
	if ((mapFd = open(DEV_MEM, O_RDWR)) < 0)
	    return NULL;
    }
    vaddr = (void *)mmap(NULL, size + delta, PROT_READ | PROT_WRITE,
                        MAP_FILE | MAP_SHARED, mapFd, (off_t)offset);
    if (vaddr == (void *)-1)
	return NULL;
#endif

    if (!vaddr) {
	if (!(mp = AddMap()))
	    return NULL;
	mp->physaddr = address;
	mp->size = size;
	mp->delta = delta;
	mp->vaddr = vaddr;
	mp->refcount = 1;
    }
    return (void *)((unsigned long)vaddr + delta);
}
Example #9
0
/*
    The following cases apply:

    Make black transparent
    Make white transparent
    Make any color transparent
    Make background transparent
 */
PERROR OpenGUI(FRAME *frame, struct Objects *o, struct Values *v, struct PPTBase *PPTBase)
{
    struct Library *BGUIBase = PPTBase->lb_BGUI;
    struct Screen *scr = PPTBase->g->maindisp->scr;
    struct Library *ColorWheelBase = o->ColorWheelBase;
    struct GfxBase *GfxBase = PPTBase->lb_Gfx;
    struct IntuitionBase *IntuitionBase = PPTBase->lb_Intuition;
    BOOL   V39 = FALSE;
    struct ColorWheelRGB rgb;
    struct ColorWheelHSB hsb;

    sprintf(o->wtitle, MYNAME ": %s", frame->name );

    if( PPTBase->lb_Gfx->LibNode.lib_Version >= 39 ) {
        int i;

        V39 = TRUE;
        rgb.cw_Red   = 0;
        rgb.cw_Green = 0;
        rgb.cw_Blue  = 0;
        ConvertRGBToHSB( &rgb, &hsb );

        for( i = 0; i < GRADCOLORS; i++ ) {
            hsb.cw_Brightness = (ULONG)0xffffffff - (((ULONG)0xffffffff / GRADCOLORS ) * i );
            ConvertHSBToRGB( &hsb, &rgb );
            if( -1 == (o->pens[i] = ObtainBestPen( scr->ViewPort.ColorMap,
                                                  rgb.cw_Red, rgb.cw_Green, rgb.cw_Blue,
                                                  TAG_DONE ) ) ) {
                break;
            }
        }
        o->pens[i] = ~0;
        o->numpens = i;

        o->Gradient = ExternalObject,
            GA_ID,          GID_GRADIENTSLIDER,
            EXT_MinWidth,   10,
            EXT_MinHeight,  10,
            EXT_ClassID,    "gradientslider.gadget",
            EXT_NoRebuild,  TRUE,
            GRAD_PenArray,  o->pens,
            PGA_Freedom,    LORIENT_VERT,
        EndObject;

        if( o->Gradient )
            GetAttr( EXT_Object, o->Gradient, (ULONG *) &o->RealGradient );
    }

    o->Win = WindowObject,
        WINDOW_Screen,      scr,
        WINDOW_Title,       o->wtitle,
        WINDOW_ScreenTitle, "Transparency: Click on the image to choose a color",
        v->window.Height ? TAG_IGNORE : TAG_SKIP, 1,
        WINDOW_Bounds,      &v->window,

        WINDOW_ScaleWidth,  30,
        WINDOW_NoBufferRP,  TRUE,
        WINDOW_MenuStrip,   mymenus,
        // WINDOW_HelpFile,    "Docs/effects.guide",
        // WINDOW_HelpNode,    "Transparency",
        // WINDOW_HelpText,    infoblurb,
        WINDOW_CloseOnEsc,  TRUE,
        WINDOW_MasterGroup,
            VGroupObject, Spacing(4), HOffset(6), VOffset(4),
                StartMember,
                    HGroupObject, Spacing(6),
                        StartMember,
                            VGroupObject, Spacing(4),
                                StartMember,
                                    InfoObject,
                                        INFO_TextFormat, ISEQ_C "Please, do select\n"
                                                         "which color should be\n"
                                                         "transparent:",
                                        INFO_MinLines, 3,
                                        ButtonFrame, FRM_Flags, FRF_RECESSED,
                                    EndObject,
                                    LGO_NoAlign, TRUE,
                                EndMember,
                                VarSpace(25),
                                StartMember,
                                    VGroupObject,
                                        StartMember,
                                            HGroupObject, Spacing(3),
                                                StartMember,
                                                    o->Red = SliderObject,
                                                        GA_ID, GID_RED,
                                                        Label("Red"), Place(PLACE_LEFT),
                                                        SLIDER_Min, 0,
                                                        SLIDER_Max, 255,
                                                        SLIDER_Level, v->r,
                                                    EndObject,
                                                EndMember,
                                                StartMember,
                                                    o->RedI = StringObject,
                                                        GA_ID, GID_REDI,
                                                        STRINGA_MinCharsVisible,4,
                                                        STRINGA_MaxChars, 3,
                                                        STRINGA_IntegerMin, 0,
                                                        STRINGA_IntegerMax, 255,
                                                        STRINGA_LongVal, v->r,
                                                    EndObject, Weight(1),
                                                EndMember,
                                            EndObject, FixMinHeight,
                                        EndMember,
                                        StartMember,
                                            HGroupObject, Spacing(3),
                                                StartMember,
                                                    o->Green = SliderObject,
                                                        GA_ID, GID_GREEN,
                                                        Label("Green"), Place(PLACE_LEFT),
                                                        SLIDER_Min, 0,
                                                        SLIDER_Max, 255,
                                                        SLIDER_Level, v->g,
                                                    EndObject,
                                                EndMember,
                                                StartMember,
                                                    o->GreenI = StringObject,
                                                        GA_ID, GID_GREENI,
                                                        STRINGA_MinCharsVisible,4,
                                                        STRINGA_MaxChars, 3,
                                                        STRINGA_IntegerMin, 0,
                                                        STRINGA_IntegerMax, 255,
                                                        STRINGA_LongVal, v->g,
                                                    EndObject, Weight(1),
                                                EndMember,
                                            EndObject, FixMinHeight,
                                        EndMember,
                                        StartMember,
                                            HGroupObject, Spacing(3),
                                                StartMember,
                                                    o->Blue = SliderObject,
                                                        GA_ID, GID_BLUE,
                                                        Label("Blue"), Place(PLACE_LEFT),
                                                        SLIDER_Min, 0,
                                                        SLIDER_Max, 255,
                                                        SLIDER_Level, v->b,
                                                    EndObject,
                                                EndMember,
                                                StartMember,
                                                    o->BlueI = StringObject,
                                                        GA_ID, GID_BLUEI,
                                                        STRINGA_MinCharsVisible,4,
                                                        STRINGA_MaxChars, 3,
                                                        STRINGA_IntegerMin, 0,
                                                        STRINGA_IntegerMax, 255,
                                                        STRINGA_LongVal, v->b,
                                                    EndObject, Weight(1),
                                                EndMember,
                                            EndObject,  FixMinHeight,
                                        EndMember,
                                     EndObject,
                                EndMember,
                                VarSpace(25),
                            EndObject,  LGO_NoAlign, TRUE,
                        EndMember,
                        (V39) ? TAG_IGNORE : TAG_SKIP, 2,
                        StartMember,
                            o->Wheel = ExternalObject,
                                EXT_MinWidth,           30,
                                EXT_MinHeight,          30,
                                EXT_ClassID,            "colorwheel.gadget",
                                WHEEL_Screen,           scr,
                                /*
                                **      Pass a pointer to the "real" gradient slider
                                **      here.
                                **/
                                WHEEL_GradientSlider,   o->RealGradient,
                                WHEEL_Red,              v->r * 0x01010101,
                                WHEEL_Green,            v->g * 0x01010101,
                                WHEEL_Blue,             v->b * 0x01010101,
                                GA_FollowMouse,         TRUE,
                                GA_ID,                  GID_WHEEL,
                                /*
                                **      These attributes of the colorwheel are
                                **      tracked and reset to the object after
                                **      it has been rebuild. This way the current
                                **      colorwheel internals will not be lost
                                **      after the object is re-build.
                                **/
                                EXT_TrackAttr,          WHEEL_Red,
                                EXT_TrackAttr,          WHEEL_Green,
                                EXT_TrackAttr,          WHEEL_Blue,
                                EXT_TrackAttr,          WHEEL_Hue,
                                EXT_TrackAttr,          WHEEL_Saturation,
                                EXT_TrackAttr,          WHEEL_Brightness,
                            EndObject,
                        EndMember,
                        (V39) ? TAG_IGNORE : TAG_SKIP, 3,
                        StartMember,
                            o->Gradient, FixWidth(20),
                        EndMember,
                    EndObject, LGO_NoAlign, TRUE,
                EndMember,
                StartMember,
                    HGroupObject,
                        StartMember,
                            o->Trans = SliderObject,
                                GA_ID, GID_TRANSPARENCY,
                                Label("Transparency:"), Place(PLACE_LEFT),
                                SLIDER_Min, 0,
                                SLIDER_Max, 255,
                                SLIDER_Level, v->transp,
                            EndObject,
                        EndMember,
                        StartMember,
                            o->TransI = StringObject,
                                GA_ID, GID_TRANSPARENCYI,
                                STRINGA_MinCharsVisible,4,
                                STRINGA_MaxChars, 3,
                                STRINGA_IntegerMin, 0,
                                STRINGA_IntegerMax, 255,
                                STRINGA_LongVal, v->transp,
                            EndObject, Weight(1),
                        EndMember,
                    EndObject, FixMinHeight,
                EndMember,
                StartMember,
                    HGroupObject, NormalSpacing,
                        StartMember,
                            o->All = CheckBoxObject,
                                GA_ID, GID_ALL,
                                Label("All colors?"),
                                GA_Selected, (v->mode == MODE_ALL) ? TRUE : FALSE,
                            EndObject, Weight(1),
                        EndMember,
                        StartMember,
                            o->Tolerance = SliderObject,
                                GA_ID, GID_TOLERANCE,
                                Label("Tolerance:"), Place(PLACE_LEFT),
                                SLIDER_Min, 0,
                                SLIDER_Max, 255,
                                SLIDER_Level, v->tolerance,
                            EndObject,
                        EndMember,
                        StartMember,
                            o->ToleranceI = StringObject,
                                GA_ID, GID_TOLERANCEI,
                                STRINGA_MinCharsVisible, 4,
                                STRINGA_MaxChars, 3,
                                STRINGA_IntegerMin, 0,
                                STRINGA_IntegerMax, 255,
                                STRINGA_LongVal, v->tolerance,
                            EndObject, Weight(1),
                        EndMember,
                    EndObject, FixMinHeight,
                EndMember,
                StartMember,
                    HorizSeparator,
                EndMember,
                StartMember,
                    HGroupObject,
                        StartMember,
                            ButtonObject,
                                GA_ID, GID_OK,
                                Label("OK"), Place(PLACE_IN),
                            EndObject,
                        EndMember,
                        VarSpace(DEFAULT_WEIGHT/2),
                        StartMember,
                            ButtonObject,
                                GA_ID, GID_CANCEL,
                                Label("Cancel"), Place(PLACE_IN),
                            EndObject,
                        EndMember,
                    EndObject, FixMinHeight,
                EndMember,
            EndObject,
    EndObject;

    if( o->Win ) {

        /*
         *  Attach the gadgets unto each other
         */

        AddMap( o->Trans, o->TransI, dpcol_sl2int );
        AddMap( o->TransI,o->Trans,  dpcol_int2sl );
        AddMap( o->Red, o->RedI, dpcol_sl2int );
        AddMap( o->RedI,o->Red,  dpcol_int2sl );
        AddMap( o->Green, o->GreenI, dpcol_sl2int );
        AddMap( o->GreenI,o->Green,  dpcol_int2sl );
        AddMap( o->Blue, o->BlueI, dpcol_sl2int );
        AddMap( o->BlueI,o->Blue,  dpcol_int2sl );
        AddMap( o->Tolerance, o->ToleranceI, dpcol_sl2int );
        AddMap( o->ToleranceI,o->Tolerance,  dpcol_int2sl );

        AddCondit( o->All, o->Red, GA_Selected, FALSE,
                   GA_Disabled, FALSE, GA_Disabled, TRUE );
        AddCondit( o->All, o->RedI, GA_Selected, FALSE,
                   GA_Disabled, FALSE, GA_Disabled, TRUE );
        AddCondit( o->All, o->Green, GA_Selected, FALSE,
                   GA_Disabled, FALSE, GA_Disabled, TRUE );
        AddCondit( o->All, o->GreenI, GA_Selected, FALSE,
                   GA_Disabled, FALSE, GA_Disabled, TRUE );
        AddCondit( o->All, o->Blue, GA_Selected, FALSE,
                   GA_Disabled, FALSE, GA_Disabled, TRUE );
        AddCondit( o->All, o->BlueI, GA_Selected, FALSE,
                   GA_Disabled, FALSE, GA_Disabled, TRUE );
        AddCondit( o->All, o->ToleranceI, GA_Selected, FALSE,
                   GA_Disabled, FALSE, GA_Disabled, TRUE );
        AddCondit( o->All, o->Tolerance, GA_Selected, FALSE,
                   GA_Disabled, FALSE, GA_Disabled, TRUE );
        if(V39) {
            AddCondit( o->All, o->Wheel, GA_Selected, FALSE,
                       GA_Disabled, FALSE, GA_Disabled, TRUE );
            AddCondit( o->All, o->Gradient, GA_Selected, FALSE,
                       GA_Disabled, FALSE, GA_Disabled, TRUE );
        }

        if( o->win = WindowOpen(o->Win) ) {
            /* This sets the other gadgets disabled or enabled */
            SetGadgetAttrs( (struct Gadget *)o->All, o->win, NULL,
                            GA_Selected, (v->mode == MODE_ALL) ? TRUE : FALSE, TAG_DONE );
        } else {
            DisposeObject(o->Win);
        }
    }

    return (BOOL)(o->win ? PERR_OK : PERR_WINDOWOPEN);
}
Example #10
0
CTobCompiler::EToken CTobCompiler::CompilePass1()
{
    EToken r, LastToken;
    CString str, buf, sizebuf;
    CByteArray* bin;
    SValueType* val;
    SExpression* exp;

    for(;;)
    {
        BOOL bSkipGetToken = FALSE;
        if ((r = GetToken(str)) <= 0) return r;
_SkipGetToken:
        if (r == SYM_DEF)
        {
/*
            if (m_bin.GetSize() > 0)
            {
                m_err = "const token can not defined after data";
                return ERR_NORMAL;
            }
*/
            if ((r = GetToken(str)) < 0) return r;
            if (r != SYM_TOKEN)
            {
                m_err = "not found token after '@'";
                return ERR_NORMAL;
            }

            if (str == "_IGNORECASE")
            {
                m_Option.bIgnoreCase = TRUE;
                continue;
            }

            if ((r = GetToken(buf)) < 0) return r;
            if (r == SYM_BIN)
            {
                bin = new CByteArray;
                if ((r = GetBinary(*bin)) < 0) { delete bin; return r; }
                AddMap(m_binmap, str, bin);
            }
            else if (r == SYM_STR)
            {
                bin = new CByteArray;
                if ((r = GetString(*bin)) < 0) { delete bin; return r; }
                AddMap(m_binmap, str, bin);
            }
            else if (r == SYM_INT)
            {
                ULONG Length;
                BOOL bHex = (buf[0] == '0' && buf[1] == 'x');

                r = GetToken(sizebuf);
                LastToken = r;
                if (r == SYM_TYPE)
                {
                    r = GetToken(sizebuf);
                    if (r != SYM_TOKEN)
                    {
                        m_err = "not found type after ':'";
                        return ERR_NORMAL;
                    }

                    Length = GetSizeFromType(sizebuf[0]);
                    if (Length == -1)
                    {
                        m_err.Format("unknown type '%c' after ':'", sizebuf[0]);
                        return ERR_NORMAL;
                    }
                }
                else
                {
                    Length = -1;
                }
                val = new SValueType((int)strtoul(buf, NULL, bHex ? 16 : 10), Length);
                AddMap(m_valmap, str, val);

                if (Length == -1)
                    bSkipGetToken = TRUE;

                r = SYM_INT;
            }
            else if (r == SYM_FLOAT)
            {
                AddMap(m_valmap, str, new SValueType(atof(buf)));
            }
            else
            {
                m_err.Format("not found '[' or ''' or '\"' or number after '@%s'", (LPCTSTR)str);
                return ERR_NORMAL;
            }

            if (m_Option.bIgnoreCase)
                str.MakeUpper();

            if (str == "_DEFI")
            {
                if (r != SYM_INT || val->ival < 1 || val->ival > 4)
                {
                    m_err = "_DEFI must be 1/2/3/4";
                    return ERR_NORMAL;
                }
                m_Option.DefInt = val->ival;
            }
            else if (str == "_DEFF")
            {
                if (r != SYM_INT || val->ival != 4 && val->ival != 8)
                {
                    m_err = "_DEFF must be 4/8";
                    return ERR_NORMAL;
                }
                m_Option.DefFloat = val->ival;
            }
            else if (str == "_MOD")
            {
                if (r != SYM_INT)
                {
                    m_err = "_MOD must be number";
                    return ERR_NORMAL;
                }

                while (m_bin.GetSize() % val->ival)
                    m_bin.Add(0);
            }
            else if (str == "_INCLUDE")
            {
                FILE *fsrc;
                WCHAR szPath[MAX_PATH];
                CByteArray *bin;

                if (m_Option.bIgnoreCase)
                    str.MakeLower();

                if (!m_binmap.Lookup(str, bin))
                    continue;

                m_binmap.RemoveKey(str);

                MultiByteToWideChar(
                    CP_GB2312,
                    0,
                    (LPSTR)bin->GetData(),
                    -1,
                    szPath,
                    countof(szPath));

                delete bin;

                fsrc = m_fsrc;
                m_fsrc = _wfopen(szPath, L"rb");
                if (m_fsrc == NULL)
                {
                    m_fsrc = fsrc;
                    m_err.Format("can't open include file '%S'", szPath);
                    return ERR_SEVERE;
                }
                else
                {
                    EToken r;
                    for(;;)
                    {
                        r = CompilePass1();
                        if (r == ERR_EOF)
                            break;

                        if (r < 0)
                        {
                            if (!ErrorHandlerInternal(GetErrorString(m_err)))
                                break;
                        }

                        if (r == ERR_SEVERE)
                            break;
                    }

                    fclose(m_fsrc);
                    m_fsrc = fsrc;
                    if (r < 0)
                        return r;
                }
            }

            if (bSkipGetToken)
            {
                str = sizebuf;
                r = LastToken;
                goto _SkipGetToken;
            }
        }
        else if (r == SYM_BIN)
        {
            if ((r = GetBinary(m_bin)) < 0) return r;
        }
        else if (r == SYM_STR)
        {
            if ((r = GetString(m_bin)) < 0) return r;
        }
        else if (r == SYM_TOKEN)
        {
            if (!m_binmap.Lookup(str, bin))
            {
                m_err.Format("unknown token '%s'", (LPCTSTR)str);
                return ERR_NORMAL;
            }
            m_bin.Append(*bin);
        }
        else if (r == SYM_LABEL)
        {
            if ((r = GetToken(str)) < 0) return r;
            if (r != SYM_TOKEN)
            {
                m_err = "not found token after '#'";
                return ERR_NORMAL;
            }
            if (m_valmap.Lookup(str, val))
            {
                m_err.Format("already defined label token '%s'", (LPCTSTR)str);
                return ERR_NORMAL;
            }
            m_valmap.SetAt(str, new SValueType(m_bin.GetSize()));
        }
        else if (r == SYM_EXP_BEGIN)
        {
            int i = m_exparr.GetSize();
            do
            {
                int len = m_Option.DefInt;
                BOOL hastype = FALSE;
                exp = new SExpression(m_bin.GetSize(), m_line);
                for(;;)
                {
                    if ((r = GetToken(buf)) < 0)
                    {
                        delete exp;
                        return r;
                    }

                    if (r == SYM_TOKEN)
                    {
                        val = NULL;
                        if (!hastype && len > 0 && m_valmap.Lookup(buf, val) && val->isfloat)
                            len = -m_Option.DefFloat;
                        exp->m_item.Add(buf);
                        if (val != NULL && val->m_size != -1)
                            len = val->isfloat ? -val->m_size : val->m_size;
                    }
                    else if (r == SYM_ADD)
                    {
                        exp->m_item.Add("+");
                    }
                    else if (r == SYM_SUB)
                    {
                        exp->m_item.Add("-");
                    }
                    else if (r == SYM_DEF)
                    {
                        exp->m_item.Add("@");
                    }
                    else if (r == SYM_INT)
                    {
                        exp->m_item.Add(buf);
                    }
                    else if (r == SYM_FLOAT)
                    {
                        if (!hastype && len > 0)
                            len = -m_Option.DefFloat;
                        exp->m_item.Add(buf);
                    }
                    else if (r == SYM_TYPE)
                    {
                        int newlen;
                        if ((r = GetToken(buf)) < 0) { delete exp; return r; }
                        if (r != SYM_TOKEN)
                        {
                            delete exp;
                            m_err = "not found type after ':'";
                            return ERR_NORMAL;
                        }

                        newlen = GetSizeFromType(buf[0]);
                        if (newlen == -1)
                        {
                            delete exp;
                            m_err.Format("unknown type '%c' after ':'", buf[0]);
                            return ERR_NORMAL;
                        }

                        if (hastype && newlen != len)
                        {
                            delete exp;
                            m_err = "found different types in one expression";
                            return ERR_NORMAL;
                        }
                        hastype = TRUE;
                        len = newlen;
                    }
                    else if (r == SYM_BIN)
                    {
                        if (exp->m_item.GetSize() > 0)
                        {
                            delete exp;
                            m_err = "found different types in one expression";
                            return ERR_NORMAL;
                        }
                        if ((r = GetBinary(m_bin)) < 0) { delete exp; return r; }
                    }
                    else if (r == SYM_STR)
                    {
                        if (exp->m_item.GetSize() > 0)
                        {
                            delete exp;
                            m_err = "found different types in one expression";
                            return ERR_NORMAL;
                        }
                        if ((r = GetString(m_bin)) < 0) { delete exp; return r; }
                    }
                    else if (r == SYM_NEXT || r == SYM_EXP_END)
                    {
                        break;
                    }
                    else
                    {
                        delete exp;
                        m_err.Format("unknown or bad symbol1 '%s' in expression", (LPCTSTR)str);
                        return ERR_NORMAL;
                    }
                }
                if (exp->m_item.GetSize() <= 0)
                {
                    delete exp;
                }
                else
                {
                    exp->m_size = len;
                    m_exparr.Add(exp);
                    if (len < 0) len = -len;
                    while(len--)
                        m_bin.Add(0);
                }
            }
            while(r != SYM_EXP_END);
            for(int j = m_exparr.GetSize(); i < j; ++i)
                m_exparr[i]->m_self = m_bin.GetSize();
        }
        else
        {
            m_err.Format("unknown or bad symbol2 '%s'", (LPCTSTR)str);
            return ERR_NORMAL;
        }
    }
}
Example #11
0
	void ScreenMap::Initialization(vector<Map> &maps)
	{
		AddMap(maps);
		Reset();

	}
STDMETHODIMP ESource::InitEvent(IDispatch *SourceDispatch,
                 OrxScript *ORexxScript,
                 FILE *LogFile)
{
    ITypeInfo *SourceType;
    TYPEATTR  *TypeAttributes;
    BSTR       SourceName;
    unsigned int NameCount;
    int        i;
    FUNCDESC  *FuncDesc;
    char       DispIDName[29];
    PEMAP      NewMap;
    HRESULT    RetCode=S_OK;
    int        EMCount;

    FPRINTF2(LogFile,"created a new Event Source. %p\n",this);
    FPRINTF2(DLLlogfile,"created a new Event Source.%p\n",this);
    EventType = AddScriptlet;
    Source = SourceDispatch;   // Mimick the ParseProcedures "THIS" parameter by returning this pointer.
    Engine = ORexxScript;
    Connected = false;
    ConnectionPoint = NULL;
    Container = NULL;
    logfile = LogFile;

    RetCode = GetTypeInfo(&SourceType);
    if (SUCCEEDED(RetCode))
    {
        RetCode = SourceType->GetTypeAttr(&TypeAttributes);
        memcpy(&SourceGUID,&TypeAttributes->guid,sizeof(GUID));
        EMCount = TypeAttributes->cFuncs;
        SourceType->ReleaseTypeAttr(TypeAttributes);
        OLECHAR    lGUID[50];
        StringFromGUID2(SourceGUID,lGUID,sizeof(lGUID));
        FPRINTF2(logfile,"The GUID is %S and there are %d functions.\n",lGUID,EMCount);

        /*    For each entry in the type library, create an entry on the Event Map chain.
         *  This is a many to one relation.  Each of the different Source Disp ID's
         *  will translate to the same Sink Disp ID.  There is only one chunk of code
         *  being bound to this Event that the Type Library is describing.  So every
         *  Source call must map to the same Sink.
         */
        for (i=0; i<EMCount; i++)
        {
            SourceType->GetFuncDesc(i, &FuncDesc);
            //  Despite what the documentation says, this returns Max Names, not Max Names - 1.
            // The first name is the function name, the remainder if they exist are parameters.
            SourceType->GetNames(FuncDesc->memid, &SourceName, 1, &NameCount);
            sprintf(DispIDName,"%d",FuncDesc->memid);
            //  This creates the entry for the function with an invalid DispID to call.
            RetCode = AddMap(DispIDName,&NewMap);
            if (FAILED(RetCode)) return RetCode;
            FPRINTF2(logfile,"ESource::InitEvent - AddScriptlet \"%S\" \n",SourceName);
            NewMap->SourceEventName = SourceName;
            SourceType->ReleaseFuncDesc(FuncDesc);
        }

        SourceType->Release();
    }
    else
    {
        FPRINTF2(logfile,"Could not obtain TypInfo for this event! HRESULT %08x\n",RetCode);
    }
    return RetCode;
}
Example #13
0
BOOL GimmeWindow(FRAME *frame, FRAME *with, struct PPTBase *PPTBase )
{
    strcpy(wtitle,MYNAME": ");
    strcat(wtitle, frame->name);

    Win = WindowObject,
        WINDOW_Screen,      PPTBase->g->maindisp->scr,
        WINDOW_Title,       wtitle,
        v.bounds.Top != ~0 ? TAG_IGNORE : TAG_SKIP, 1,
        WINDOW_Bounds,      &v.bounds,
        WINDOW_Position,    POS_CENTERSCREEN,
        WINDOW_Font,        PPTBase->g->userprefs->mainfont,
        WINDOW_MasterGroup,
            VGroupObject, Spacing(4), HOffset(4), VOffset(4),
                StartMember,
                    InfoTxt = InfoObject,
                        INFO_TextFormat, ISEQ_C"Please position the source\n"
                                               "over the destination...",
                        INFO_MinLines, 3,
                    EndObject,
                EndMember,
                StartMember,
                    InfoObject,
                        Label("Destination:"),
                        ButtonFrame,
                        FRM_Flags, FRF_RECESSED,
                        INFO_TextFormat, frame->name,
                    EndObject,
                EndMember,
                StartMember,
                    InfoObject,
                        Label("Source:"),
                        ButtonFrame,
                        FRM_Flags, FRF_RECESSED,
                        INFO_TextFormat, with ? with->name : "None",
                    EndObject,
                EndMember,
                StartMember,
                    Method = CycleObject, GA_ID, GID_METHOD,
                        Label("Method:"),
                        Place(PLACE_LEFT),
                        ButtonFrame,
                        CYC_Active, v.method,
                        CYC_Labels, method_labels,
                        CYC_Popup,  TRUE,
                    EndObject,
                EndMember,
                StartMember,
                    HGroupObject,
                        StartMember,
                            Ratio = SliderObject, GA_ID, GID_RATIO,
                                Label("Ratio:"),
                                Place(PLACE_LEFT),
                                SLIDER_Min,   0,
                                SLIDER_Max,   255,
                                SLIDER_Level, v.ratio,
                                PGA_Freedom,  FREEHORIZ,
                            EndObject,
                        EndMember,
                        StartMember,
                            RatioI = IndicatorObject,
                                INDIC_Min, 0,
                                INDIC_Max, 255,
                                INDIC_Level, v.ratio,
                                INDIC_Justification, IDJ_RIGHT,
                                INDIC_FormatString, "%3ld",
                            EndObject, FixMinWidth,
                        EndMember,
                    EndObject,
                EndMember,
                StartMember,
                    Tile = CheckBoxObject,
                        GA_ID, GID_TILE,
                        Label("Tile source?"), Place(PLACE_LEFT),
                        GA_Selected, v.tile,
                    EndObject, FixMinSize,
                EndMember,
                StartMember,
                    HGroupObject, Spacing(6),
                        StartMember,
                            OKButton = ButtonObject,
                                GA_ID, GID_OK,
                                Label("OK"),
                                GA_Disabled, FALSE,
                            EndObject,
                        EndMember,
                        StartMember,
                            Button("Cancel", GID_CANCEL),
                        EndMember,
                    EndObject,
                EndMember,
            EndObject,
        EndObject;

    if(Win) {

        AddMap( Ratio, RatioI, sl2ind );
        AddCondit( Method, Ratio,  CYC_Active, Mix, GA_Disabled, FALSE, GA_Disabled, TRUE );
        AddCondit( Method, RatioI, CYC_Active, Mix, GA_Disabled, FALSE, GA_Disabled, TRUE );

        if( v.method != Mix ) {
            SetGadgetAttrs( (struct Gadget *)Ratio, NULL, NULL, GA_Disabled, TRUE, TAG_DONE );
            SetGadgetAttrs( (struct Gadget *)RatioI, NULL, NULL, GA_Disabled, TRUE, TAG_DONE );
        }

        win = WindowOpen(Win);
        if(!win) {
            SetErrorCode(frame,PERR_WINDOWOPEN);
            DisposeObject(Win);
            return FALSE;
        }
    } else
        return FALSE;

    return TRUE;
}