GraphicsHandler::GraphicsHandler(HWND _hWnd, ConfigFile* _configFile) { this->m_deviceHandler = new DeviceHandler(_hWnd, _configFile->getWindowed(), _configFile->getScreenSize()); this->m_world = new World(this->m_deviceHandler, _hWnd, _configFile->getWindowed(), _configFile->getShadowMapResolution(), _configFile->getSSAO()); this->m_resourceHolder = new ResourceHolder(this->m_deviceHandler->getDevice()); this->m_windowed = _configFile->getWindowed(); this->m_shadowMapResolution = _configFile->getShadowMapResolution(); this->m_configScreenSize = _configFile->getScreenSize(); // If we run in windowed, set the real screen size to be config screen size or the bars and crap outside of the window are counted in if(_configFile->getWindowed()) { this->m_realScreenSize = _configFile->getScreenSize(); } // Else get the real screen size else { RECT rc; GetWindowRect(_hWnd, &rc); this->m_realScreenSize = INT2(rc.right-rc.left, rc.bottom-rc.top); } this->m_fpsText = this->createText("", INT2(300, 300), 40, D3DXCOLOR(1.0f, 0.2f, 0.2f, 1.0f)); }
//================================================================================================= void StatsPanel::Event(GuiEvent e) { GamePanel::Event(e); if(e == GuiEvent_Moved) { flow.global_pos = global_pos + flow.pos; scrollbar.global_pos = global_pos + scrollbar.pos; } else if(e == GuiEvent_Resize) { flow.size = size - INT2(44,48); scrollbar.pos = INT2(size.x-28, 48); scrollbar.global_pos = global_pos + scrollbar.pos; scrollbar.size = INT2(16, size.y-60); if(scrollbar.offset+scrollbar.part > scrollbar.total) scrollbar.offset = float(scrollbar.total-scrollbar.part); if(scrollbar.offset < 0) scrollbar.offset = 0; flow.moved = int(scrollbar.offset); } else if(e == GuiEvent_Show) SetText(); else if(e == GuiEvent_LostFocus) scrollbar.LostFocus(); }
//================================================================================================= Slider2::Slider2() : hold(false), minstep(false) { bt[0].text = '<'; bt[0].id = GuiEvent_Custom; bt[0].parent = this; bt[0].size = INT2(32,32); bt[1].text = '>'; bt[1].id = GuiEvent_Custom+1; bt[1].parent = this; bt[1].size = INT2(32,32); }
//================================================================================================= void Grid::Init() { scroll.pos = INT2(size.x-16,height); scroll.size = INT2(16,size.y-height); scroll.total = height*items; scroll.part = size.y; scroll.offset = 0; total_width = 0; for(vector<Column>::iterator it = columns.begin(), end = columns.end(); it != end; ++it) total_width += it->width; }
SpotLight::SpotLight(ID3D10Device* _device, FLOAT3 _position, FLOAT3 _direction, FLOAT3 _la, FLOAT3 _ld, FLOAT3 _ls, FLOAT2 _angle, float _range) { m_direction = _direction; //this->m_up = D3DXVECTOR3(0.0f, 0.0f, 1.0f); //D3DXVECTOR3 evilVector; //if(this->m_direction.x <= this->m_direction.y && this->m_direction.x <= this->m_direction.z && this->m_direction.x > 0) //{ // evilVector = D3DXVECTOR3(1.0f, 0.0f, 0.0f); //} //else if(this->m_direction.y <= this->m_direction.z && this->m_direction.y > 0) //{ // evilVector = D3DXVECTOR3(0.0f, 1.0f, 0.0f); //} //else //{ // evilVector = D3DXVECTOR3(0.0f, 0.0f, 1.0f); //} //D3DXVec3Cross(&this->m_up, &this->m_direction.toD3DXVector(), &evilVector); this->m_up = D3DXVECTOR3(1.0f, 0.0f, 0.0f); this->m_la = _la; this->m_ld = _ld; this->m_ls = _ls; this->m_angle = FLOAT2(cos(_angle.x / 2), cos(_angle.y / 2)); this->m_range = _range; m_shadowMap = new DepthStencil(_device, INT2(512, 512), false); this->setPosition(_position); }
/** Saves the patches to a file */ XRESULT GOcean::SavePatches(const std::string& file) { FILE* f = fopen(file.c_str(), "wb"); if(!f) return XR_FAILED; int version = 1; fwrite(&version, sizeof(version), 1, f); int count = Patches.size(); fwrite(&count, sizeof(count), 1, f); for(std::map<std::pair<int, int>, WaterPatchInfo>::iterator it = Patches.begin(); it != Patches.end(); it++) { INT2 xz = INT2((*it).first.first, (*it).first.second); // Write xz-coord fwrite(&xz, sizeof(xz), 1, f); // Write info-struct fwrite(&(*it).second, sizeof(WaterPatchInfo), 1, f); } fclose(f); }
/** * Returns the resolution needed for the given window */ INT2 RBaseDevice::GetWindowResolution(HWND hWnd) { RECT r; GetClientRect(OutputWindow, &r); return INT2(r.right - r.left, r.bottom - r.top); }
//================================================================================================= PickServerPanel::PickServerPanel(const DialogInfo& info) : Dialog(info) { size = INT2(524,340); bts.resize(2); txUnknownPacket = Str("unknownPacket"); txUnknownResponse = Str("unknownResponse"); txUnknownResponse2 = Str("unknownResponse2"); txBrokenResponse = Str("brokenResponse"); bts[0].size = INT2(180,44); bts[0].pos = INT2(336,30); bts[0].id = GuiEvent_Custom+BUTTON_OK; bts[0].text = Str("join"); bts[0].parent = this; bts[1].size = INT2(180,44); bts[1].pos = INT2(336,80); bts[1].id = GuiEvent_Custom+BUTTON_CANCEL; bts[1].text = GUI.txCancel; bts[1].parent = this; grid.pos = INT2(8,8); grid.size = INT2(320,300); grid.event = GridEvent(this, &PickServerPanel::GetCell); grid.AddColumn(Grid::IMGSET, 50); grid.AddColumn(Grid::TEXT_COLOR, 100, Str("players")); grid.AddColumn(Grid::TEXT_COLOR, 150, Str("name2")); grid.Init(); }
//================================================================================================= void CreateCharacterPanel::Update(float dt) { RenderUnit(); UpdateUnit(dt); // obracanie if(PointInRect(GUI.cursor_pos, INT2(pos.x+228,pos.y+94), INT2(128,256)) && Key.Focus() && focus) { if(Key.Down(VK_LBUTTON)) unit->rot = clip(unit->rot - float(GUI.cursor_pos.x - pos.x - 228 - 64)/16*dt); //dist = clamp(dist + GUI.mouse_wheel, -3.f, -1.f); } if(mode == PickClass) { for(int i=0; i<5; ++i) { bts[i].mouse_focus = focus; bts[i].Update(dt); } } else { for(int i=0; i<2; ++i) { bts2[i].mouse_focus = focus; bts2[i].Update(dt); } if(!game->IsOnline()) { checkbox.mouse_focus = focus; checkbox.Update(dt); } for(int i=0; i<5; ++i) { slider[i].mouse_focus = focus; slider[i].Update(dt); } } if(focus && Key.Focus() && Key.PressedRelease(VK_ESCAPE)) Event((GuiEvent)IdCancel); }
//================================================================================================= StatsPanel::StatsPanel(const INT2& _pos, const INT2& _size) { min_size = INT2(32,32); pos = global_pos = _pos; size = _size; txStatsPanel = Str("statsPanel"); txTraitsText = Str("traitsText"); txStatsText = Str("statsText"); txYearMonthDay = Str("yearMonthDay"); txBase = Str("base"); flow.pos = INT2(8,40); flow.global_pos = global_pos + flow.pos; flow.size = size - INT2(44,48); flow.parent = this; flow.moved = 0; flow.Add(new StaticText(Str("attributes"), GUI.fBig)); tAttribs = new StaticText("", GUI.default_font); flow.Add(tAttribs); flow.Add(new StaticText(Str("skills"), GUI.fBig)); tSkills = new StaticText("", GUI.default_font); flow.Add(tSkills); flow.Add(new StaticText(Str("traits"), GUI.fBig)); tTraits = new StaticText("", GUI.default_font); flow.Add(tTraits); flow.Add(new StaticText(Str("stats"), GUI.fBig)); tStats = new StaticText("", GUI.default_font); flow.Add(tStats); scrollbar.pos = INT2(size.x-28,48); scrollbar.size = INT2(16,size.y-60); scrollbar.global_pos = global_pos + scrollbar.pos; scrollbar.total = 100; scrollbar.offset = 0; scrollbar.part = 100; }
//================================================================================================= Controls::Controls(const DialogInfo& info) : Dialog(info), picked(-1) { size = INT2(570+8*2,368); bts.resize(2); bts[0].size = INT2(180,44); bts[0].pos = INT2(50,316); bts[0].id = Button_Reset; bts[0].text = Str("resetKeys"); bts[0].parent = this; bts[1].size = INT2(180,44); bts[1].pos = INT2(size.x-180-50,316); bts[1].id = Button_Ok; bts[1].text = GUI.txOk; bts[1].parent = this; grid.size = INT2(570,300); grid.pos = INT2(8,8); grid.AddColumn(Grid::TEXT, 200, Str("action")); grid.AddColumn(Grid::TEXT, 175, Str("key_1")); grid.AddColumn(Grid::TEXT, 175, Str("key_2")); grid.items = GK_MAX; grid.event = GridEvent(this, &Controls::GetCell); grid.select_event = SelectGridEvent(this, &Controls::SelectCell); grid.single_line = true; grid.selection_type = Grid::NONE; grid.Init(); InitKeyText(); }
void Cursor::setFrame(CURSOR_TYPE cursor, int _priority) { if(_priority >= this->m_priority) { int i = cursor; this->m_sprite->setCurrentFrame(INT2(i % 3, i / 3)); this->m_priority = _priority; } }
//================================================================================================= void GamePanel::UpdateButton(float dt) { bt_updated = true; if(GUI.HaveDialog()) return; if(PointInRect(GUI.cursor_pos, INT2(GUI.wnd_size.x-32, GUI.wnd_size.y-32), INT2(32,32)) && Key.Focus() && Key.PressedRelease(VK_LBUTTON)) { menu.visible = true; menu.focus = true; GUI.focused_ctrl = &menu; UpdateMenuText(); } if(menu.visible) menu.Update(dt); }
void LobbyMenu::setReady(int _playerIndex) { switch(_playerIndex) { case 0: m_Buttons[8]->setCurrentFrame(INT2(2, 0)); break; case 1: m_Buttons[9]->setCurrentFrame(INT2(2, 0)); break; case 2: m_Buttons[10]->setCurrentFrame(INT2(2, 0)); break; case 3: m_Buttons[11]->setCurrentFrame(INT2(2, 0)); break; } }//Level 1__MAPSIZE_SMALL__WAVES_20__STARTING DIVINE POWER_1500
//================================================================================================= void ListBox::Init(bool _extended) { extended = _extended; real_size = INT2(size.x-20,size.y); scrollbar.pos = INT2(size.x-16,0); scrollbar.size = INT2(16,size.y); scrollbar.offset = 0.f; scrollbar.total = items.size()*20; scrollbar.part = size.y-4; if(extended) { menu = new MenuList; menu->AddItems(texts); menu->visible = false; menu->Init(); menu->size.x = size.x; menu->event = DialogEvent(this, &ListBox::OnSelect); } }
//================================================================================================= MultiplayerPanel::MultiplayerPanel(const DialogInfo& info) : Dialog(info) { size = INT2(344,380); bts.resize(5); txMultiplayerGame = Str("multiplayerGame"); txNick = Str("nick"); txNeedEnterNick = Str("needEnterNick"); txEnterValidNick = Str("enterValidNick"); const INT2 bt_size(180,44); const int x = (size.x-bt_size.x)/2; bts[0].text = Str("joinLAN"); bts[0].parent = this; bts[0].id = IdJoinLan; bts[0].size = bt_size; bts[0].pos = INT2(x,100); bts[1].text = Str("joinIP"); bts[1].parent = this; bts[1].id = IdJoinIp; bts[1].size = bt_size; bts[1].pos = INT2(x,150); bts[2].text = Str("host"); bts[2].parent = this; bts[2].id = IdCreate; bts[2].size = bt_size; bts[2].pos = INT2(x,200); bts[3].text = Str("load"); bts[3].parent = this; bts[3].id = IdLoad; bts[3].size = bt_size; bts[3].pos = INT2(x,250); bts[4].text = GUI.txCancel; bts[4].parent = this; bts[4].id = IdCancel; bts[4].size = bt_size; bts[4].pos = INT2(x,300); textbox.limit = 16; textbox.parent = this; textbox.pos = INT2((size.x-200)/2, 57); textbox.size = INT2(200,32); visible = false; }
/** Blurs the backbuffer and puts the result into TempBufferDS4_2*/ void D3D11PFX_HDR::CreateBloom(RenderToTextureBuffer* lum) { D3D11GraphicsEngine* engine = (D3D11GraphicsEngine *)Engine::GraphicsEngine; INT2 dsRes = INT2(Engine::GraphicsEngine->GetResolution().x / 4, Engine::GraphicsEngine->GetResolution().y / 4); engine->GetShaderManager()->GetVShader("VS_PFX")->Apply(); D3D11PShader* tonemapPS = engine->GetShaderManager()->GetPShader("PS_PFX_Tonemap"); tonemapPS->Apply(); HDRSettingsConstantBuffer hcb; hcb.HDR_LumWhite = Engine::GAPI->GetRendererState()->RendererSettings.HDRLumWhite; hcb.HDR_MiddleGray = Engine::GAPI->GetRendererState()->RendererSettings.HDRMiddleGray; hcb.HDR_Threshold = Engine::GAPI->GetRendererState()->RendererSettings.BloomThreshold; tonemapPS->GetConstantBuffer()[0]->UpdateBuffer(&hcb); tonemapPS->GetConstantBuffer()[0]->BindToPixelShader(0); lum->BindToPixelShader(engine->GetContext(), 1); FxRenderer->CopyTextureToRTV(engine->GetHDRBackBuffer()->GetShaderResView(), FxRenderer->GetTempBufferDS4_1()->GetRenderTargetView(), dsRes, true); D3D11PShader* gaussPS = engine->GetShaderManager()->GetPShader("PS_PFX_GaussBlur"); /** Pass 1: Blur-H */ // Apply PFX-VS D3D11PShader* simplePS = engine->GetShaderManager()->GetPShader("PS_PFX_Simple"); // Apply blur-H shader gaussPS->Apply(); // Update settings BlurConstantBuffer bcb; bcb.B_BlurSize = 1.0f; bcb.B_PixelSize = float2(1.0f / FxRenderer->GetTempBufferDS4_1()->GetSizeX(), 0.0f); gaussPS->GetConstantBuffer()[0]->UpdateBuffer(&bcb); gaussPS->GetConstantBuffer()[0]->BindToPixelShader(0); // Copy FxRenderer->CopyTextureToRTV(FxRenderer->GetTempBufferDS4_1()->GetShaderResView(), FxRenderer->GetTempBufferDS4_2()->GetRenderTargetView(), dsRes, true); /** Pass 2: Blur V */ // Update settings bcb.B_BlurSize = 1.0f; bcb.B_PixelSize = float2(0.0f, 1.0f / FxRenderer->GetTempBufferDS4_1()->GetSizeY()); bcb.B_Threshold = 0.0f; gaussPS->GetConstantBuffer()[0]->UpdateBuffer(&bcb); gaussPS->GetConstantBuffer()[0]->BindToPixelShader(0); // Copy FxRenderer->CopyTextureToRTV(FxRenderer->GetTempBufferDS4_2()->GetShaderResView(), FxRenderer->GetTempBufferDS4_1()->GetRenderTargetView(), dsRes, true); }
//================================================================================================= void Slider2::Draw(ControlDrawData*) { const int D = 150; bt[0].global_pos = bt[0].pos = global_pos; bt[1].global_pos = bt[1].pos = bt[0].pos + INT2(D,0); for(int i=0; i<2; ++i) bt[i].Draw(); RECT r0 = {global_pos.x+32, global_pos.y-16, global_pos.x+D, global_pos.y+48}; GUI.DrawText(GUI.default_font, text, DT_CENTER|DT_VCENTER, BLACK, r0); }
/** Debug-draws the cubemap to the screen */ void D3D11PointLight::DebugDrawCubeMap() { if(!InitDone) return; D3D11GraphicsEngineBase* engineBase = (D3D11GraphicsEngineBase *)Engine::GraphicsEngine; D3D11GraphicsEngine* engine = (D3D11GraphicsEngine *) engineBase; // TODO: Remove and use newer system! const int previewSize = POINTLIGHT_SHADOWMAP_SIZE; const int previewDownscale = 4; for(int i=0;i<6;i++) { INT2 pPosition; int stride = (previewSize / previewDownscale); if(i==1) // x- { pPosition.x = 0; pPosition.y = stride; }else if(i==3) // y- { pPosition.x = stride; pPosition.y = stride; }else if(i==0) // x+ { pPosition.x = stride * 2; pPosition.y = stride; }else if(i==2) // y+ { pPosition.x = stride * 3; pPosition.y = stride; }else if(i==5) // z- { pPosition.x = stride; pPosition.y = 0; }else if(i==4) // z+ { pPosition.x = stride; pPosition.y = stride * 2; } INT2 pSize = INT2(previewSize / previewDownscale,previewSize / previewDownscale); ID3D11ShaderResourceView* srv = engine->GetDummyCubeRT()->GetSRVCubemapFace(i); engine->GetContext()->PSSetShaderResources(0,1, &srv); Engine::GraphicsEngine->DrawQuad(pPosition, pSize); } }
//================================================================================================= void ListBox::Draw(ControlDrawData*) { if(extended) { // box GUI.DrawItem(GUI.tBox, global_pos, size, WHITE, 8, 32); // element if(selected != -1) { RECT rc = {global_pos.x+2, global_pos.y+2, global_pos.x+size.x-12, global_pos.y+size.y-2}; GUI.DrawText(GUI.default_font, *texts[selected], DT_SINGLELINE, BLACK, rc, &rc); } // obrazek GUI.DrawSprite(GUI.tDown, INT2(global_pos.x+size.x-10, global_pos.y+(size.y-10)/2)); // powinno byæ tu ale wtedy by³a by z³a kolejnoœæ rysowania //if(menu->visible) // menu->Draw(); } else { // box GUI.DrawItem(GUI.tBox, global_pos, real_size, WHITE, 8, 32); // zaznaczenie RECT rc = {global_pos.x, global_pos.y, global_pos.x+real_size.x, global_pos.y+real_size.y}; if(selected != -1) { RECT rs = {global_pos.x+2, global_pos.y-int(scrollbar.offset)+2+selected*20, global_pos.x+real_size.x-2}; rs.bottom = rs.top + 20; RECT out; if(IntersectRect(&out, &rs, &rc)) GUI.DrawSpriteRect(GUI.tPix, out, COLOR_RGBA(0,255,0,128)); } // elementy RECT r = {global_pos.x+2, global_pos.y-int(scrollbar.offset)+2, global_pos.x+real_size.x-2, rc.bottom-2}; for(vector<string*>::iterator it = texts.begin(), end = texts.end(); it != end; ++it) { if(!GUI.DrawText(GUI.default_font, **it, DT_SINGLELINE, BLACK, r, &rc)) break; r.top += 20; } // pasek przewijania scrollbar.Draw(); } }
//int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR pScmdline, int iCmdshow) int main(int _argc, char** _argv) { EEDesc desc; desc.applicationName = L"Emerald"; //窗口名称 desc.isFullScreen = false; //是否全屏 desc.width = 800; //窗口宽度 desc.height = 450; //窗口高度 desc.isSSAA = true; //是开启抗锯齿 desc.isVsync = false; //是否垂直同步 EEInitialize(); // EETexture tex0(L"Texture\\etc\\101087.jpg"); EETexture tex1(L"Texture/etc/xmyrz.jpg"); EETexture tex1_gray = tex1.Clone(); EEGrayC gray(tex1_gray); gray.Process(); EEQuad2D quad(Rect_Float(0, 0, (float)EEGetWidth(), (float)EEGetHeight()), tex1); EEDilateC dilate(tex1, tex1_gray, INT2(2, 2)); dilate.Process(); EEErodeC erode(tex1, tex1_gray, INT2(2, 2)); erode.Process(); while (EERun()) { EEBeginScene(EEColor::BLACK); quad.Process(); printf("%d ", EEGetFPS()); EEEndScene(); } EEShutdown(); return 0; }
//================================================================================================= void GamePanel::Init(GamePanel* handler) { txEdit = Str("guiEdit"); txEndEdit = Str("guiEndEdit"); menu.event = DialogEvent(handler, &GamePanel::OnMenuClick); menu.AddItem(txEdit); menu.AddItem(Str("guiSave")); menu.AddItem(Str("guiLoad")); menu.AddItem(Str("guiRestore")); menu.PrepareItem(txEndEdit); menu.Init(); menu.global_pos = menu.pos = INT2(GUI.wnd_size.x-menu.size.x, GUI.wnd_size.y-menu.size.y); menu.visible = false; }
ConfigFile::ConfigFile() { this->m_windowed = DEFAULT_WINDOWED; this->m_screenSize = INT2(DEFAULT_SCREEN_WIDTH, DEFAULT_SCREEN_HEIGHT); this->m_musicVolume = DEFAULT_MUSIC_VOLUME; this->m_soundVolume = DEFAULT_SOUND_EFFECTS_VOLUME; this->m_speechVolume = DEFAULT_SPEECH_VOLUME; this->m_playerName = DEFAULT_PLAYER_NAME; this->m_emilMode = DEFAULT_EMILMODE; this->m_shadowMapResolution = DEFAULT_SHADOW_MAP_RESOLUTION; this->m_levelMode = DEFAULT_LEVELMODE; this->m_diffuse = DEFAULT_DIFFUSE; this->m_shadowmap = DEFAULT_SHADOWMAP; this->m_SSAO = DEFAULT_SSAO; this->m_textureQuality = DEFAULT_TEXTUREQUALITY; }
//================================================================================================= void ListBox::Update(float dt) { if(extended) { if(menu->visible) { // powinno byæ aktualizowane tu ale niestety wed³ug kolejnoœci musi byæ na samym pocz¹tku //menu->Update(dt); if(!menu->focus) menu->visible = false; } else if(mouse_focus && Key.Focus() && PointInRect(GUI.cursor_pos, global_pos, size) && Key.PressedRelease(VK_LBUTTON)) { menu->global_pos = global_pos + INT2(0,size.y); if(menu->global_pos.y+menu->size.y >= GUI.wnd_size.y) menu->global_pos.y = GUI.wnd_size.y-menu->size.y; menu->visible = true; menu->focus = true; } } else { if(mouse_focus && Key.Focus() && PointInRect(GUI.cursor_pos, global_pos, real_size) && Key.PressedRelease(VK_LBUTTON)) { int n = (GUI.cursor_pos.y-global_pos.y+int(scrollbar.offset))/20; if(n >= 0 && n < (int)items.size() && n != selected) { selected = n; if(e_change_index) e_change_index(n); } } if(IsInside(GUI.cursor_pos)) scrollbar.ApplyMouseWheel(); scrollbar.Update(dt); } }
void LobbyMenu::setPlayerName(int _playerIndex, string _name, bool changeText) { INT2 pos; switch(_playerIndex) { case 0: //pos = INT2(0.675f, 0.2f); pos = INT2(1920/2.0f*0.671f + 1920/2.0f, 1080/2.0f - 1080/2.0f*0.05f); m_Buttons[8]->setVisible(true); break; case 1: //pos = INT2(0.8f, 0.2f); pos = INT2(1920/2.0f*0.796f + 1920/2.0f, 1080/2.0f - 1080/2.0f*0.05f); m_Buttons[9]->setVisible(true); m_Buttons[9]->setCurrentFrame(INT2(1, 0)); break; case 2: //pos = INT2(0.675f, -0.2f); pos = INT2(1920/2.0f*0.671f + 1920/2.0f, 1080/2.0f - 1080/2.0f*(-0.175f)); m_Buttons[10]->setVisible(true); m_Buttons[10]->setCurrentFrame(INT2(1, 0)); break; case 3: //pos = INT2(0.8f, -0.2f); pos = INT2(1920/2.0f*0.796f + 1920/2.0f, 1080/2.0f - 1080/2.0f*(-0.17f)); m_Buttons[11]->setVisible(true); m_Buttons[11]->setCurrentFrame(INT2(1, 0)); break; } m_playerNames[_playerIndex] = new TextLabel(_name, "text2.png", pos, 50, true); if(changeText == true) { this->m_Label[4]->setText(_name); } }
void LobbyMenu::selectHero(int _playerIndex, Hero::HERO_TYPE _type, bool changeText) { FLOAT2 pos; int buttonIndex; switch(_playerIndex) { case 0: buttonIndex = 8; pos = m_Buttons[8]->getPos()+FLOAT2(0.0f, -0.08f); break; case 1: buttonIndex = 9; pos = m_Buttons[9]->getPos()+FLOAT2(0.0f, -0.08f); break; case 2: buttonIndex = 10; pos = m_Buttons[10]->getPos()+FLOAT2(0.0f, -0.08f); break; case 3: buttonIndex = 11; pos = m_Buttons[11]->getPos()+FLOAT2(0.0f, -0.08f); break; } switch(m_currentSelections[_playerIndex]) { case Hero::OFFICER: m_officerPortrait->setVisible(false); break; case Hero::RED_KNIGHT: m_redKnightPortrait->setVisible(false); break; case Hero::ENGINEER: m_engineerPortrait->setVisible(false); break; case Hero::DOCTOR: m_doctorPortrait->setVisible(false); break; case Hero::THE_MENTALIST: m_mentalistPortrait->setVisible(false); break; } switch(_type) { case Hero::OFFICER: this->m_officerPortrait->setPosition(pos); this->m_officerPortrait->setVisible(true); if(changeText == true) { this->m_Label[2]->setText("Officer"); this->m_Label[0]->setText("2__3__5__1__3"); this->m_Label[1]->setText("A captain of the Royal Airship Brigade, the officer is now commissioned to take charge_against the siege that has befallen Chevington. His leadership skills are a true_assets to the brave men and women stationed in the towers and siege weapons and his_skill with blade and rifle makes him a true plague upon anyone standing in his way."); this->m_Buttons[6]->setTexture("menu_textures\\O0.png"); this->m_Buttons[7]->setTexture("menu_textures\\O1.png"); delete this->m_Buttons[12]; delete this->m_Buttons[13]; this->m_Buttons[12] = new Button(); this->m_Buttons[12]->Init(FLOAT2(-0.85f, -0.5f),FLOAT2(0.079166667f,0.140740741f),m_skillHolder.getSkill(Skill::TARGET_ACQUIRED_PERMISSION_TO_FIRE),"",0,0,1,12,100,0,INT2(422,80), false, Skill::TARGET_ACQUIRED_PERMISSION_TO_FIRE,"menu_textures\\Skill_25.png"); this->m_Label[7]->setText("In melee, you need to get close to your enemy,_but are guaranteed to land every strike with_greater precision, effectively dealing more_damage."); this->m_Buttons[13] = new Button(); this->m_Buttons[13]->Init(FLOAT2(-0.85f, -0.7f),FLOAT2(0.079166667f,0.140740741f),m_skillHolder.getSkill(Skill::READY_AIM_FIRE),"",0,0,1,12,100,0,INT2(422,80), false, Skill::READY_AIM_FIRE,"menu_textures\\Skill_26.png"); this->m_Label[5]->setText("Bombardment____Ready aim fire"); if (m_Combat == 1) { this->m_Label[3]->setText("Range combat_"); this->m_Label[7]->setText("With ranged combat, you can rain damage_on your enemies from afar, but with distance_comes less accuracy and damage."); } } break; case Hero::RED_KNIGHT: this->m_redKnightPortrait->setPosition(pos); this->m_redKnightPortrait->setVisible(true); if(changeText == true) { this->m_Label[2]->setText("Red Knight"); this->m_Label[0]->setText("1__5__2__1__4"); this->m_Label[1]->setText("In a city where steam and cogs are the pinnacle of modern civilization, the ancient_order of Sword and Shield wielding knights seem a bit superfluous, but they are fierce_warriors and good men. Whenever Dark Powers show their ugly face, the Red Knights_descend upon them without mercy. This particular Knight is a paragon of his order_and instills courage in his comrades as he strikes down enemy after enemy."); this->m_Buttons[6]->setTexture("menu_textures\\R0.png"); this->m_Buttons[7]->setTexture("menu_textures\\R1.png"); this->m_Label[7]->setText("In melee, you need to get close to your enemy,_but are guaranteed to land every strike with_greater precision, effectively dealing more_damage."); delete this->m_Buttons[12]; delete this->m_Buttons[13]; this->m_Buttons[12] = new Button(); this->m_Buttons[12]->Init(FLOAT2(-0.85f, -0.5f),FLOAT2(0.079166667f,0.140740741f),m_skillHolder.getSkill(Skill::SWIFT_AS_A_CAT_POWERFUL_AS_A_BEAR),"",0,0,1,12,100,0,INT2(422,80), false, Skill::SWIFT_AS_A_CAT_POWERFUL_AS_A_BEAR,"menu_textures\\Skill_23.png"); this->m_Buttons[13] = new Button(); this->m_Buttons[13]->Init(FLOAT2(-0.85f, -0.7f),FLOAT2(0.079166667f,0.140740741f),m_skillHolder.getSkill(Skill::COURAGE_HONOR_VALOR),"",0,0,1,12,100,0,INT2(422,80), false, Skill::COURAGE_HONOR_VALOR,"menu_textures\\Skill_24.png"); this->m_Label[5]->setText("Mighty blow____Courage,Honor,Valor"); if (m_Combat == 1) { this->m_Label[3]->setText("Two-handed combat_"); this->m_Label[7]->setText("Armed with a two-handed weapon you are_able to strike multiple enemies with a blow._The heavy weight of the weapon does however_restrict your speed, making your strikes slower."); } } break; case Hero::ENGINEER: this->m_engineerPortrait->setPosition(pos); this->m_engineerPortrait->setVisible(true); if(changeText == true) { this->m_Label[2]->setText("Engineer"); this->m_Label[0]->setText("2__3__3__5__1"); this->m_Label[1]->setText("In the modern society of Chevington, the Engineer is a key figure on the forefront of_research and development.In a city where most things run on either steampower_, gunpowder or some innovative cog contraption,the society of engineer command much_power and a lot of wealth. This particular engineer is exceptionally intuitive and_probably understands machinery better than he understands people. Who better to_oversee the defense of a city highly reliant on such machines?"); this->m_Buttons[6]->setTexture("menu_textures\\E0.png"); this->m_Buttons[7]->setTexture("menu_textures\\E1.png"); delete this->m_Buttons[12]; delete this->m_Buttons[13]; this->m_Buttons[12] = new Button(); this->m_Buttons[12]->Init(FLOAT2(-0.85f, -0.5f),FLOAT2(0.079166667f,0.140740741f),m_skillHolder.getSkill(Skill::TIME_IS_MONEY),"",0,0,1,12,100,0,INT2(422,80), false, Skill::TIME_IS_MONEY,"menu_textures\\Skill_27.png"); this->m_Label[7]->setText("In melee, you need to get close to your enemy,_but are guaranteed to land every strike with_greater precision, effectively dealing more_damage."); this->m_Buttons[13] = new Button(); this->m_Buttons[13]->Init(FLOAT2(-0.85f, -0.7f),FLOAT2(0.079166667f,0.140740741f),m_skillHolder.getSkill(Skill::ENHANCED_DEVELOPMENT),"",0,0,1,12,100,0,INT2(422,80), false, Skill::ENHANCED_DEVELOPMENT,"menu_textures\\Skill_28.png"); this->m_Label[5]->setText("Time is money____Enhanced development"); if (m_Combat == 1) { this->m_Label[3]->setText("Range combat"); this->m_Label[7]->setText("With ranged combat, you can rain damage_on your enemies from afar, but with distance_comes less accuracy and damage."); } } break; case Hero::DOCTOR: this->m_doctorPortrait->setPosition(pos); this->m_doctorPortrait->setVisible(true); if(changeText == true) { this->m_Label[2]->setText("Doctor"); this->m_Label[0]->setText("1__1__3__5__3"); this->m_Label[1]->setText("A master of surgery, medicine and the art of healing, the Doctor is not only wanted,_but needed on the field of battle. Not only skilled in healing his allies and bringing_their spirits back, but also gifted with the ability to poison his enemies, making them_weaker and easier to kill, he is a force to be reckoned with and not a man you would_want to cross."); this->m_Buttons[6]->setTexture("menu_textures\\D0.png"); this->m_Buttons[7]->setTexture("menu_textures\\D1.png"); delete this->m_Buttons[12]; delete this->m_Buttons[13]; this->m_Buttons[12] = new Button(); this->m_Buttons[12]->Init(FLOAT2(-0.85f, -0.5f),FLOAT2(0.079166667f,0.140740741f),m_skillHolder.getSkill(Skill::SIMONS_EVIL),"",0,0,1,12,100,0,INT2(422,80), false, Skill::SIMONS_EVIL,"menu_textures\\Skill_15.png"); this->m_Label[7]->setText("In melee, you need to get close to your enemy,_but are guaranteed to land every strike with_greater precision, effectively dealing more_damage."); this->m_Buttons[13] = new Button(); this->m_Buttons[13]->Init(FLOAT2(-0.85f, -0.7f),FLOAT2(0.079166667f,0.140740741f),m_skillHolder.getSkill(Skill::LIFE_REGEN),"",0,0,1,12,100,0,INT2(422,80), false, Skill::LIFE_REGEN,"menu_textures\\Skill_29.png"); this->m_Label[5]->setText("Holy aura____Life regen"); if (m_Combat == 1) { this->m_Label[3]->setText("Range combat_"); this->m_Label[7]->setText("With ranged combat, you can rain damage_on your enemies from afar, but with distance_comes less accuracy and damage."); } } break; case Hero::THE_MENTALIST: this->m_mentalistPortrait->setPosition(pos); this->m_mentalistPortrait->setVisible(true); if(changeText == true) { this->m_Label[2]->setText("Mentalist"); this->m_Label[0]->setText("1__1__4__5__2"); this->m_Label[1]->setText("The Mentalist is an enigmatic, charming character with the stunning ability to know_more about you than you do yourself. Some say he is a charlatan, other think it is_real magic. Whichever is true,it is clear that The Mentalist can do incredible things_to your mind, often without you even noticing.Be glad he is on your side."); this->m_Buttons[6]->setTexture("menu_textures\\M0.png"); this->m_Buttons[7]->setTexture("menu_textures\\M1.png"); delete this->m_Buttons[12]; delete this->m_Buttons[13]; this->m_Buttons[12] = new Button(); this->m_Buttons[12]->Init(FLOAT2(-0.85f, -0.5f),FLOAT2(0.079166667f,0.140740741f),m_skillHolder.getSkill(Skill::HYPNOTIC_STARE),"",0,0,1,12,100,0,INT2(422,80), false, Skill::HYPNOTIC_STARE,"menu_textures\\Skill_21.png"); this->m_Label[7]->setText("In melee, you need to get close to your enemy,_but are guaranteed to land every strike with_greater precision, effectively dealing more_damage."); this->m_Buttons[13] = new Button(); this->m_Buttons[13]->Init(FLOAT2(-0.85f, -0.7f),FLOAT2(0.079166667f,0.140740741f),m_skillHolder.getSkill(Skill::ENIGMATIC_PRESENCE),"",0,0,1,12,100,0,INT2(422,80), false, Skill::ENIGMATIC_PRESENCE,"menu_textures\\Skill_22.png"); this->m_Label[5]->setText("Hypnotic stare____Enigmatic presence"); if (m_Combat == 1) { this->m_Label[3]->setText("Range combat_"); this->m_Label[7]->setText("With ranged combat, you can rain damage_on your enemies from afar, but with distance_comes less accuracy and damage."); } } break; } if(changeText) { m_mentalistPortrait2->setVisible(false); m_doctorPortrait2->setVisible(false); m_engineerPortrait2->setVisible(false); m_redKnightPortrait2->setVisible(false); m_officerPortrait2->setVisible(false); switch(_type) { case Hero::OFFICER: this->m_officerPortrait2->setVisible(true); break; case Hero::RED_KNIGHT: this->m_redKnightPortrait2->setVisible(true); break; case Hero::ENGINEER: this->m_engineerPortrait2->setVisible(true); break; case Hero::DOCTOR: this->m_doctorPortrait2->setVisible(true); break; case Hero::THE_MENTALIST: this->m_mentalistPortrait2->setVisible(true); break; } } m_currentSelections[_playerIndex] = _type; }
//============================================================================= void InitGame() { RefTable.Init(); srand((uint)time(NULL)); // map for(int i=0; i<MAP_W*MAP_H; ++i) { int c = rand()%8; Tile& tile = mapa[i]; tile.unit = NULL; tile.building = NULL; if(c == 0) tile.type = 1; else if(c == 1 || c == 2) tile.type = 2; else tile.type = 0; } // player player = new Player; player->pos = INT2(0,0); units.push_back(player); mapa[0].type = 0; mapa[0].unit = player->_ref; // enemies struct SpawnGroup { int line, enemy[3], drop; }; const SpawnGroup groups[] = { 11, 2, 0, 0, 2, 15, 3, 0, 0, 2, 19, 0, 1, 0, 0, 25, 2, 1, 0, 2, 29, 0, 2, 0, 1, 35, 1, 2, 0, 2, 39, 2, 2, 0, 2, 45, 0, 3, 0, 1, 50, 0, 0, 1, 0, 55, 0, 2, 1, 1, 60, 0, 0, 2, 0 }; const int count = countof(groups); for(int i=0; i<11; ++i) { const SpawnGroup& group = groups[i]; for(int j=0; j<3; ++j) { int enemy_count = group.enemy[j]; while(enemy_count) { INT2 pt(rand()%MAP_W, group.line); if(group.drop) pt.y += random(-group.drop, group.drop); Tile& tile = mapa[pt.x+pt.y*MAP_W]; if(tile.type != 1 && !tile.unit) { --enemy_count; Unit* enemy = new Unit(&base_units[j+1]); enemy->pos = pt; units.push_back(enemy); tile.unit = enemy->_ref; } } } } // inn #define M(x,y) mapa[(x)+(y)*MAP_W] Building* b = new Building; b->base = &base_buildings[0]; M(5,1).PutBuilding(b, BT_WALL); M(6,1).PutBuilding(b, BT_SIGN); M(7,1).PutBuilding(b, BT_WALL); M(5,2).PutBuilding(b, BT_WALL); M(6,2).PutBuilding(b, BT_DOOR); M(7,2).PutBuilding(b, BT_WALL); M(6,3).type = 0; inn = b; // text width text[0].w = 300; text[1].w = 300; text[2].w = 600; text[3].w = 600; }
enum DIR { DIR_S, DIR_SW, DIR_W, DIR_NW, DIR_N, DIR_NE, DIR_E, DIR_SE, DIR_INVALID }; INT2 dir_change[] = { INT2(0,1), INT2(-1,1), INT2(-1,0), INT2(-1,-1), INT2(0,-1), INT2(1,-1), INT2(1,0), INT2(1,1), INT2(0,0) }; SDL_Window* window; SDL_Renderer* renderer; inline int Distance(const INT2& a, const INT2& b) {
void levels(int kpds6, int kpds7, int center) { int o11, o12; /* octets 11 and 12 */ o11 = kpds7 / 256; o12 = kpds7 % 256; switch (kpds6) { case 1: printf("sfc"); break; case 2: printf("cld base"); break; case 3: printf("cld top"); break; case 4: printf("0C isotherm"); break; case 5: printf("cond lev"); break; case 6: printf("max wind lev"); break; case 7: printf("tropopause"); break; case 8: printf("nom. top"); break; case 9: printf("sea bottom"); break; case 200: case 10: printf("atmos col"); break; case 12: case 212: printf("low cld bot"); break; case 13: case 213: printf("low cld top"); break; case 14: case 214: printf("low cld lay"); break; case 22: case 222: printf("mid cld bot"); break; case 23: case 223: printf("mid cld top"); break; case 24: case 224: printf("mid cld lay"); break; case 32: case 232: printf("high cld bot"); break; case 33: case 233: printf("high cld top"); break; case 34: case 234: printf("high cld lay"); break; case 201: printf("ocean column"); break; case 204: printf("high trop freezing lvl"); break; case 206: printf("grid-scale cld bot"); break; case 207: printf("grid-scale cld top"); break; case 209: printf("bndary-layer cld bot"); break; case 210: printf("bndary-layer cld top"); break; case 211: printf("bndary-layer cld layer"); break; case 242: printf("convect-cld bot"); break; case 243: printf("convect-cld top"); break; case 244: printf("convect-cld layer"); break; case 246: printf("max e-pot-temp lvl"); break; case 247: printf("equilibrium lvl"); break; case 248: printf("shallow convect-cld bot"); break; case 249: printf("shallow convect-cld top"); break; case 251: printf("deep convect-cld bot"); break; case 252: printf("deep convect-cld top"); break; case 100: printf("%d mb",kpds7); break; case 101: printf("%d-%d mb",o11*10,o12*10); break; case 102: printf("MSL"); break; case 103: printf("%d m above MSL",kpds7); break; case 104: printf("%d-%d m above msl",o11*100,o12*100); break; case 105: printf("%d m above gnd",kpds7); break; case 106: printf("%d-%d m above gnd",o11*100,o12*100); break; case 107: printf("sigma=%.4f",kpds7/10000.0); break; case 108: printf("sigma %.2f-%.2f",o11/100.0,o12/100.0); break; case 109: printf("hybrid lev %d",kpds7); break; case 110: printf("hybrid %d-%d",o11,o12); break; case 111: printf("%d cm down",kpds7); break; case 112: printf("%d-%d cm down",o11,o12); break; case 113: printf("%dK",kpds7); break; case 114: printf("%d-%dK",475-o11,475-o12); break; case 115: printf("%d mb above gnd",kpds7); break; case 116: printf("%d-%d mb above gnd",o11,o12); break; case 117: printf("%d pv units",INT2(o11,o12)); /* units are suspect */ break; case 119: printf("%.5f (ETA level)",kpds7/10000.0); break; case 120: printf("%.2f-%.2f (ETA levels)",o11/100.0,o12/100.0); break; case 121: printf("%d-%d mb",1100-o11,1100-o12); break; case 125: printf("%d cm above gnd",kpds7); break; case 126: if (center == NMC) printf("%.2f mb",kpds7*0.01); break; case 128: printf("%.3f-%.3f (sigma)",1.1-o11/1000.0, 1.1-o12/1000.0); break; case 141: printf("%d-%d mb",o11*10,1100-o12); break; case 160: printf("%d m below sea level",kpds7); break; default: break; } }
/** Called when we started to render the world */ XRESULT D3D11GraphicsEngineTest::OnStartWorldRendering() { if(Engine::GAPI->GetRendererState()->RendererSettings.DisableRendering) return XR_SUCCESS; SetDefaultStates(); Engine::GAPI->SetFarPlane(80000.0f); Clear(float4(Engine::GAPI->GetRendererState()->GraphicsState.FF_FogColor, 0.0f)); ID3D11RenderTargetView* rtvs[] = {GBuffer0_Diffuse->GetRenderTargetView(), GBuffer1_Normals_SpecIntens_SpecPower->GetRenderTargetView()}; Context->OMSetRenderTargets(2, rtvs, DepthStencilBuffer->GetDepthStencilView()); if(Engine::GAPI->GetRendererState()->RendererSettings.DrawWorldMesh) DrawWorldMeshTest(); if(Engine::GAPI->GetRendererState()->RendererSettings.DrawVOBs) DrawSceneLightPrePass(); SetDefaultStates(); PfxRenderer->CopyTextureToRTV(GBuffer0_Diffuse->GetShaderResView(), HDRBackBuffer->GetRenderTargetView()); PfxRenderer->CopyTextureToRTV(GBuffer1_Normals_SpecIntens_SpecPower->GetShaderResView(), HDRBackBuffer->GetRenderTargetView(), INT2(256,256)); // Set viewport for gothics rendering D3D11_VIEWPORT vp; vp.TopLeftX = 0.0f; vp.TopLeftY = 0.0f; vp.MinDepth = 0.0f; vp.MaxDepth = 0.0f; vp.Width = (float)GetBackbufferResolution().x; vp.Height = (float)GetBackbufferResolution().y; Context->RSSetViewports(1, &vp); PS_LPP = ShaderManager->GetPShader("PS_LPPNormalmappedAlphaTest"); return XR_SUCCESS; }