// <cgame> -*- C++ -*-
//No Copyright.
// This is a C++ Library header.
#ifndef game6
#define game6
#include<windows.h>
#include<iostream>
#include<fstream>
namespace game6
{
/* DO NOT EDIT ! */
#define gFILE_VERSION "1.0.1.0"
#define gFILE_DESCRIPTION "Developed using the Dev-C++ IDE"
#define gLEGAL_COPYRIGHT "None"
#define gORIGINAL_FILENAME "cgame"
#define gPRODUCT_VERSION "1.0.1.0"
long long time(){return ::GetTickCount();}//毫秒级
long long time(long long init){return ::GetTickCount()-init;}//毫秒级
void hidew(){ShowWindow(GetConsoleWindow(),SW_HIDE);}
void seenw(){ShowWindow(GetConsoleWindow(),SW_SHOW);}
void goxy(int x, int y){SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE),{x,y});}
void hidecur(){
CONSOLE_CURSOR_INFO cursor_info={1,0};
SetConsoleCursorInfo(GetStdHandle(STD_OUTPUT_HANDLE),&cursor_info);
}
void movewin(){
RECT rect;
HWND hwnd = GetForegroundWindow();
GetWindowRect(hwnd, &rect);
MoveWindow(GetForegroundWindow(),0,0,0,0,1);
}
void wintop(std::string n)//标题
{
std::string t = "title ";
t += n;
system(&t[0]);
}
//wincon
#define FOREGROUND_BLUE 0x1
#define FOREGROUND_GREEN 0x2
#define FOREGROUND_RED 0x4
#define FOREGROUND_INTENSITY 0x8
#define BACKGROUND_BLUE 0x10
#define BACKGROUND_GREEN 0x20
#define BACKGROUND_RED 0x40
#define BACKGROUND_INTENSITY 0x80
//wincon
void color(int a,int b){SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),a+b*0x10);}
void color(int x){SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),x);}
void top()//将置顶与不置顶来回更换
{
HWND hWnd = ::GetForegroundWindow();
if (::GetWindowLong(hWnd, GWL_EXSTYLE) & WS_EX_TOPMOST)::SetWindowPos(hWnd, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
else::SetWindowPos(hWnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
}
void wsize(short h,short l)//windows size
{
std::string n="mode con cols=",t="";
while(l>0)
{
t+=char(l%10+'0');
l/=10;
}
for(int i=t.size()-1;i>=0;i--)n+=t[i];
n+=" lines=",t="";
while(h>0)
{
t=t+char(h%10+'0');
h/=10;
}
for(int i=t.size()-1;i>=0;i--)n+=t[i];
system(&n[0]);
return;
}
void nomode()//移除快速编辑模式
{
DWORD mode;
GetConsoleMode(GetStdHandle(STD_INPUT_HANDLE),&mode);
mode&=~ENABLE_QUICK_EDIT_MODE;
SetConsoleMode(GetStdHandle(STD_INPUT_HANDLE),mode);
return;
}
void hcur()//隐藏光标
{
CONSOLE_CURSOR_INFO cursor;
cursor.bVisible=FALSE;
cursor.dwSize=sizeof(cursor);
SetConsoleCursorInfo(GetStdHandle(STD_OUTPUT_HANDLE),&cursor);
}
void movecur(long long h, long long l){SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE),{l-1,h-1});}
void fout(int n, std::string name)//参考饼干369
{
std::ofstream cd(&name[0]);
cd << n;
cd.close();
return;
}
void fout(long long n, std::string name)
{
std::ofstream cd(&name[0]);
cd << n;
cd.close();
return;
}
void fout(bool n, std::string name)
{
std::ofstream cd(&name[0]);
cd << n;
cd.close();
return;
}
void fout(char n, std::string name)
{
std::ofstream cd(&name[0]);
cd << n;
cd.close();
return;
}
void fout(std::string n, std::string name)
{
std::ofstream cd(&name[0]);
cd << n;
cd.close();
return;
}
void fin(int& n, std::string name)
{
std::ifstream cd(&name[0]);
cd >> n;
cd.close();
return;
}
void fin(long long& n, std::string name)
{
std::ifstream cd(&name[0]);
cd >> n;
cd.close();
return;
}
void fin(bool& n, std::string name)
{
std::ifstream cd(&name[0]);
cd >> n;
cd.close();
return;
}
void fin(char& n, std::string name)
{
std::ifstream cd(&name[0]);
cd >> n;
cd.close();
return;
}
void fin(std::string& n, std::string name)//参考饼干369
{
std::ifstream cd(&name[0]);
cd >> n;
cd.close();
return;
}
struct hl//行列
{
long long h, l;
};
hl where(bool x = 1, bool n = 1)//鼠标位置
{
HANDLE hOutput = GetStdHandle(STD_OUTPUT_HANDLE);
HWND h = GetForegroundWindow();
CONSOLE_FONT_INFO consoleCurrentFont;
hl hl;
POINT p;
if (x)
{
GetCursorPos(&p);
ScreenToClient(h, &p);
}
else
{
GetCursorPos(&p);
}
if (n)
{
GetCurrentConsoleFont(hOutput, FALSE, &consoleCurrentFont);
p.x /= consoleCurrentFont.dwFontSize.X;
p.y /= consoleCurrentFont.dwFontSize.Y;
}
hl.h = p.y + 1;
hl.l = p.x + 1;
return hl;
}
}
#endif
game.h lv.2
最新推荐文章于 2024-11-09 13:08:09 发布