Beispiel #1
0
void CHistoryPane::OnSize(UINT nType, int cx, int cy) 
{
	CStatic::OnSize(nType, cx, cy);
  Update();
  RedrawWindow();
}
Beispiel #2
0
		Interval Validity(TimeValue t) {Interval v; Update(t,v); return ivalid;}
Beispiel #3
0
const Matrix4f Camera::GetMatrix()
{
  Update();
  return mat;
}
Beispiel #4
0
	ThreadsTableModel(Team* team)
		:
		fTeam(team)
	{
		Update(-1);
	}
Beispiel #5
0
 /**
  * Updates the time stamp, setting it to the current clock plus the
  * specified offset.
  */
 void UpdateWithOffset(int offset) {
   Update();
   last += offset;
 }
Beispiel #6
0
void XyzWindow::On_Adjust()
{
	Update(XY_VIEW);
	Update(XZ_VIEW);
	Update(ZY_VIEW);
}
void cIncrementalRedstoneSimulator::Simulate(float a_dt)
{
	for (auto & DelayInfo : m_Data.m_MechanismDelays)
	{
		if ((--DelayInfo.second.first) == 0)
		{
			m_Data.GetActiveBlocks().emplace_back(DelayInfo.first);
		}
	}

	// Build our work queue
	cVector3iArray WorkQueue;
	std::swap(WorkQueue, m_Data.GetActiveBlocks());

	// Process the work queue
	while (!WorkQueue.empty())
	{
		// Grab the first element and remove it from the list
		Vector3i CurrentLocation = WorkQueue.back();
		WorkQueue.pop_back();

		BLOCKTYPE CurrentBlock;
		NIBBLETYPE CurrentMeta;
		if (!m_World.GetBlockTypeMeta(CurrentLocation.x, CurrentLocation.y, CurrentLocation.z, CurrentBlock, CurrentMeta))
		{
			continue;
		}

		auto CurrentHandler = cIncrementalRedstoneSimulator::CreateComponent(m_World, CurrentBlock, &m_Data);
		if (CurrentHandler == nullptr)  // Block at CurrentPosition doesn't have a corresponding redstone handler
		{
			// Clean up cached PowerData for CurrentPosition
			static_cast<cIncrementalRedstoneSimulator *>(m_World.GetRedstoneSimulator())->GetChunkData()->ErasePowerData(CurrentLocation);

			continue;
		}

		cRedstoneHandler::PoweringData Power;
		for (const auto & Location : CurrentHandler->GetValidSourcePositions(CurrentLocation, CurrentBlock, CurrentMeta))
		{
			if (!cChunk::IsValidHeight(Location.y))
			{
				continue;
			}
			BLOCKTYPE PotentialBlock;
			NIBBLETYPE PotentialMeta;
			m_World.GetBlockTypeMeta(Location.x, Location.y, Location.z, PotentialBlock, PotentialMeta);

			auto PotentialSourceHandler = cIncrementalRedstoneSimulator::CreateComponent(m_World, PotentialBlock, &m_Data);
			if (PotentialSourceHandler == nullptr)
			{
				continue;
			}

			decltype(Power) PotentialPower(PotentialBlock, PotentialSourceHandler->GetPowerDeliveredToPosition(Location, PotentialBlock, PotentialMeta, CurrentLocation, CurrentBlock));
			Power = std::max(Power, PotentialPower);
		}

		// Inform the handler to update
		cVector3iArray Updates = CurrentHandler->Update(CurrentLocation, CurrentBlock, CurrentMeta, Power);
		WorkQueue.insert(WorkQueue.end(), Updates.begin(), Updates.end());

		if (IsAlwaysTicked(CurrentBlock))
		{
			m_Data.GetActiveBlocks().emplace_back(CurrentLocation);
		}
	}
}
Beispiel #8
0
void VideoColourSpace::SetBrightness(int value)
{
    m_brightness = (value * 0.02f) - 1.0f;
    Update();
}
Beispiel #9
0
void VideoColourSpace::SetContrast(int value)
{
    m_contrast = value * 0.02f;
    Update();
}
Beispiel #10
0
void VideoColourSpace::SetColourSpace(VideoCStd csp)
{
    m_colourSpace = csp;
    Update();
}
Beispiel #11
0
void VideoColourSpace::SetStudioLevels(bool studio)
{
    m_studioLevels = studio;
    Update();
}
void CLibraryFolderCtrl::Update(CLibraryFolder* pFolder, HTREEITEM hFolder, HTREEITEM hParent, DWORD nUpdateCookie, BOOL bRecurse)
{
	if ( ! hFolder )
	{
		DWORD dwStyle = INDEXTOOVERLAYMASK( pFolder->IsShared() ? 0 : SHI_O_LOCKED );

		if ( pFolder->m_sPath.CompareNoCase( Settings.Downloads.CompletePath ) == 0 ) dwStyle |= TVIS_BOLD;

		if ( m_bMultiSelect && GetFirstSelectedItem() == NULL ) dwStyle |= TVIS_SELECTED;
		if ( pFolder->m_bExpanded ) dwStyle |= TVIS_EXPANDED;

		CString strName = pFolder->m_sName;

		if ( pFolder->m_pParent == NULL )
		{
			CString strDrive;
			if ( pFolder->m_sPath.Find( _T(":\\") ) == 1 || pFolder->m_sPath.GetLength() == 2 )
				strDrive.Format( _T(" (%c:)"), pFolder->m_sPath[0] );
			else
				strDrive = _T(" (Net)");

			strName += strDrive;
			dwStyle |= TVIS_EXPANDED;
		}

		hFolder = InsertItem( TVIF_PARAM|TVIF_TEXT|TVIF_IMAGE|TVIF_SELECTEDIMAGE|TVIF_STATE,
			strName, SHI_FOLDER_CLOSED, SHI_FOLDER_CLOSED, dwStyle,
			TVIS_EXPANDED|TVIS_SELECTED|TVIS_OVERLAYMASK, (LPARAM)pFolder, hParent, TVI_SORT );
	}
	else
	{
		DWORD dwMask = TVIS_OVERLAYMASK | TVIS_BOLD;
		DWORD dwStyle = INDEXTOOVERLAYMASK( pFolder->IsShared() ? 0 : SHI_O_LOCKED );

		if ( pFolder->m_sPath.CompareNoCase( Settings.Downloads.CompletePath ) == 0 ) dwStyle |= TVIS_BOLD;

		DWORD dwExisting = GetItemState( hFolder, dwMask ) & dwMask;

		if ( dwExisting != dwStyle ) SetItemState( hFolder, dwStyle, dwMask );
	}

	if ( nUpdateCookie )
	{
		if ( bRecurse || ( GetItemState( hFolder, TVIS_SELECTED ) & TVIS_SELECTED ) )
		{
			pFolder->m_nSelectCookie = nUpdateCookie;
			bRecurse |= ( GetItemState( hFolder, TVIS_EXPANDED ) & TVIS_EXPANDED ) == 0;
		}
	}

	CPtrList pAlready;

	for ( HTREEITEM hItem = GetChildItem( hFolder ) ; hItem ; )
	{
		HTREEITEM hNext = GetNextSiblingItem( hItem );

		CLibraryFolder* pChild = (CLibraryFolder*)GetItemData( hItem );

		if ( pFolder->CheckFolder( pChild ) )
		{
			Update( pChild, hItem, NULL, nUpdateCookie, bRecurse );
			pAlready.AddTail( pChild );
		}
		else
		{
			DeleteItem( hItem );
		}

		hItem = hNext;
	}

	for ( POSITION pos = pFolder->GetFolderIterator() ; pos ; )
	{
		CLibraryFolder* pChild = pFolder->GetNextFolder( pos );

		if ( pAlready.Find( pChild ) == NULL )
		{
			Update( pChild, NULL, hFolder, nUpdateCookie, bRecurse );
		}
	}

	int nOldImage1, nOldImage2;
	GetItemImage( hFolder, nOldImage1, nOldImage2 );

	int nImage = ItemHasChildren( hFolder ) && ( GetItemState( hFolder, TVIS_EXPANDED ) & TVIS_EXPANDED );
	nImage = nImage ? SHI_FOLDER_OPEN : SHI_FOLDER_CLOSED;
	if ( nOldImage1 != nImage ) SetItemImage( hFolder, nImage, nImage );
}
Beispiel #13
0
void PhaseMgr::UnRegisterPhasingAuraEffect(AuraEffect const* auraEffect)
{
    _UpdateFlags |= phaseData.RemoveAuraInfo(auraEffect->GetId());

    Update();
}
Beispiel #14
0
	float Random::Generate(float low, float high)
	{
		Update();
		return (seed & BRICKS_RANDOM_MAX) * (high - low) / BRICKS_RANDOM_MAX + low;
	}
Beispiel #15
0
void XyzWindow::YSliderChanged(int i)
{
	//   sliderChanged(2 , i);
	cy = i;
	Update(XZ_VIEW);
}
Beispiel #16
0
void VideoColourSpace::SetHue(int value)
{
    m_hue = value * (-3.6f * M_PI / 180.0f);
    Update();
}
Beispiel #17
0
void XyzWindow::ZSliderChanged(int i)
{
	//   sliderChanged(3 ,i);
	cz = i;
	Update(XY_VIEW);
}
Beispiel #18
0
void VideoColourSpace::SetSaturation(int value)
{
    m_saturation = value * 0.02f;
    Update();
}
Beispiel #19
0
void World::UpdatePos(float x, float y)
{
    _x = x;
    _y = y;
    Update();
}
Beispiel #20
0
bool wxGenericProgressDialog::Create( const wxString& title,
                                      const wxString& message,
                                      int maximum,
                                      wxWindow *parent,
                                      int style )
{
    SetTopParent(parent);

    m_parentTop = wxGetTopLevelParent(parent);
    m_pdStyle = style;

    wxWindow* const
        realParent = GetParentForModalDialog(parent, GetWindowStyle());

    if (!wxDialog::Create(realParent, wxID_ANY, title))
        return false;

    SetMaximum(maximum);

    // We need a running event loop in order to update the dialog and be able
    // to process clicks on its buttons, so ensure that there is one running
    // even if this means we have to start it ourselves (this happens most
    // commonly during the program initialization, e.g. for the progress
    // dialogs shown from overridden wxApp::OnInit()).
    if ( !wxEventLoopBase::GetActive() )
    {
        m_tempEventLoop = new wxEventLoop;
        wxEventLoop::SetActive(m_tempEventLoop);
    }

#if defined(__WXMSW__) && !defined(__WXUNIVERSAL__)
    // we have to remove the "Close" button from the title bar then as it is
    // confusing to have it - it doesn't work anyhow
    //
    // FIXME: should probably have a (extended?) window style for this
    if ( !HasPDFlag(wxPD_CAN_ABORT) )
    {
        EnableCloseButton(false);
    }
#endif // wxMSW

    m_state = HasPDFlag(wxPD_CAN_ABORT) ? Continue : Uncancelable;

    // top-level sizerTop
    wxSizer * const sizerTop = new wxBoxSizer(wxVERTICAL);

    m_msg = new wxStaticText(this, wxID_ANY, message);
    sizerTop->Add(m_msg, 0, wxLEFT | wxRIGHT | wxTOP, 2*LAYOUT_MARGIN);

    int gauge_style = wxGA_HORIZONTAL;
    if ( style & wxPD_SMOOTH )
        gauge_style |= wxGA_SMOOTH;
    gauge_style |= wxGA_PROGRESS;

#ifdef __WXMSW__
    maximum /= m_factor;
#endif

    m_gauge = new wxGauge
                  (
                    this,
                    wxID_ANY,
                    maximum,
                    wxDefaultPosition,
                    // make the progress bar sufficiently long
                    wxSize(wxMin(wxGetClientDisplayRect().width/3, 300), -1),
                    gauge_style
                  );

    sizerTop->Add(m_gauge, 0, wxLEFT | wxRIGHT | wxTOP | wxEXPAND, 2*LAYOUT_MARGIN);
    m_gauge->SetValue(0);

    // create the estimated/remaining/total time zones if requested
    m_elapsed =
    m_estimated =
    m_remaining = NULL;

    // also count how many labels we really have
    size_t nTimeLabels = 0;

    wxSizer * const sizerLabels = new wxFlexGridSizer(2);

    if ( style & wxPD_ELAPSED_TIME )
    {
        nTimeLabels++;

        m_elapsed = CreateLabel(GetElapsedLabel(), sizerLabels);
    }

    if ( style & wxPD_ESTIMATED_TIME )
    {
        nTimeLabels++;

        m_estimated = CreateLabel(GetEstimatedLabel(), sizerLabels);
    }

    if ( style & wxPD_REMAINING_TIME )
    {
        nTimeLabels++;

        m_remaining = CreateLabel(GetRemainingLabel(), sizerLabels);
    }
    sizerTop->Add(sizerLabels, 0, wxALIGN_CENTER_HORIZONTAL | wxTOP, LAYOUT_MARGIN);

    m_btnAbort =
    m_btnSkip = NULL;

    wxBoxSizer *buttonSizer = new wxBoxSizer(wxHORIZONTAL);

    const int borderFlags =
#if defined(__WXMSW__) || defined(__WXOSX__)
        wxALL
#else
        wxBOTTOM | wxTOP
#endif
        ;

    const wxSizerFlags sizerFlags
        = wxSizerFlags().Border(borderFlags, LAYOUT_MARGIN);

    if ( HasPDFlag(wxPD_CAN_SKIP) )
    {
        m_btnSkip = new wxButton(this, wxID_SKIP, _("&Skip"));

        buttonSizer->Add(m_btnSkip, sizerFlags);
    }

    if ( HasPDFlag(wxPD_CAN_ABORT) )
    {
        m_btnAbort = new wxButton(this, wxID_CANCEL);

        buttonSizer->Add(m_btnAbort, sizerFlags);
    }

    if ( !HasPDFlag(wxPD_CAN_SKIP | wxPD_CAN_ABORT) )
        buttonSizer->AddSpacer(LAYOUT_MARGIN);

    sizerTop->Add(buttonSizer, sizerFlags);

    SetSizerAndFit(sizerTop);

    Centre(wxCENTER_FRAME | wxBOTH);

    DisableOtherWindows();

    Show();
    Enable();

    // this one can be initialized even if the others are unknown for now
    //
    // NB: do it after calling Layout() to keep the labels correctly aligned
    if ( m_elapsed )
    {
        SetTimeLabel(0, m_elapsed);
    }

    Update();
    return true;
}
//------------------------------------------------------------
// Game loop
//------------------------------------------------------------
void PlayDemo()
{
	Update();
	RenderFrame();
}
Beispiel #22
0
bool
wxGenericProgressDialog::Update(int value, const wxString& newmsg, bool *skip)
{
    if ( !DoBeforeUpdate(skip) )
        return false;

    wxCHECK_MSG( m_gauge, false, "dialog should be fully created" );

#ifdef __WXMSW__
    value /= m_factor;
#endif // __WXMSW__

    wxASSERT_MSG( value <= m_maximum, wxT("invalid progress value") );

    m_gauge->SetValue(value);

    UpdateMessage(newmsg);

    if ( (m_elapsed || m_remaining || m_estimated) && (value != 0) )
    {
        unsigned long elapsed;
        unsigned long display_remaining;

        UpdateTimeEstimates( value,
                             elapsed,
                             m_display_estimated,
                             display_remaining );

        SetTimeLabel(elapsed, m_elapsed);
        SetTimeLabel(m_display_estimated, m_estimated);
        SetTimeLabel(display_remaining, m_remaining);
    }

    if ( value == m_maximum )
    {
        if ( m_state == Finished )
        {
            // ignore multiple calls to Update(m_maximum): it may sometimes be
            // troublesome to ensure that Update() is not called twice with the
            // same value (e.g. because of the rounding errors) and if we don't
            // return now we're going to generate asserts below
            return true;
        }

        // so that we return true below and that out [Cancel] handler knew what
        // to do
        m_state = Finished;
        if( !HasPDFlag(wxPD_AUTO_HIDE) )
        {
            EnableClose();
            DisableSkip();
#if defined(__WXMSW__) && !defined(__WXUNIVERSAL__)
            EnableCloseButton();
#endif // __WXMSW__

            if ( newmsg.empty() )
            {
                // also provide the finishing message if the application didn't
                m_msg->SetLabel(_("Done."));
            }

            // allow the window to repaint:
            // NOTE: since we yield only for UI events with this call, there
            //       should be no side-effects
            wxEventLoopBase::GetActive()->YieldFor(wxEVT_CATEGORY_UI);

            // NOTE: this call results in a new event loop being created
            //       and to a call to ProcessPendingEvents() (which may generate
            //       unwanted re-entrancies).
            (void)ShowModal();
        }
        else // auto hide
        {
            // reenable other windows before hiding this one because otherwise
            // Windows wouldn't give the focus back to the window which had
            // been previously focused because it would still be disabled
            ReenableOtherWindows();

            Hide();
        }
    }
    else // not at maximum yet
    {
        DoAfterUpdate();
    }

    // update the display in case yielding above didn't do it
    Update();

    return m_state != Canceled;
}
Beispiel #23
0
	~ThreadsTableModel()
	{
		fTeam = NULL;
		Update(-1);
	}
Beispiel #24
0
void Debugger_Disasm::RemoveBreakpoint()
{
	CBreakPoints::RemoveBreakPoint(breakpointAddr);
	Update();
}
Beispiel #25
0
/// <summary>
/// Creates the main window and begins processing
/// </summary>
/// <param name="hInstance">handle to the application instance</param>
/// <param name="nCmdShow">whether to display minimized, maximized, or normally</param>
int CDataCollection::Run(HINSTANCE hInstance, int nCmdShow)
{
    MSG       msg = {0};
    WNDCLASS  wc;

    // Dialog custom window class
    ZeroMemory(&wc, sizeof(wc));
    wc.style         = CS_HREDRAW | CS_VREDRAW;
    wc.cbWndExtra    = DLGWINDOWEXTRA;
    wc.hInstance     = hInstance;
    wc.hCursor       = LoadCursor(NULL, IDC_ARROW);
    wc.hIcon         = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_APP));
    wc.lpfnWndProc   = DefDlgProc;
    wc.lpszClassName = L"DataCollectionAppDlgWndClass";

    if (!RegisterClass(&wc))
    {
        return 0;
    }

    // Create main application window
    HWND hWndApp = CreateDialogParam(
        hInstance,
        MAKEINTRESOURCE(IDD_APP),
        NULL,
        (DLGPROC)CDataCollection::MessageRouter, 
        reinterpret_cast<LPARAM>(this));

    // Show window
    ShowWindow(hWndApp, nCmdShow);

    const int eventCount = 2;
	HANDLE hEvents[eventCount]={m_hNextColorFrameEvent, m_hNextSkeletonEvent};

	
    // Main message loop
    while (WM_QUIT != msg.message)
    {
        

        // Check to see if we have either a message (by passing in QS_ALLINPUT)
        // Or a Kinect event (hEvents)
        // Update() will check for Kinect events individually, in case more than one are signalled
        DWORD dwEvent = MsgWaitForMultipleObjects(eventCount, hEvents, FALSE, INFINITE, QS_ALLINPUT);
	    
        // Check if this is an event we're waiting on and not a timeout or message
        if ((WAIT_OBJECT_0 == dwEvent)||(WAIT_OBJECT_0+1)==dwEvent)
        {
			
            Update();
        }
		
        if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
        {
            // If a dialog message will be taken care of by the dialog proc
            if ((hWndApp != NULL) && IsDialogMessage(hWndApp, &msg))
            {
                continue;
            }

            TranslateMessage(&msg);
            DispatchMessageW(&msg);
        }
    }

    return static_cast<int>(msg.wParam);
}
Beispiel #26
0
void Debugger_Disasm::on_clearAllBP_clicked()
{
	CBreakPoints::ClearAllBreakPoints();
	Update();
}
Beispiel #27
0
void Engine::Run()
{
    while(!endProcess_)
    {
        while(SDL_PollEvent(&event_))
        {
            switch(event_.type)
            {

            ModuleManager::Instance()->SetType(event_.type);

            case SDL_ACTIVEEVENT:
            {
                if (event_.active.gain == 0)
                {
                    active_ ^= true;
                }
                break;
            }
            case SDL_VIDEORESIZE:
            {
                screen_ = SDL_SetVideoMode(
                              event_.resize.w,
                              event_.resize.h,
                              bits_, videoFlags_
                          );

                Resize (event_.resize.w, event_.resize.h);
                width_  = event_.resize.w;
                height_ = event_.resize.h;
                break;
            }
            case SDL_MOUSEBUTTONDOWN:
            {
                ModuleManager::Instance()->SetType(SDL_MOUSEBUTTONDOWN);
                ModuleManager::Instance()->MouseButtonDown(event_);
                break;
            }
            case SDL_MOUSEMOTION:
            {
                ModuleManager::Instance()->SetType(SDL_MOUSEMOTION);
                ModuleManager::Instance()->MouseMotion(event_);
            }
            case SDL_KEYDOWN:
            {
                ModuleManager::Instance()->KeyDown(event_.key.keysym.sym);
                if(event_.key.keysym.sym == SDLK_F1)
                {
                    fullscreen_ ^= true;
                    SDL_LockSurface(screen_);
                    ToggleFullscreen();
                    SDL_UnlockSurface(screen_);
                }
                else if(event_.key.keysym.sym == SDLK_F2)
                {
                    showFPS_ ^= true;
                }
                else if(event_.key.keysym.sym == SDLK_F3)
                {
                    ModuleManager::Instance()->ActivateNext();
                }
                else if(event_.key.keysym.sym == SDLK_ESCAPE)
                {
                    endProcess_ = true;
                }
                break;
            }
            case SDL_KEYUP:
            {
                ModuleManager::Instance()->KeyUp(event_.key.keysym.sym);
                break;
            }
            case SDL_QUIT:
            {
                endProcess_ = true;
                break;
            }
            default:
            {
                ModuleManager::Instance()->SetType(event_.type);
            }
            }
        }

        if(timer_->ReadyForNextFrame())
        {
            Update(timer_->TimeElapsed());
        }

        Render();
        SDL_GL_SwapBuffers();
    }
}
Beispiel #28
0
void Debugger_Disasm::GotoThreadEntryPoint()
{
	ui->DisasmView->gotoAddr(threadRowSelected->data(4,Qt::UserRole).toInt());
	Update();
}
Beispiel #29
0
int CzCamera::LoadFromXoml(IzXomlResource* parent, bool load_children, CzXmlNode* node)
{
	// Process attributes
	for (CzXmlNode::_AttribIterator it = node->attribs_begin(); it != node->attribs_end(); it++)
	{
		unsigned int name_hash = (*it)->getName().getHash();

		if (name_hash == CzHashes::Name_Hash)
			setName((*it)->getValue().c_str());
		else
		if (name_hash == CzHashes::Tag_Hash)
			setTag((*it)->getValue().c_str());
		else
		if (name_hash == CzHashes::Position_Hash)
		{
			if (!(*it)->getValueAsPoint(Position))
				CzDebug::Log(CZ_DEBUG_CHANNEL_WARNING, "Camera - Invalid value for Camera::Position", DebugInfo.c_str());
		}
		else
		if (name_hash == CzHashes::Angle_Hash)
			Angle = (*it)->getValueAsFloat();
		else
		if (name_hash == CzHashes::Scale_Hash)
			Scale = (*it)->getValueAsFloat();
		else
		if (name_hash == CzHashes::TargetX_Hash)
			setTargetX((*it)->getValue().c_str());
		else
		if (name_hash == CzHashes::TargetY_Hash)
			setTargetY((*it)->getValue().c_str());
		else
		if (name_hash == CzHashes::VelocityDamping_Hash)
		{
			if (!(*it)->getValueAsPoint(VelocityDamping))
				CzDebug::Log(CZ_DEBUG_CHANNEL_WARNING, "Camera - Invalid value for Camera::VelocityDamping", DebugInfo.c_str());
		}
		else
		if (name_hash == CzHashes::FollowSpeed_Hash)
		{
			if (!(*it)->getValueAsPoint(FollowSpeed))
				CzDebug::Log(CZ_DEBUG_CHANNEL_WARNING, "Camera - Invalid value for Camera::FollowSpeed", DebugInfo.c_str());
		}
		else
		if (name_hash == CzHashes::TouchPanX_Hash)
			setTouchPanX((*it)->getValueAsBool());
		else
		if (name_hash == CzHashes::TouchPanY_Hash)
			setTouchPanY((*it)->getValueAsBool());
		else
		if (name_hash == CzHashes::IgnoreActors_Hash)
			setIgnoreActors((*it)->getValueAsBool());
	}

	// If we are declared inside a scene then shape is local to the scene
	CzScene* scene = NULL;
	if (parent != NULL && parent->getClassTypeHash() == CzHashes::Actor_Hash)
		scene = ((CzActor*)parent)->getScene();
	else
	if (parent != NULL && parent->getClassTypeHash() == CzHashes::Scene_Hash)
		scene = (CzScene*)parent;
	Scene = scene;

	bool ret = false;
	if (scene != NULL)
		ret = scene->getResourceManager()->addResource(this);
	else
		ret = CZ_GLOBAL_RESOURCES->getResourceManager()->addResource(this);

	if (!ret)
		return 0;

	Update(0);

	return 1;
}
Beispiel #30
0
int main () {
  ALLEGRO_DISPLAY *display;
  ALLEGRO_EVENT_QUEUE *eventQueue;
  ALLEGRO_TIMER *timer;

  bool done = false;

  al_init();
  display = al_create_display(1280, 720);
  al_set_window_title(display, "Height Liquid");
  eventQueue = al_create_event_queue();
  timer = al_create_timer(1.0/constFps);

  al_init_primitives_addon();
  al_install_keyboard();
  al_init_image_addon();

  al_register_event_source(eventQueue, al_get_display_event_source(display));
  al_register_event_source(eventQueue, al_get_timer_event_source(timer));
  al_register_event_source(eventQueue, al_get_keyboard_event_source());

  ALLEGRO_BITMAP *floor;

  float tileSize = 10.0; 
  const int nTilesHoriz = 1280/tileSize;
  const int nTilesVert   = 720/tileSize;
  const ALLEGRO_COLOR heightColors[6] = {
    al_map_rgb(255, 240, 200),
    al_map_rgb(200, 190, 150),
    al_map_rgb(180, 170, 120),
    al_map_rgb(160, 150, 100),
    al_map_rgb(140, 130, 70),
    al_map_rgb(120, 110, 50)
  };

  srand(time(0));
  int   **height;
  float **water;

  height = new int*[nTilesHoriz];
  water  = new float*[nTilesHoriz];
  for (int i = 0; i < nTilesHoriz; i++) {
    height[i] = new int[nTilesVert];
    water[i]  = new float[nTilesVert];
  }

  for (int i = 0; i < nTilesVert; i++) {
    for (int j = 0; j < nTilesHoriz; j++) {
      int v = rand()%100 + 1;
      if (v > 99)
        v = 5;
      else if (v > 98)
        v = 4;
      else if (v > 97)
        v = 3;
      else if (v > 96)
        v = 2;
      else if (v > 95)
        v = 1;
      else
        v = 0;

      height[j][i] = v;
      water[j][i] = 0;
    }
  }

  floor = al_create_bitmap(1280, 720);
  al_set_target_bitmap(floor);
  for (int i = 0; i < nTilesVert; i++) {
    for (int j = 0; j < nTilesHoriz; j++) {
      al_draw_filled_rectangle(j*tileSize, i*tileSize, (j+1)*tileSize, (i+1)*tileSize,
          heightColors[height[j][i]]);
    }
  }
  al_set_target_bitmap(al_get_backbuffer(display));

//  int waterSourceX = 1280/2;
//  int waterSourceY = 720/2;

  bool redraw = false;

  al_clear_to_color(al_map_rgb(0, 0, 0));
  al_start_timer(timer);
  while (!done) {
    ALLEGRO_EVENT ev;
    al_wait_for_event(eventQueue, &ev);

    if (ev.type == ALLEGRO_EVENT_TIMER) {
      redraw = true;
      Update(water, height, nTilesHoriz, nTilesVert);
    } else if (ev.type == ALLEGRO_EVENT_DISPLAY_CLOSE) {
      done = true;
    } else if (ev.type == ALLEGRO_EVENT_KEY_DOWN) {
      switch (ev.keyboard.keycode) {
        case ALLEGRO_KEY_Q:
        case ALLEGRO_KEY_ESCAPE:
          done = true;
          break;
      }
    }

    if (redraw && al_is_event_queue_empty(eventQueue)) {
      redraw = false;
      al_clear_to_color(al_map_rgb_f(0.0, 0.0, 0.0));

      al_draw_bitmap(floor, 0, 0, 0);
      for (int i = 0; i < nTilesVert; i++) {
        for (int j = 0; j < nTilesHoriz; j++) {
          float waterValue = water[j][i];
          if (waterValue > 5) waterValue = 5;
          if (waterValue > 0)
            al_draw_filled_rectangle(j*tileSize, i*tileSize,
                (j+1)*tileSize, (i+1)*tileSize, 
                al_map_rgba_f(0, 0, 1.0 - waterValue/10.0, 0.8));
        }
      }

      al_flip_display();
    }
  }

  for (int i = 0; i < nTilesHoriz; i++) {
    delete []height[i];
    delete []water[i];
  }
  delete []height;
  delete []water;

  al_destroy_bitmap(floor);
  al_destroy_timer(timer);
  al_destroy_event_queue(eventQueue);
  al_destroy_display(display);
}