- #include "main.h"
- #include "cMouseMenu.h"
- //----------------------------------------------------
- //class cButton---------------------------------------
- //----------------------------------------------------
- cButton::cButton()
- {
- int x = 0;
- int y = 0;
- int w = 0;
- int h = 0;
- char *caption = "";
- int red = 0;
- int green = 0;
- int blue = 0;
- int alpha = 255;
- vgui::HFont hFont = g_pMatSystemSurface->CreateFont();
- g_pMatSystemSurface->SetFontGlyphSet(hFont, "Arial", 15, 400, 0, 0, 0);
- };
- bool cButton::bClicked()
- {
- if(GetAsyncKeyState(0x01))
- {
- LPPOINT lpPos;
- GetCursorPos(lpPos);
- if((lpPos->x > this->x) && (lpPos->x < this->x+w)
- &&(lpPos->y > this->y) && (lpPos->y < this->y+h))
- return true;
- }
- return false;
- }
- void cButton::Draw(bool clicked)
- {
- if(!clicked)
- {
- g_pMatSystemSurface->DrawSetColor(this->red, this->green, this->blue, this->alpha);
- g_pMatSystemSurface->DrawFilledRect(x, y, x+w, y+h);
- g_pMatSystemSurface->DrawColoredText(this->hFont, x+2, y+2, 0, 0, 0, 255, (char *)&this->caption);
- return;
- }
- if(clicked)
- {
- g_pMatSystemSurface->DrawSetColor(this->red-10, this->green-10, this->blue-10, this->alpha-10);
- g_pMatSystemSurface->DrawFilledRect(x, y, x+w, y+h);
- g_pMatSystemSurface->DrawColoredText(this->hFont, x+2, y+2, 0, 0, 0, 255, (char *)&this->caption);
- return;
- }
- return;
- }
- void cButton::Init(int x, int y, int w, int h, char *caption, int r, int g, int b, int alpha)
- {
- this->x = x;
- this->y = y;
- this->w = w;
- this->h = h;
- this->caption = (char *)&caption;
- this->red = r;
- this->green = g;
- this->blue = b;
- this->alpha = alpha;
- return;
- }
- //----------------------------------------------------
- //class cCheckobx-------------------------------------
- //----------------------------------------------------
- cCheckbox::cCheckbox()
- {
- this->x = 0;
- this->y = 0;
- this->caption = "";
- this->checked = false;
- vgui::HFont hFont = g_pMatSystemSurface->CreateFont();
- g_pMatSystemSurface->SetFontGlyphSet(hFont, "Arial", 15, 400, 0, 0, 0);
- }
- void cCheckbox::Init(int x, int y, char *caption, bool checked)
- {
- this->x = x;
- this->y = y;
- this->caption = (char *)&caption;
- this->checked = checked;
- return;
- }
- void cCheckbox::Draw()
- {
- g_pMatSystemSurface->DrawSetColor(0, 0, 0, 255);
- g_pMatSystemSurface->DrawOutlinedRect(x-1, y-1, x+11, y+11);
- g_pMatSystemSurface->DrawSetColor(30, 30, 30, 255);
- g_pMatSystemSurface->DrawFilledRect(x, y, x+10, x+10);
- g_pMatSystemSurface->DrawColoredText(this->hFont, x+2, y+2, 0, 0, 0, 255, "%s", this->caption);
- if(this->checked)
- {
- g_pMatSystemSurface->DrawSetColor(0, 0, 0, 255);
- g_pMatSystemSurface->DrawFilledRect(x+2, y+2, x+8, y+8);
- }
- return;
- }
- bool cCheckbox::bClicked()
- {
- if(GetAsyncKeyState(0x01))
- {
- LPPOINT lpPos;
- GetCursorPos(lpPos);
- if((lpPos->x >= this->x) && (lpPos->x <= this->x+10)
- &&(lpPos->y >= this->y) && (lpPos->y <= this->y+10))
- {
- if(this->checked)
- { this->checked = false; return false;}
- else if(!this->checked)
- { this->checked = true; return true;}
- }
- }
- return false;
- }
- //----------------------------------------------------
- //class cLabel----------------------------------------
- //----------------------------------------------------
- cLabel::cLabel()
- {
- this->x = 0;
- this->y = 0;
- this->caption = "";
- vgui::HFont hFont = g_pMatSystemSurface->CreateFont();
- g_pMatSystemSurface->SetFontGlyphSet(hFont, "Arial", 15, 400, 0, 0, 0);
- }
- void cLabel::Init(int x, int y, char *caption)
- {
- this->x = x;
- this->x = y;
- this->caption = (char *)&caption;
- }
- void cLabel::Draw()
- {
- g_pMatSystemSurface->DrawColoredText(this->hFont, x, y, 0, 0, 0, 255, "%s", this->caption);
- }
- //----------------------------------------------------
- //class cMenu-----------------------------------------
- //----------------------------------------------------
- cMenu::cMenu()
- {
- this->x = 0;
- this->y = 0;
- this->w = 0;
- this->h = 0;
- this->a = 0;
- this->r = 0;
- this->g = 0;
- this->b = 0;
- this->hFont = g_pMatSystemSurface->CreateFont();
- }
- void cMenu::Init(int x, int y, int w, int h, int r, int g, int b, int a, char *caption, char *fontname)
- {
- this->x = x;
- this->y = y;
- this->w = w;
- this->h = h;
- this->r = r;
- this->g = g;
- this->b = b;
- this->a = a;
- this->caption = (char *)&caption;
- g_pMatSystemSurface->SetFontGlyphSet(this->hFont, (char *) &fontname, 20, 400, 0, 0, 0);
- }
- void cMenu::Draw()
- {
- g_pMatSystemSurface->DrawSetColor(0, 0, 0, 255);
- g_pMatSystemSurface->DrawOutlinedRect(this->x-1, this->y-1, this->x+this->w+1, this->y+this->h+1); //Draw black Border of the Main Menu
- g_pMatSystemSurface->DrawOutlinedRect(this->x-1, this->y-31, this->x+this->w+1, this->y-6); //Draw black Border of the Captionline
- g_pMatSystemSurface->DrawSetColor(this->r, this->g, this->b, this->a);
- g_pMatSystemSurface->DrawFilledRect(this->x, this->y, this->x+this->w, this->y+this->h); //Draw Main Menu Window
- g_pMatSystemSurface->DrawFilledRect(this->x, this->y-30, this->x+this->w, this->y-5); //Draw Captionline
- g_pMatSystemSurface->DrawColoredText(this->hFont, this->x+3, this->y-27, 0, 0, 0, 255, "%s", this->caption);
- };
- void cMenu::SetAlpha(int a)
- {
- this->a = a;
- }
- void cMenu::SetColor(int r, int g, int b, int a)
- {
- this->r = r;
- this->g = g;
- this->b = b;
- this->a = a;
- }
lalala
By: cMouseMenu.cpp | Date: Oct 25 2009 12:45 | Format: None | Expires: never | Size: 5.32 KB | Hits: 1218
Latest pastes
1 hours ago
11 hours ago
1 days ago
2 days ago
2 days ago