Built-in minimize option

Post ideas and/or requests for future releases.
Post Reply
Dragon
Panzer n00b
Posts: 65
Joined: Sat Mar 26, 2011 6:44 pm
Contact:

Built-in minimize option

Post by Dragon » Thu Apr 21, 2011 12:44 pm

Would be nice to see possibility to minimize the game without any external programs. There is one mod which has this feature already, but it isn't so good there cause resolution from the game isn't changed with the minimize (eg. if game res is 1024x768 and Windows one is 1920x1080 you will see your desktop in 1024x768). Would be great if such "script" would detect your desktop resolution.

I hope you understand me, it's hard to explain this thing in English for me :)

User avatar
stealth
Rambo Medic
Posts: 375
Joined: Sun Jun 11, 2006 1:17 pm
Location: Chair

Re: Built-in minimize option

Post by stealth » Thu Apr 21, 2011 6:10 pm

This was posted on SD a few days ago:
http://www.splashdamage.com/forums/show ... hp?t=24040
:D

Genert
Server n00b
Posts: 12
Joined: Thu Mar 24, 2011 9:10 am

Re: Built-in minimize option

Post by Genert » Tue Apr 26, 2011 3:35 am

Scenna code works,but where is LINUX???
It can be done in better way,adding cg_minimizer code and coding it into cg_concolecmds.c,cg_main.c ...
My old minimizer code,it was actually program,never builded it into ET-SDK soucre.

Code: Select all

#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <shellapi.h>
#include <stdio.h>
#define HOTKEY_ID 40022
#define SHELL_ICON_ID 402442
#define SHELL_CALLBACK WM_USER+14

#include "resource.h"

using namespace std;

LRESULT CALLBACK winProc(HWND hwnd, UINT msg, WPARAM wp, LPARAM lp);
HMENU hmenu;
string check = "Enemy Territory";

int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrev, LPSTR lpCmdLine, int nCmdShow)
{
	HWND hwnd;
	WNDCLASSEX wc;

	wc.cbSize = sizeof(WNDCLASSEX);
	wc.cbClsExtra = 0;
	wc.cbWndExtra = 0;
	wc.hbrBackground = (HBRUSH)WHITE_BRUSH+1;
	wc.hCursor = NULL;
	wc.hIcon = NULL;
	wc.hIconSm = NULL;
	wc.hInstance = hInst;
	wc.lpfnWndProc = winProc;
	wc.lpszClassName = "gminimizer";
	wc.style = CS_DBLCLKS;
	wc.lpszMenuName = NULL;

	if (!RegisterClassEx(&wc)) { return -1; }

	hwnd = CreateWindow("gminimizer", "gminimizer", NULL, 0, 0, 50, 50, NULL, NULL, hInst, NULL);

	if (!hwnd)
	{
		MessageBox(0, "crap", NULL, NULL);
		return -1;
	}

	if (!RegisterHotKey(NULL, HOTKEY_ID, MOD_ALT, 'Z'))
	{
		MessageBox(0, "crapolio", NULL, NULL);
		return -1;
	}

//	ShowWindow(hwnd, SW_SHOW);

	//create tray icon
	NOTIFYICONDATA nid;
	ZeroMemory(&nid, sizeof(NOTIFYICONDATA));

	nid.cbSize = sizeof(NOTIFYICONDATA);
	nid.hWnd = hwnd;
	nid.uID = SHELL_ICON_ID;
	nid.uFlags = NIF_ICON | NIF_TIP | NIF_MESSAGE;
	nid.uCallbackMessage = SHELL_CALLBACK;
	nid.hIcon = LoadIcon(hInst, MAKEINTRESOURCE(IDI_ICON));
	strcpy(nid.szTip, "Enemy Territory Minimizer");
		
	Shell_NotifyIcon(NIM_ADD, &nid);

	//Genert - Funktsioon,mis laeb menu üles
	hmenu = GetSubMenu(LoadMenu(hInst, MAKEINTRESOURCE(IDR_MENU1)), 0);


	FILE *fp = fopen("README.txt", "r");
	if (fp)
	{
		check = "";
		while (!feof(fp))
		{
			char buf[1024*32];
			fread(buf, 1, 1024*32-1, fp);
			buf[1024*32-1] = 0;
			check += buf;
		}
		fclose(fp);
	}


	//Genert - Siin lööb pildi ette
	MSG msg;
	while (GetMessage(&msg, NULL, NULL, NULL) != 0)
	{
		if (msg.message == WM_HOTKEY)
			msg.hwnd = hwnd;

		TranslateMessage(&msg);
		DispatchMessage(&msg);
	}

	Shell_NotifyIcon(NIM_DELETE, &nid);

	UnregisterHotKey(NULL, HOTKEY_ID);

	return 0;
}

void tryMin()
{
	string::size_type f = 0;
	string::size_type r = 0;
	string curWin;
	HWND hwet;

	while (f != string::npos)
	{
		r = check.find('\t', r+1);
		if (r == string::npos)
		{
			curWin = check.substr(f);
			f = r;
		}
		else
		{
			curWin = check.substr(f,r);
			f=r+1;
		}

		
		hwet = FindWindow(curWin.c_str(), NULL);
		
		if (hwet)
		{
			WINDOWPLACEMENT wp;
			GetWindowPlacement(hwet, &wp);
			if (wp.showCmd == SW_SHOWMINIMIZED)
				ShowWindow(hwet, SW_RESTORE);
			else
				ShowWindow(hwet, SW_MINIMIZE);
		}
	}
}

LRESULT CALLBACK winProc(HWND hwnd, UINT msg, WPARAM wp, LPARAM lp)
{
	switch(msg)
	{
	case WM_CREATE:
		break;

	case WM_HOTKEY:
		if (wp == HOTKEY_ID)
			tryMin();
		break;

	case SHELL_CALLBACK:
		switch(lp)
		{
		case WM_RBUTTONDOWN:
			{
				if (hmenu != 0)
				{
					SetForegroundWindow(hwnd);
					POINT p;
					GetCursorPos(&p);
					TrackPopupMenu(hmenu, 0, p.x, p.y, 0, hwnd, 0);
					PostMessage(hwnd, WM_NULL, 0,0);
				}
			}
			break;
		case WM_LBUTTONDBLCLK:
			tryMin();
			break;
		}
		return TRUE;
		break;
	case WM_COMMAND:
		switch(LOWORD(wp))
		{
			case ID_SHELL_TOGGLESTATE:
				tryMin();
				break;

			case ID_SHELL_EXIT:
				DestroyWindow(hwnd);
				break;
			case ID_SHELL_MADEBYGON:
				MessageBox(0, "See programm lubab Wolfenstein Enemy Territoryit minimize-da.\n Programm on tehtud Genert-i poolt..", "helP", MB_OK);
				break;

		}
		break;

	case WM_DESTROY:
		PostQuitMessage(0);
		break;
	default:
		return DefWindowProc(hwnd, msg, wp, lp);
	}

	return TRUE;
}

scenna
Server n00b
Posts: 1
Joined: Sat Aug 27, 2011 11:10 am

Re: Built-in minimize option

Post by scenna » Sat Aug 27, 2011 11:13 am

lolz, why addings so many useless shit?

is my minimizer not simple and effective?

grmpfl....

And where is the code for linux?

oh sorry, when i havent codet it...

Ligustah
Panzer n00b
Posts: 66
Joined: Wed Apr 13, 2011 9:03 am

Re: Built-in minimize option

Post by Ligustah » Sat Aug 27, 2011 2:12 pm

The minimizing has been explicitly disabled in the source code of the game client. It cannot be easily controlled by the mod. If you want to get your game to easily minimize, you will either have to use an external minimizer or grab the source, comment out some lines and recompile. The latter is actually fairly easy.

Post Reply