blob_id
stringlengths 40
40
| directory_id
stringlengths 40
40
| path
stringlengths 5
146
| content_id
stringlengths 40
40
| detected_licenses
listlengths 0
7
| license_type
stringclasses 2
values | repo_name
stringlengths 6
79
| snapshot_id
stringlengths 40
40
| revision_id
stringlengths 40
40
| branch_name
stringclasses 4
values | visit_date
timestamp[us] | revision_date
timestamp[us] | committer_date
timestamp[us] | github_id
int64 5.07k
426M
⌀ | star_events_count
int64 0
27
| fork_events_count
int64 0
12
| gha_license_id
stringclasses 3
values | gha_event_created_at
timestamp[us] | gha_created_at
timestamp[us] | gha_language
stringclasses 6
values | src_encoding
stringclasses 26
values | language
stringclasses 1
value | is_vendor
bool 1
class | is_generated
bool 1
class | length_bytes
int64 20
6.28M
| extension
stringclasses 20
values | content
stringlengths 20
6.28M
| authors
listlengths 1
16
| author_lines
listlengths 1
16
|
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
768bb4ed4c5c6740e0f9b91558eaab759bc3c42f
|
8aaa5982660c1be96b443f0c5e75a3aecdefa556
|
/dEdge.cpp
|
1071dd310212629c44416ea4d2d42342003836ce
|
[] |
no_license
|
mweiguo/libgeoalgorithm
|
af24c87f27e2ce2db504d99211da717859776ca3
|
ee91178c022df900f16037ba7dae4361e8b76fac
|
refs/heads/master
| 2016-09-06T17:45:02.294222 | 2010-06-26T05:35:32 | 2010-06-26T05:35:32 | null | 0 | 0 | null | null | null | null |
UTF-8
|
C++
| false | false | 526 |
cpp
|
#include "Delaunay.h"
#include <tinylog.h>
bool dEdge::add_owner( int id )
{
if ( mTris[0] && mTris[1] )
return false;
if ( mTris[0]==0 )
mTris[0] = id;
else
mTris[1] = id;
return true;
}
bool dEdge::remove_owner( int tri )
{
if ( mTris[0]==tri )
mTris[0]=0;
else if ( mTris[1]==tri )
mTris[1]=0;
else
return false;
return true;
}
dEdge::dEdge( int id1, int id2, int id ) : mID (id)
{
mPnts[0] = id1;
mPnts[1] = id2;
mTris[0] = mTris[1] = 0;
}
|
[
"[email protected]"
] |
[
[
[
1,
32
]
]
] |
ff7541b22235e313020d3f2c5d85f65293a0636d
|
f695ff54770f828d18e0013d12d9d760ec6363a3
|
/datastructures/Deque.h
|
6620ce47d2be94400ef1949275fb6237d36386bf
|
[] |
no_license
|
dbremner/airhan
|
377e1b1f446a44170f745d3a3a47e0a30bc917e1
|
a436fda7799c1032d060c30355c309ec1589e058
|
refs/heads/master
| 2021-01-10T19:42:16.321886 | 2010-05-29T02:16:25 | 2010-05-29T02:16:25 | 34,024,271 | 0 | 0 | null | null | null | null |
UTF-8
|
C++
| false | false | 3,570 |
h
|
/***************************************************************
Copyright (c) 2008 Michael Liang Han
Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation
files (the "Software"), to deal in the Software without
restriction, including without limitation the rights to use,
copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following
conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
****************************************************************/
#ifndef AIRHAN_DATASTRUCTURE_DEQUE_H_
#define AIRHAN_DATASTRUCTURE_DEQUE_H_
namespace lianghancn
{
namespace air
{
namespace datastructures
{
template<class T> class Deque
{
public:
virtual ~Deque()
{
while (! Empty())
{
DequeHead();
}
};
private:
template<class T> struct Entry
{
T payload;
Entry* previous;
Entry* next;
Entry(T item)
: previous(NULL)
, next(NULL)
, payload(item)
{
}
};
public:
Deque()
: _head(NULL)
, _tail(NULL)
{
}
void EnqueHead(T item)
{
Entry<T>* entry = new Entry<T>(item);
entry->next = _head;
entry->previous = NULL;
if (_head == NULL)
{
_tail = entry;
}
else
{
_head->previous = entry;
}
_head = entry;
}
void EnqueTail(T item)
{
Entry<T>* entry = new Entry<T>(item);
entry->previous = _tail;
_tail = entry;
if (entry->previous == NULL)
{
_head = _tail;
}
}
T DequeHead()
{
if (_head == NULL)
{
return 0;
}
T payload = _head->payload;
Entry<T>* entry = _head;
_head = _head->next;
if (_head == NULL)
{
_tail = NULL;
}
else
{
_head->previous = NULL;
}
delete entry;
return payload;
}
T DequeTail()
{
if (_tail == NULL)
{
return 0;
}
T payload = _tail->payload;
Entry<T>* entry = _tail;
_tail = _tail->previous;
if (_tail == NULL)
{
_head = NULL;
}
else
{
_tail->next = NULL;
}
delete entry;
return payload;
}
T PeekHead()
{
if (_head == NULL)
{
return 0; // TODO?
}
return _head->payload;
}
T PeekTail()
{
if (_tail == NULL)
{
return 0;
}
return _tail->payload;
}
bool Empty()
{
return _head == NULL ? true : false;
}
private:
Entry<T>* _head;
Entry<T>* _tail;
private:
Deque(const Deque&);
Deque& operator=(const Deque&);
};
};
};
};
#endif
|
[
"lianghancn@29280b2a-3d39-11de-8f11-b9fadefa0f10"
] |
[
[
[
1,
189
]
]
] |
5c105b8962f52d1e24e71b301ce0c204d6eca976
|
1741474383f0b3bc3518d7935a904f7903f40506
|
/A6/Ident.h
|
0a7e12415bb9e9a63ee7d6bae62a603f08221226
|
[] |
no_license
|
osecki/drexelgroupwork
|
739df86f361e00528a6b03032985288d64b464aa
|
7c3bde253a50cab42c22d286c80cad72348b4fcf
|
refs/heads/master
| 2020-05-31T02:25:57.734312 | 2009-06-03T18:34:59 | 2009-06-03T18:34:59 | 32,121,248 | 0 | 0 | null | null | null | null |
UTF-8
|
C++
| false | false | 385 |
h
|
#ifndef IDENT_H
#define IDENT_H
#include <map>
#include <vector>
#include <string>
#include "Expr.h"
using namespace std;
class Ident : public Expr
{
public:
Ident(string name = "");
virtual string translate(map<int, string> &constantValues, map<string, SymbolDetails> &symbolTable, vector<string> &ralProgram) const;
private:
string name_;
};
#endif
|
[
"jordan.osecki@c6e0ff0a-2120-11de-a108-cd2f117ce590"
] |
[
[
[
1,
19
]
]
] |
2beeebea58d349cb7cb34a881e06762ca7922554
|
6dac9369d44799e368d866638433fbd17873dcf7
|
/src/branches/01032005/graphics/gui/Window.cpp
|
edd55255279c65c73625e52657db38b2b2b886b4
|
[] |
no_license
|
christhomas/fusionengine
|
286b33f2c6a7df785398ffbe7eea1c367e512b8d
|
95422685027bb19986ba64c612049faa5899690e
|
refs/heads/master
| 2020-04-05T22:52:07.491706 | 2006-10-24T11:21:28 | 2006-10-24T11:21:28 | null | 0 | 0 | null | null | null | null |
UTF-8
|
C++
| false | false | 3,338 |
cpp
|
// Window.cpp: implementation of the Window class.
//
//////////////////////////////////////////////////////////////////////
#include <gui/gui.h>
Window::Window(InputDeviceDB *inputdevicedb, SceneGraph *scenegraph)
{
m_active = true;
m_comp_id = 0;
m_highlighted_component = NULL;
m_inputdevicedb = inputdevicedb;
m_cache_wc = NULL;
m_scenegraph = scenegraph;
m_event = NULL;
SetTitle("DefaultWindow");
}
Window::~Window()
{
for(unsigned int a=0;a<m_components.size();a++) UserInterfaceDB::m_library.DestroyComponent(m_components[a]);
m_components.clear();
m_event = NULL;
}
void Window::SetActive(bool Active)
{
m_active = Active;
// Clear the event queue, you didnt want those other events anyway :)
if(m_active == true) m_event = NULL;
}
bool Window::Initialise(void)
{
if(m_inputdevicedb!=NULL){
IInputDevice *input = m_inputdevicedb->GetDevicePtr(IInputDevice::MOUSE);
if(input != NULL) input->AddListener(&m_event);
return true;
}
return false;
}
void Window::SetTitle(std::string title)
{
if(title.empty() == false){
m_title = title;
}
}
std::string Window::GetTitle(void)
{
return m_title;
}
IWindowComponent * Window::AddComponent(WndComponentSetup *wcs)
{
// Find the component creation function
// Create the function, test the object created ok
if(wcs->m_componentid < UserInterfaceDB::m_library.NumberRegisteredComponents()){
m_cache_wc = UserInterfaceDB::m_library.CreateComponent(wcs->m_componentid);
if(m_cache_wc!=NULL){
// Initialise the component
// Store the component
m_cache_wc->Initialise(wcs, m_scenegraph);
m_components.push_back(m_cache_wc);
// Set the components initial state to active
// Delete the setup object
// Return a ptr to the created object
m_cache_wc->SetActive(true);
delete wcs;
return m_cache_wc;
}
}
return NULL;
}
void Window::SetCaps(int caps, union CapabilityData *cd)
{
if(m_cache_wc != NULL) m_cache_wc->SetCaps(caps,cd);
}
IWindowComponent * Window::GetComponentPtr(int type,int value)
{
// TODO: complete this function (rewrite if necessary)
return NULL;
}
void Window::ProcessEvents(void)
{
for(InputEvent *e=m_event;e!=NULL;e=e->prev)
{
switch(e->m_InputEvent)
{
case IInputDevice::EVENT_XY:
{
MouseXYEvent *xy = (MouseXYEvent *)e;
if(m_highlighted_component != NULL)
{
if(m_highlighted_component->Highlight(xy->m_x,xy->m_y) == false) m_highlighted_component = NULL;
}else{
for(wndcomp_t::iterator wc=m_components.begin();wc!=m_components.end();wc++){
if((*wc)->Highlight(xy->m_x,xy->m_y) == true)
{
m_highlighted_component = (*wc);
break;
}
}
}
}break;
case IInputDevice::EVENT_BUTTON:
{
InputButtonEvent *ib = (InputButtonEvent *)e;
if(ib->m_EventAction == IInputDevice::BUTTON_DOWN){
if(m_highlighted_component != NULL) m_highlighted_component->Click();
}
}break;
};
}
m_event = NULL;
}
bool Window::Update(void)
{
if(m_active==true)
{
ProcessEvents();
for(wndcomp_t::iterator wc=m_components.begin();wc!=m_components.end();wc++){
if((*wc)->Update() == false) return false;
}
}
return true;
}
|
[
"chris_a_thomas@1bf15c89-c11e-0410-aefd-b6ca7aeaabe7"
] |
[
[
[
1,
144
]
]
] |
5cb28138127346404a6a1f8176e5ff4b908a47a4
|
c5ecda551cefa7aaa54b787850b55a2d8fd12387
|
/src/UILayer/StatisticsInfo.h
|
64c9d868313ca2da55fd20a2e0734a5d13efb1e9
|
[] |
no_license
|
firespeed79/easymule
|
b2520bfc44977c4e0643064bbc7211c0ce30cf66
|
3f890fa7ed2526c782cfcfabb5aac08c1e70e033
|
refs/heads/master
| 2021-05-28T20:52:15.983758 | 2007-12-05T09:41:56 | 2007-12-05T09:41:56 | null | 0 | 0 | null | null | null | null |
GB18030
|
C++
| false | false | 1,152 |
h
|
#pragma once
#include "resource.h"
#include "afxcmn.h"
// CStatisticsInfo 对话框
#include "ProgressCtrlX.h"
#include "IconStatic.h"
#include "Localizee.h"
#include "ResizableLib\ResizableDialog.h"
class CStatisticsInfo : public CResizableDialog, public CLocalizee
{
DECLARE_DYNAMIC(CStatisticsInfo)
LOCALIZEE_WND_CANLOCALIZE();
public:
CStatisticsInfo(CWnd* pParent = NULL); // 标准构造函数
virtual ~CStatisticsInfo();
// 对话框数据
enum { IDD = IDD_DIALOG_STATISTICS };
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV 支持
virtual BOOL OnInitDialog();
DECLARE_MESSAGE_MAP()
public:
void SetRequest(int range, int pos);
void SetAcceptUpload(int range, int pos);
void SetTransfer(int range, uint64 pos);
void SetAll(int request, int accept, uint64 transfer);
void SetNoFile();
void SetStatisticsFrmText(CString str);
private:
CProgressCtrlX pop_bar;
CProgressCtrlX pop_baraccept;
CProgressCtrlX pop_bartrans;
CIconStatic m_ctrlStatisticsFrm;
public:
afx_msg void OnSize(UINT nType, int cx, int cy);
void Localize(void);
};
|
[
"LanceFong@4a627187-453b-0410-a94d-992500ef832d"
] |
[
[
[
1,
49
]
]
] |
df713fd747befe9e74c25a61c0df019f2e3c221d
|
84aacb0434740fdc06e947fb4525ffe725fa712c
|
/Framework/quicktool/src/actions.h
|
7c005bd5033e0bfbec6348b8d6695563fb7739e3
|
[] |
no_license
|
evanxg852000/yalamo-php
|
c5d702cb4367e7de34e8da2433b4fd6bb951df88
|
086034d8b68e1250d1c70ed2ebc3133a62379b63
|
refs/heads/master
| 2021-01-10T20:35:34.906963 | 2011-10-14T19:12:13 | 2011-10-14T19:12:13 | 34,729,399 | 0 | 0 | null | null | null | null |
UTF-8
|
C++
| false | false | 5,692 |
h
|
#ifndef ACTIONS_H
#define ACTIONS_H
#include <fstream>
#include <cctype>
#include <cstring>
#include <dirent.h>
namespace Actions {
using namespace std;
bool checkarglength(Array args,unsigned int n){
if(args.size()<n){
return false;
}
return true;
}
void paramerror(){
cout<<"Command expects more parameters! "<<endl;
}
bool createfile(string &fullpath,string const &content){
ofstream stream(fullpath.c_str());
if(stream){
stream<<content<<endl;
stream.close();
return true;
}
return false;
}
string capitalise(string text){
const char *car=text.c_str();
char cpy[strlen(car)];
cpy[0]=std::toupper(car[0]);
for(unsigned int i=1;i<strlen(car)-1;i++){
cpy[i]=car[i];
}
return (string) cpy ;
}
void Help(){
cout.fill(' ');
cout<<"---------- Yalamo Quick Help ----------"<<endl;
cout<<" exit: Exit yalQuick"<<endl;
cout<<" ?: Show help content"<<endl;
cout<<" cls: Clear the screen"<<endl;
cout<<" prompt: Set the command line prompt"<<endl;
cout<<" path: Set the working directory"<<endl;
cout<<" list: List the comtent of the curent directory "<<endl;
cout<<" project: Create yalamo project in the current directory "<<endl;
cout<<" module: Create module in the curent project"<<endl;
cout<<" extension: Create extension in the current project"<<endl;
cout<<" controller: Create controller in the current project"<<endl;
cout<<" model: Create model in the current project"<<endl;
cout<<" view: Create view in the current project"<<endl;
}
void ClearScreen(){
system("cls");
}
void SetPrompt(Application *app,Array &args){
if(checkarglength(args,1)){
string argval=args.getvalueof(0);
if(argval !=""){
app->SetPrompt(argval);
}
return ;
}
paramerror();
}
void SetPath(Application *app, Array &args){
if(checkarglength(args,1)){
string argval=args.getvalueof(0);
if(argval !=""){
app->SetPath(argval);
}
return ;
}
else{
cout<<app->GetPath()<<endl;
}
}
void ListDir (Application *app, Array &args){
DIR *pdir = NULL;
pdir = opendir (app->GetPath().c_str());
struct dirent *pent = NULL;
if (pdir == NULL){ return;}
while ((pent = readdir (pdir))){
if (pent == NULL){
return;
}
cout<<pent->d_name<<endl;
}
closedir (pdir);
}
void Project(Application *app, Array &args){
if(checkarglength(args,1)){
string projectname=args.getvalueof(0);
if(projectname !=""){
cout<<"No Supported yet"<<endl;
}
return ;
}
paramerror();
}
void Module (Application *app, Array &args){
if(checkarglength(args,1)){
string modulename=capitalise(args.getvalueof(0));
if(modulename !=""){
string path=app->GetPath()+Constants::dirmodule+modulename+".php";
string content="<?php\nclass "+modulename+" extends Object {\n\tpublic function __construct(){\n\n\t}\n}";
if(!createfile(path,content)){
cout<<"Not able to create the module !"<<endl;
}
}
return ;
}
paramerror();
}
void Extension (Application *app, Array &args){
if(checkarglength(args,1)){
string extname=capitalise(args.getvalueof(0));
if(extname !=""){
string path=app->GetPath()+Constants::dirextension+extname+".php";
string content="<?php\nclass "+extname+" extends Object {\n\tpublic function __construct(){\n\n\t}\n}";
if(!createfile(path,content)){
cout<<"Not able to create the extension !"<<endl;
}
}
return ;
}
paramerror();
}
void Controller(Application *app, Array &args){
if(checkarglength(args,1)){
string ctrlname=capitalise(args.getvalueof(0));
if(ctrlname !=""){
string path=app->GetPath()+Constants::dircontroller+ctrlname+".php";
string content="<?php\nclass "+ctrlname+" extends Controller {\n\tpublic function Index() {\n\t\t$this->Show('view');\n\t}\n}";
if(!createfile(path,content)){
cout<<"Not able to create the controller !"<<endl;
}
}
return ;
}
paramerror();
}
void Model (Application *app, Array &args){
if(checkarglength(args,1)){
string modelname=capitalise(args.getvalueof(0));
if(modelname !=""){
string path=app->GetPath()+Constants::dirmodel+modelname+".php";
string content="<?php\nclass "+modelname+" extends Model {\n\tpublic function __construct() {\n\t\tparent::__construct();\n\t}\n}";
if(!createfile(path,content)){
cout<<"Not able to create the model !"<<endl;
}
}
return ;
}
paramerror();
}
void View (Application *app, Array &args){
if(checkarglength(args,1)){
string viewname=capitalise(args.getvalueof(0));
if(viewname !=""){
string path=app->GetPath()+Constants::dirview+viewname+".php";
string content="<html>\n<head>\n\t<title>"+viewname+"</title>\n</head>\n<body>\n\n</body>\n</html>";
if(!createfile(path,content)){
cout<<"Not able to create the view !"<<endl;
}
}
return ;
}
paramerror();
}
}
#endif // ACTIONS_H
|
[
"evanxg852000@14598e67-aabe-1442-b7d5-ab22a4115611"
] |
[
[
[
1,
189
]
]
] |
7f1e7eb669dfa318343e3b7e147494e7add55e43
|
01fa6f43ad536f4c9656be0f2c7da69c6fc9dc1c
|
/garbage/wed2.cpp
|
e3658db7fc521ae4439ebc87d54678511046f42b
|
[] |
no_license
|
akavel/wed-editor
|
76a22b7ff1bb4b109cfe5f3cc630e18ebb91cd51
|
6a10c167e46bfcb65adb514a1278634dfcb384c1
|
refs/heads/master
| 2021-01-19T19:33:18.124144 | 2010-04-16T20:32:17 | 2010-04-16T20:32:17 | 10,511,499 | 1 | 0 | null | null | null | null |
UTF-8
|
C++
| false | false | 19,709 |
cpp
|
// wed.cpp : Main application file
//
#include "stdafx.h"
#include "io.h"
#include "wed.h"
#include "StrList.h"
#include "MainFrm.h"
#include "ChildFrm.h"
#include "wedDoc.h"
#include "wedView.h"
#include "splash.h"
#include "editor.h"
#include "notepad.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
Splash spp;
CBitmap caret;
CFont ff;
LOGFONT fflf;
CFont pp;
LOGFONT pplf;
int fgcol = 0;
int bgcol = 0xffffff;
int selcol = 0x808080;
int cselcol = 0xff0000;
CString strHash = "Hash";
CString strSection = "Files";
CString strConfig = "Config";
CString strStringItem = "File";
CString strIntItem = "Count";
CWnd *currentedit;
char approot[MAX_PATH];
CString dataroot;
static splashed = FALSE;
static comline = FALSE;
/////////////////////////////////////////////////////////////////////////////
// CWedApp
BEGIN_MESSAGE_MAP(CWedApp, CWinApp)
//{{AFX_MSG_MAP(CWedApp)
ON_COMMAND(ID_APP_ABOUT, OnAppAbout)
// NOTE - the ClassWizard will add and remove mapping macros here.
// DO NOT EDIT what you see in these blocks of generated code!
//}}AFX_MSG_MAP
// Standard file based document commands
ON_COMMAND(ID_FILE_NEW, CWinApp::OnFileNew)
ON_COMMAND(ID_FILE_OPEN, CWinApp::OnFileOpen)
// Standard print setup command
ON_COMMAND(ID_FILE_PRINT_SETUP, CWinApp::OnFilePrintSetup)
END_MESSAGE_MAP()
CMainFrame* pMainFrame;
int wait_exit = 0;
Search srcdlg;
/////////////////////////////////////////////////////////////////////////////
// CWedApp construction
CWedApp::CWedApp()
{
}
/////////////////////////////////////////////////////////////////////////////
// The one and only CWedApp object
CWedApp theApp;
CWedView *mainview;
/////////////////////////////////////////////////////////////////////////////
// CWedApp initialization
#include "direct.h"
#include "afxtempl.h"
HCURSOR WaitCursor;
HCURSOR NormalCursor;
/////////////////////////////////////////////////////////////////////////////
// BOOL CWedApp::InitInstance()
BOOL CWedApp::InitInstance()
{
CString str;
char *ptr;
WaitCursor = AfxGetApp()->LoadStandardCursor(IDC_WAIT);
NormalCursor = AfxGetApp()->LoadStandardCursor(IDC_ARROW);
GetModuleFileName(AfxGetInstanceHandle(),
approot, MAX_PATH);
ptr = strrchr(approot, '\\');
if(ptr) *(ptr+1) = '\0';
dataroot = (CString)approot + "wed\\";
if(access(dataroot, 0))
{
//PrintToNotepad("No data dir\r\n");
if(mkdir(dataroot))
{
//PrintToNotepad("Cannot create data dir\r\n");
}
}
str = dataroot; str += "data";
// Check if data dir is in order
if(access(str, 0))
{
//PrintToNotepad("No data dir\r\n");
if(mkdir(str))
{
//PrintToNotepad("Cannot create data dir\r\n");
}
}
str = dataroot; str += "macros";
// Check if data dir is in order
if(access(str, 0))
{
//PrintToNotepad("No macro dir\r\n");
if(mkdir(str))
{
//PrintToNotepad("Cannot create macro dir\r\n");
}
}
str = dataroot; str += "holdings";
// Check if data dir is in order
if(access(str, 0))
{
//PrintToNotepad("No holders dir\r\n");
if(mkdir(str))
{
//PrintToNotepad("Cannot create holders dir\r\n");
}
}
str = dataroot; str += "coco";
// Check if coco dir is in order
if(access(str, 0))
{
//PrintToNotepad("No coco dir\r\n");
if(mkdir(str))
{
//PrintToNotepad("Cannot create holders dir\r\n");
}
}
//PrintToNotepad("Started Application: %s %s\r\n",
// m_pszAppName, approot);
getcwd(str.GetBuffer(MAX_PATH), MAX_PATH);
str.ReleaseBuffer();
//PrintToNotepad("Initial dir: %s\r\n", str);
if (!AfxSocketInit())
{
AfxMessageBox(IDP_SOCKETS_INIT_FAILED);
return FALSE;
}
// Initialize OLE 2.0 libraries
if (!AfxOleInit())
{
AfxMessageBox("IDP_OLE_INIT_FAILED");
//return FALSE;
}
AfxEnableControlContainer();
//m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
// Standard initialization
// If you are not using these features and wish to reduce the size
// of your final executable, you should remove from the following
// the specific initialization routines you do not need.
#ifdef _AFXDLL
Enable3dControls(); // Call this when using MFC in a shared DLL
#else
Enable3dControlsStatic(); // Call this when linking to MFC statically
#endif
// Change the registry key under which our settings are stored.
// You should modify this string to be something appropriate
// such as the name of your company or organization.
SetRegistryKey(_T("PeterGlen"));
LoadStdProfileSettings(6); // Load standard INI file options (including MRU)
// Register the application's document templates. Document templates
// serve as the connection between documents, frame windows and views.
pDocTemplate = new CMultiDocTemplate(
IDR_WEDTYPE,
RUNTIME_CLASS(CWedDoc),
RUNTIME_CLASS(CChildFrame), // custom MDI child frame
RUNTIME_CLASS(CWedView));
AddDocTemplate(pDocTemplate);
// create main MDI Frame window
pMainFrame = new CMainFrame;
if (!pMainFrame->LoadFrame(IDR_MAINFRAME))
return FALSE;
m_pMainWnd = pMainFrame;
// Parse command line for standard shell commands, DDE, file open
CCommandLineInfo cmdInfo;
ParseCommandLine(cmdInfo);
if(cmdInfo.m_strFileName != "")
{
comline = TRUE;
OpenDocumentFile(cmdInfo.m_strFileName);
}
else
{
// DON'T display a new MDI child window during startup!!!
cmdInfo.m_nShellCommand = CCommandLineInfo::FileNothing;
}
// Dispatch commands specified on the command line
if (!ProcessShellCommand(cmdInfo))
return FALSE;
// Get resources we need:
// 1. Enum fonts
#if 0
if(!AddFontResource("sample.fnt"))
MessageBox(NULL, "Cannot add font", "Wed", 0);
#endif
if(!ff.CreateFont(0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, FIXED_PITCH, "system"))
{
MessageBox(NULL, "Cannot set font", "Wed", 0);
}
if(!ff.GetLogFont(&fflf))
MessageBox(NULL, "Cannot get font parameters", "Wed", 0);
// logfont
//PrintToNotepad("Font lfw = %d lfh = %d\r\n",
// fflf.lfWidth, fflf.lfHeight);
// Get printer stuff
if(!pp.CreateFont(80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
FF_MODERN, "system"))
{
//PrintToNotepad("Cannot set font\r\n");
MessageBox(NULL, "Cannot set font", "Wed", 0);
}
if(!pp.GetLogFont(&pplf))
MessageBox(NULL, "Cannot get font parameters", "Wed", 0);
// 2. Enum bimaps
caret.LoadBitmap(IDB_BITMAP1);
// Figure out last usage time:
int last = GetProfileInt(strConfig, "LastUsage", 0);
CTime tt = CTime::GetCurrentTime();
CTimeSpan t(tt.GetTime() - (time_t)last);
//PrintToNotepad("Time diff of last fire %d -- %d \r\n",
// t.GetTotalSeconds(), (int)tt.GetTime());
// Show only if more then 30 seconds pased
if(t.GetTotalSeconds() > 30)
{
spp.Create(IDD_DIALOG5, NULL);
RECT rect; AfxGetMainWnd()->GetClientRect(&rect);
AfxGetMainWnd()->ClientToScreen(&rect);
RECT rect2; spp.GetClientRect(&rect2);
int posx = rect.left + (rect.right - rect.left)/2 -
(rect2.right - rect2.left)/2;
int posy = rect.top + (rect.bottom - rect.top)/2 -
(rect2.bottom - rect2.top)/2;
spp.SetWindowPos( NULL, posx, posy, 0, 0,
SWP_NOOWNERZORDER | SWP_NOSIZE );
//spp.SetFocus();
spp.ShowWindow(SW_SHOW);
splashed = TRUE;
}
YieldToWin() ;
//if(GetKeyState(VK_SHIFT))
// {
// AfxMessageBox("SHIFT HELD on startup\r\n");
// return(TRUE);
// }
// The main window has been initialized ...
// Show and update it.
m_nCmdShow = GetProfileInt(strConfig, "WindowState", 1);
pMainFrame->ShowWindow(m_nCmdShow);
pMainFrame->UpdateWindow();
CString strConfig = "Config";
CString strSection = "Files";
CString strStringItem = "File";
CString strIntItem = "Count";
int num = GetProfileInt(strSection, strIntItem, 0);
// De serialize hash map
CMap < int, int&, CString, CString& > HashMap;
CFile cf;
CString fname;
fname.Format("%s%s", dataroot, "macros\\hashes.000");
if( cf.Open( fname, CFile::modeRead))
{
CArchive ar( &cf, CArchive::load);
HashMap.Serialize(ar);
}
else
{
//PrintToNotepad("Cannot open hash map file: %s\r\n", fname);
}
POSITION rpos;
rpos = HashMap.GetStartPosition();
while(rpos)
{
int key;
CString val;
HashMap.GetNextAssoc(rpos, key, val);
//PrintToNotepad("In Hashlist: %x %s\r\n", key, val);
}
if(!comline)
{
// Reopen old documents:
CString buf2, file;
for(int count1 = 1; count1 <= num; count1++)
{
CWedDoc *doc = NULL;
buf2.Format("%d", count1);
file = GetProfileString(strSection, strStringItem + buf2);
//PrintToNotepad("Reloading file: '%s' at %s\r\n", file, buf2);
// Empty file, next ...
if(file == "")
continue;
doc = (CWedDoc*)OpenDocumentFile(file);
PrintToNotepad("After Reloading file: %s at %s\r\n", file, buf2);
if(doc)
{
ASSERT_VALID(doc);
int lrow, lcol;
lrow = GetProfileInt(strSection,
strStringItem + buf2 + "row", 0);
lcol = GetProfileInt(strSection,
strStringItem + buf2 + "col", 0);
// Update cursor posions
POSITION pos = doc->GetFirstViewPosition();
for(;;)
{
if(!pos)
break;
CWedView *cv = (CWedView*)doc->GetNextView(pos);
if(cv)
{
ASSERT_VALID(cv);
cv->row = lrow; cv->col = lcol;
cv->sync_caret();
YieldToWin() ;
}
}
// This happens after load, set it again
doc->UpdateAllViews(NULL);
}
}
// Try figure out last current directory
int idx;
if((idx = file.ReverseFind('\\')) != -1)
{
file = file.Left(idx);
}
//PrintToNotepad("Chdir: %s\r\n", file);
_chdir(file);
}
message ("Loading macros");
LoadMacros();
message ("Loading holdings");
LoadHoldings();
//PrintToNotepad("Done reloading row/col\r\n");
return TRUE;
}
/////////////////////////////////////////////////////////////////////////////
// BOOL CWedApp::LoadMacros()
BOOL CWedApp::LoadMacros()
{
int loop;
// Save numbered macros
for(loop=0; loop < 10; loop++)
{
CFile cf;
CString fname;
fname.Format("%s%s%03d",
dataroot, "macros\\macro.", loop);
if(cf.Open( fname, CFile::modeRead))
{
CArchive ar( &cf, CArchive::load);
macros[loop].Serialize(ar);;
}
else
{
//PrintToNotepad("Cannot open macro file: %s\r\n", fname);
}
}
return 0;
}
/////////////////////////////////////////////////////////////////////////////
// BOOL CWedApp::SaveMacros()
BOOL CWedApp::SaveMacros()
{
int loop;
// Save numbered macros
for(loop=0; loop < 10; loop++)
{
// Do not save empty macro
if(macros[loop].IsEmpty())
continue;
CFile cf;
CString fname;
fname.Format("%s%s%03d",
dataroot, "macros\\macro.", loop);
if( cf.Open( fname, CFile::modeCreate | CFile::modeWrite ))
{
CArchive ar( &cf, CArchive::store);
macros[loop].Serialize(ar);
}
else
{
//PrintToNotepad("Cannot create macro file: %s\r\n", fname);
}
}
return 0;
}
/////////////////////////////////////////////////////////////////////////////
// BOOL CWedApp::SaveHoldings()
BOOL CWedApp::SaveHoldings()
{
int loop;
// Save numbered macros
for(loop=0; loop < 10; loop++)
{
// Do not save empty macro
if(holding[loop].IsEmpty())
continue;
CFile cf;
CString fname;
fname.Format("%s%s%03d",
dataroot, "holdings\\holding.", loop);
if( cf.Open( fname, CFile::modeCreate | CFile::modeWrite ))
{
CArchive ar( &cf, CArchive::store);
holding[loop].Serialize(ar);;
}
else
{
//PrintToNotepad("Cannot create macro file: %s\r\n", fname);
}
}
return 0;
}
/////////////////////////////////////////////////////////////////////////////
// BOOL CWedApp::LoadHoldings()
BOOL CWedApp::LoadHoldings()
{
int loop;
// Save numbered macros
for(loop=0; loop < 10; loop++)
{
CFile cf;
CString fname;
fname.Format("%s%s%03d",
dataroot, "holdings\\holding.", loop);
if( cf.Open( fname, CFile::modeRead))
{
CArchive ar( &cf, CArchive::load);
holding[loop].Serialize(ar);;
}
else
{
//PrintToNotepad("Cannot open holding file: %s\r\n", fname);
}
}
return 0;
}
/////////////////////////////////////////////////////////////////////////////
// CAboutDlg dialog used for App About
class CAboutDlg : public CDialog
{
public:
CAboutDlg();
// Dialog Data
//{{AFX_DATA(CAboutDlg)
enum { IDD = IDD_ABOUTBOX };
CString m_build;
CString m_date;
//}}AFX_DATA
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CAboutDlg)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
protected:
//{{AFX_MSG(CAboutDlg)
virtual BOOL OnInitDialog();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
{
//{{AFX_DATA_INIT(CAboutDlg)
m_build = _T("");
m_date = _T("");
//}}AFX_DATA_INIT
}
void CAboutDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CAboutDlg)
DDX_Text(pDX, IDC_EDIT1, m_build);
DDX_Text(pDX, IDC_EDIT2, m_date);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
//{{AFX_MSG_MAP(CAboutDlg)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
// App command to run the dialog
/////////////////////////////////////////////////////////////////////////////
// void CWedApp::OnAppAbout()
void CWedApp::OnAppAbout()
{
CAboutDlg aboutDlg;
aboutDlg.DoModal();
}
/////////////////////////////////////////////////////////////////////////////
// CWedApp commands
// Put a message to the status bar:
int timer_in = 0;
void message(const char * str)
{
((CMainFrame*)theApp.m_pMainWnd)->m_wndStatusBar
.SetPaneText(0, str);
timer_in = 8;
}
void rowcol(const char * str)
{
((CMainFrame*)theApp.m_pMainWnd)->m_wndStatusBar
.SetPaneText(1, str);
}
void hold(const char * str)
{
((CMainFrame*)theApp.m_pMainWnd)->m_wndStatusBar
.SetPaneText(4, str);
}
void mac(const char * str)
{
((CMainFrame*)theApp.m_pMainWnd)->m_wndStatusBar
.SetPaneText(5, str);
}
void mode(const char * str)
{
((CMainFrame*)theApp.m_pMainWnd)->m_wndStatusBar
.SetPaneText(6, str);
}
#define ROTATE_LONG_LEFT(x, n) (((x) << (n)) | ((x) >> (32 - (n))))
#define ROTATE_LONG_RIGHT(x, n) (((x) >> (n)) | ((x) << (32 - (n))))
int HashString(const char *name)
{
unsigned int ret_val = 0;
while(*name != '\0')
{
ret_val ^= (int)*name;
ret_val = ROTATE_LONG_RIGHT(ret_val, 3); /* rotate right */
*name++;
}
return((int)ret_val);
}
/////////////////////////////////////////////////////////////////////////////
// void CWedApp::OpenFile()
void CWedApp::OpenFile()
{
OnFileOpen();
}
/////////////////////////////////////////////////////////////////////////////
// void CWedApp::NewFile()
void CWedApp::NewFile()
{
OnFileNew();
}
/////////////////////////////////////////////////////////////////////////////
// int CWedApp::ExitInstance()
int CWedApp::ExitInstance()
{
#if 0
if(!RemoveFontResource("sample.fnt"))
MessageBox(NULL, "Cannot remove font", "Wed", 0);
#endif
//PrintToNotepad("Terminated Application: %s %s\r\n",
// m_pszAppName, approot);
//if(wait_exit)
// {
// for(int loop = 0; loop < 10; loop++)
// {
// YieldToWin(); Sleep(20);
// }
// }
return CWinApp::ExitInstance();
}
/////////////////////////////////////////////////////////////////////////////
// BOOL CWedApp::SaveAllModified()
BOOL CWedApp::SaveAllModified()
{
// Save reopen information:
CString buf;
CPtrList il;
int row, col;
if(!comline)
{
// Save list of buffers
POSITION Pos = pDocTemplate->GetFirstDocPosition();
int count = 0;
// Make a list, current edited buffer as last
for(;;)
{
if(!Pos)
break;
CWedDoc* doc = (CWedDoc*)pDocTemplate->GetNextDoc(Pos);
POSITION pos = doc->GetFirstViewPosition();
CView *cv = doc->GetNextView(pos); ASSERT_VALID(cv);
if(cv != currentedit)
il.AddTail(cv);
}
if(currentedit)
il.AddTail(currentedit);
POSITION pos = il.GetHeadPosition();
for(;;)
{
if(!pos)
break;
CView *cv = (CView*)il.GetNext(pos);
if(!cv)
break;
ASSERT_VALID(cv);
CWedDoc* doc = (CWedDoc*)cv->GetDocument();
if(!doc)
break;
ASSERT_VALID(doc);
CString file = doc->GetPathName();
row = ((CWedView*)cv)->row; col = ((CWedView*)cv)->col;
buf.Format("%d", count + 1);
WriteProfileString(strSection, strStringItem + buf, file);
WriteProfileInt(strSection, strStringItem + buf + "row", row);
WriteProfileInt(strSection, strStringItem + buf + "col", col);
count++;
}
WriteProfileInt(strSection, strIntItem, count);
}
// Serialize holdings
message ("Saving holdings");
SaveHoldings();
// Serialize macros
message ("Saving macros");
SaveMacros();
// Save config information:
CTime t = CTime::GetCurrentTime();
WriteProfileInt(strConfig, "LastUsage",
(int)t.GetTime());
// Save main frame window placement
WINDOWPLACEMENT wp;
pMainFrame->GetWindowPlacement(&wp);
WriteProfileInt(strConfig, "WindowState", wp.showCmd);
// Save file informaion
// Save current window focus:
return CWinApp::SaveAllModified();
}
/////////////////////////////////////////////////////////////////////////////
// int CWedApp::Run()
int CWedApp::Run()
{
if(splashed)
{
for(int loop=0; loop<100;loop++)
{
Sleep(20); YieldToWin();
}
spp.DestroyWindow();
}
return CWinApp::Run();
}
CMenu *GetTemplateMenu()
{
int iPos;
CMenu* pViewMenu = NULL;
CMenu* pTopMenu = AfxGetMainWnd()->GetMenu();
for (iPos = pTopMenu->GetMenuItemCount()-1; iPos >= 0; iPos--)
{
CMenu* pMenu = pTopMenu->GetSubMenu(iPos);
if (pMenu && pMenu->GetMenuItemID(0) == ID_VIEW_TOOLBAR)
{
pViewMenu = pMenu;
break;
}
}
ASSERT(pViewMenu != NULL);
CMenu* pfMenu = NULL;
for (iPos = pViewMenu->GetMenuItemCount()-1; iPos >= 0; iPos--)
{
pfMenu = pViewMenu->GetSubMenu(iPos);
if(pfMenu)
break;
}
ASSERT(pfMenu != NULL);
return (pfMenu);
}
// Save all documents ...
void SaveAllDocs()
{
CWedDoc* pDoc = NULL;
CMultiDocTemplate* pDocTemplate =
((CWedApp*)AfxGetApp())->pDocTemplate;
POSITION Pos = pDocTemplate->GetFirstDocPosition();
for(;;)
{
if(!Pos)
break;
CWedDoc* doc = (CWedDoc*)pDocTemplate->GetNextDoc(Pos);
if(!doc)
continue;
ASSERT_VALID(doc);
if(doc->IsModified())
doc->OnSaveDocument(doc->GetPathName());
}
}
#include "build.h"
char bnum[] = CURRENTBUILD;
char bdate[] = CURRENTDATE;
BOOL CAboutDlg::OnInitDialog()
{
m_build = bnum;
m_date = bdate;
CDialog::OnInitDialog();
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
|
[
"none@none"
] |
[
[
[
1,
864
]
]
] |
9ef948af00490ee81b8fb71b771a2fa97ae0b03f
|
9907be749dc7553f97c9e51c5f35e69f55bd02c0
|
/april5/framework code & project/audio_handler.cpp
|
6c013b368a55c1241cf7fad43cff96d7de895e61
|
[] |
no_license
|
jdeering/csci476winthrop
|
bc8907b9cc0406826de76aca05e6758810377813
|
2bc485781f819c8fd82393ac86de33404e7ad6d3
|
refs/heads/master
| 2021-01-10T19:53:14.853438 | 2009-04-24T14:26:36 | 2009-04-24T14:26:36 | 32,223,762 | 0 | 0 | null | null | null | null |
UTF-8
|
C++
| false | false | 4,836 |
cpp
|
#include "audio_handler.h"
/******************************************************
Default Constructor
******************************************************/
AudioHandler::AudioHandler()
{
muted = false;
volume = (MAX_VOLUME - MIN_VOLUME) / 2;
}
/******************************************************
Default Destructor
******************************************************/
AudioHandler::~AudioHandler()
{
for(std::map<std::string, Audio>::iterator i = samples.begin(); i != samples.end(); ++i)
{
i->second.~Audio();
}
samples.clear();
}
/******************************************************
Adds an audio sample to the container at the
specified key, or updates the audio sample at the
key.
@param refName The key name for the sample to add.
@param sample The Allegro SAMPLE* associated with the key.
@param loop <code>true</code> if the sample loops when played, <code>false</code> if it doesn't.
@return <code>true</code> if the sample is successfully added, <code>false</code> otherwise.
******************************************************/
bool AudioHandler::AddSample(std::string refName, SAMPLE *sample, bool loop)
{
if(numSamples < MAXFILES)
{
Audio temp(sample, loop);
samples[refName] = temp;
numSamples++;
}
else
{
allegro_message("Sample \"%d\" could not be added.", refName);
return false;
}
}
/******************************************************
Removes the audio sample from the container at the
specified key.
@param refName The key name for the sample to remove.
@return <code>true</code> if the sample is successfully removed, <code>false</code> otherwise.
******************************************************/
bool AudioHandler::RemoveSample(std::string refName)
{
std::map<std::string, Audio>::iterator loc = samples.find(refName);
if(numSamples > 0 && loc != samples.end())
{
samples.erase(loc);
numSamples--;
return true;
}
else
{
allegro_message("Sample \"%d\" not found or could not be removed.", refName);
return false;
}
}
/******************************************************
Plays the audio sample at the specified key.
@param refName The key name for the sample to play.
@param volume_ The volume to play the sample at.
@return <code>true</code> if the sample is successfully started, <code>false</code> otherwise.
******************************************************/
bool AudioHandler::PlaySample(std::string refName, int volume_)
{
if(muted)
volume_ = 0;
if(samples[refName].Play(volume_) < 0)
{
allegro_message("Sample \"%d\" could not be played.\n(May be out of voice channels)", refName);
return false;
}
else
return true;
}
/******************************************************
Stops the audio sample at the specified key.
@param refName The key name for the sample to stop playing.
******************************************************/
void AudioHandler::StopSample(std::string refName)
{
samples[refName].Stop();
}
/******************************************************
Sets the volume at which to play all samples.
@param vol The volume at which to play audio samples (0 to 100);
******************************************************/
void AudioHandler::SetVolume(int vol)
{
volume = vol * MAX_VOLUME / 100;
ResetVolume(volume);
}
/******************************************************
Mutes all playing samples and subsequently played samples.
******************************************************/
void AudioHandler::Mute()
{
muted = true;
ResetVolume(0);
}
/******************************************************
Unmutes all playing samples and subsequently played samples.
******************************************************/
void AudioHandler::Unmute()
{
muted = false;
ResetVolume(volume);
}
/******************************************************
Resets the loop flag for the audio sample at the
specified key.
@param refName The key value for the audio sample.
@param loop The new value for the loop flag. Zero for no looping, non-zero for looping.
******************************************************/
void AudioHandler::ResetLoopFlag(std::string refName, int loop)
{
samples[refName].ResetLoopFlag(volume, loop);
}
/******************************************************
Resets the volume for all currently playing samples.
@param volume_ The volume at which to set the samples (0 to 255).
******************************************************/
void AudioHandler::ResetVolume(int volume_)
{
for(std::map<std::string, Audio>::iterator i = samples.begin(); i != samples.end(); ++i)
{
i->second.ResetVolume(volume_);
}
if(volume_) // Only resets volume if not muting
volume = volume_;
}
|
[
"lcairco@2656ef14-ecf4-11dd-8fb1-9960f2a117f8"
] |
[
[
[
1,
156
]
]
] |
4a54ea788096abb1ca6268ac4d9573214cf5e531
|
3da0b0276bc8c3d7d1bcdbabfb0e763a38d3a24c
|
/zju.finished/1486.cpp
|
a82c17d4f3a8789b52199614b0e2cc716417e437
|
[] |
no_license
|
usherfu/zoj
|
4af6de9798bcb0ffa9dbb7f773b903f630e06617
|
8bb41d209b54292d6f596c5be55babd781610a52
|
refs/heads/master
| 2021-05-28T11:21:55.965737 | 2009-12-15T07:58:33 | 2009-12-15T07:58:33 | null | 0 | 0 | null | null | null | null |
UTF-8
|
C++
| false | false | 1,074 |
cpp
|
#include<iostream>
using namespace std;
enum {
SIZ = 100,
};
template<int N>
struct BigNum {
int d[N];
int len;
BigNum(){
len = 0;
}
void operator=(int );
void operator *=(int);
void print();
};
template<int N>
void BigNum<N>::operator=(int n){
len = 0;
do {
d[len++] = n%10;
n /= 10;
} while(n>0);
}
template<int N>
void BigNum<N>::operator *=(int m){
int carry = 0;
int i;
for(i=0;i<len;i++){
carry += d[i] * m;
d[i] = carry % 10;
carry /= 10;
}
while(carry){
d[len++] = carry % 10;
carry /= 10;
}
}
template<int N>
void BigNum<N>::print(void){
for(int i=len-1;i>=0;i--){
printf("%d", d[i]);
}
printf("\n");
}
int N, K;
BigNum<SIZ> res;
void fun(){
res = K;
for(int i=1; i<N; i++){
res *= (K-1);
}
res.print();
}
int main(){
int i, a, b;
scanf("%d%d", &N, &K);
while(N + K){
for(i=1; i<N; i++){
scanf("%d%d",&a,&b);
}
fun();
scanf("%d%d", &N, &K);
}
return 0;
}
|
[
"[email protected]"
] |
[
[
[
1,
70
]
]
] |
5965dd017a42a792fa3cc50226c79b7f9ade33f3
|
7acbb1c1941bd6edae0a4217eb5d3513929324c0
|
/GLibrary-CPP/sources/GAlgo.cpp
|
4351ff0f9b86eefa4d69da0f5babb20cc4554ded
|
[] |
no_license
|
hungconcon/geofreylibrary
|
a5bfc96e0602298b5a7b53d4afe7395a993498f1
|
3abf3e1c31a245a79fa26b4bcf2e6e86fa258e4d
|
refs/heads/master
| 2021-01-10T10:11:51.535513 | 2009-11-30T15:29:34 | 2009-11-30T15:29:34 | 46,771,895 | 1 | 1 | null | null | null | null |
UTF-8
|
C++
| false | false | 2,821 |
cpp
|
#include "GAlgo.h"
int GAlgo::PGCD(int a, int b)
{
if (a < b)
{
int c = a;
a = b;
b = c;
}
while (true)
{
int reste = (int)(a / b);
reste = a - b * reste;
if (reste == 0)
return (b);
a = b;
b = reste;
}
return (1);
}
GStringList GAlgo::GStringToArray(const GString &s)
{
GString str(s);
GStringList result;
int save = -1;
for (unsigned int i = 0; i < str.Size(); ++i)
{
if (str[i] == '+' || str[i] == '-' || str[i] == '/' || str[i] == '*' || str[i] == '%' || str[i] == '(' || str[i] == ')' || str[i] == ']' || str[i] == '[')
{
if (save != -1)
{
result.PushBack(str.Substr(save, i));
save = -1;
}
result.PushBack(GString(str[i]));
}
else if (str[i] != ' ')
{
if (save == -1)
save = i;
}
}
if (save != -1)
result.PushBack(str.Substr(save, str.Size()));
return (result);
}
// MODIF STACK //
GStringList GAlgo::GStringToNPI(const GString &s)
{
GStringList l = GAlgo::GStringToArray(s);
GStringList sortie;
GStringList pile;
GMap<GString, int> priority;
priority["+"] = 0;
priority["-"] = 0;
priority["%"] = 1;
priority["*"] = 1;
priority["/"] = 1;
for (unsigned int i = 0; i < l.Size(); ++i)
{
if (l[i] == "(" || l[i] == "[")
pile.PushBack(l[i]);
else if (l[i].IsNumeric() || l[i].IsAlpha())
sortie.PushBack(l[i]);
else if (l[i] == ")")
{
while (pile.Back() != "(")
{
sortie.PushBack(pile.PopBack());
if (pile.Size() == 0)
throw GException("GAlgo", "Bad Expression");
}
pile.PopBack();
}
else if (l[i] == "]")
{
while (pile.Back() != "[")
{
sortie.PushBack(pile.PopBack());
if (pile.Size() == 0)
throw GException("GAlgo", "Bad Expression");
}
pile.PopBack();
}
else
{
if (pile.Size())
{
while (pile.Back() != "[" && pile.Back() != "]" && pile.Back() != "(" && pile.Back() != ")")
{
if (priority[pile.Back()] < priority[l[i]])
sortie.PushBack(pile.PopBack());
}
}
pile.PushBack(l[i]);
}
}
while (pile.Size() > 0)
sortie.PushBack(pile.PopBack());
return (sortie);
}
int GAlgo::GStringToInt(const GString &s)
{
GStringList l = GAlgo::GStringToNPI(s);
int n1, n2;
while (l.Size() != 1)
{
n1 = l.PopBack().ToInt();
n2 = l.PopBack().ToInt();
if (l.Back() == "+")
{
l.PopBack();
l.PushBack(GString(n1 + n2));
}
else if (l.Back() == "-")
{
l.PopBack();
l.PushBack(GString(n1 - n2));
}
else if (l.Back() == "*")
{
l.PopBack();
l.PushBack(GString(n1 * n2));
}
}
return (l.PopBack().ToInt());
}
unsigned int GAlgo::Pow(unsigned int Nbr, unsigned int Power)
{
if (Pow == 0)
return (1);
return (Nbr * GAlgo::Pow(Nbr, Power - 1));
}
|
[
"mvoirgard@34e8d5ee-a372-11de-889f-a79cef5dd62c",
"[email protected]",
"tincani.geoffrey@34e8d5ee-a372-11de-889f-a79cef5dd62c"
] |
[
[
[
1,
50
],
[
53,
133
]
],
[
[
51,
52
]
],
[
[
134,
140
]
]
] |
f7ded9dfbef1543f0071934db91587db2ec77d31
|
78fb44a7f01825c19d61e9eaaa3e558ce80dcdf5
|
/guidriverMyGUIOgre/src/guceMyGUIOgre_CGUIContext.cpp
|
367ba8b7a57d433f15cf91b614bee6281049a5e4
|
[] |
no_license
|
LiberatorUSA/GUCE
|
a2d193e78d91657ccc4eab50fab06de31bc38021
|
a4d6aa5421f8799cedc7c9f7dc496df4327ac37f
|
refs/heads/master
| 2021-01-02T08:14:08.541536 | 2011-09-08T03:00:46 | 2011-09-08T03:00:46 | 41,840,441 | 0 | 0 | null | null | null | null |
UTF-8
|
C++
| false | false | 5,910 |
cpp
|
/*
* guceMyGUIOgre: glue module for the MyGUI+Ogre GUI backend
* Copyright (C) 2002 - 2008. Dinand Vanvelzen
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/*-------------------------------------------------------------------------//
// //
// INCLUDES //
// //
//-------------------------------------------------------------------------*/
#include <assert.h>
#ifndef GUCE_MYGUIOGRE_CGUIDRIVER_H
#include "guceMyGUIOgre_CGUIDriver.h"
#define GUCE_MYGUIOGRE_CGUIDRIVER_H
#endif /* GUCE_MYGUIOGRE_CGUIDRIVER_H ? */
#include "guceMyGUIOgre_CGUIContext.h"
/*-------------------------------------------------------------------------//
// //
// NAMESPACE //
// //
//-------------------------------------------------------------------------*/
namespace GUCE {
namespace MYGUIOGRE {
/*-------------------------------------------------------------------------//
// //
// UTILITIES //
// //
//-------------------------------------------------------------------------*/
CGUIContext::CGUIContext( CGUIDriver& myGuiDriver )
: GUCEF::GUI::CIGUIContext() ,
m_driver( &myGuiDriver ) ,
m_widgetSet() ,
m_formSet()
{GUCE_TRACE;
assert( NULL != m_driver );
}
/*-------------------------------------------------------------------------*/
CGUIContext::~CGUIContext()
{GUCE_TRACE;
}
/*-------------------------------------------------------------------------*/
GUCEF::GUI::CWidget*
CGUIContext::CreateWidget( const CString& widgetName )
{GUCE_TRACE;
GUCEF::GUI::CWidget* widget = m_driver->CreateWidget( widgetName );
if ( NULL != widget )
{
m_widgetSet.insert( widget );
return widget;
}
return NULL;
}
/*-------------------------------------------------------------------------*/
void
CGUIContext::DestroyWidget( GUCEF::GUI::CWidget* widget )
{GUCE_TRACE;
m_widgetSet.erase( widget );
m_driver->DestroyWidget( widget );
}
/*-------------------------------------------------------------------------*/
GUCEF::GUI::CForm*
CGUIContext::CreateForm( const CString& formName )
{GUCE_TRACE;
GUCEF::GUI::CForm* form = m_driver->CreateForm( formName );
if ( NULL != form )
{
m_formSet.insert( form );
return form;
}
return NULL;
}
/*-------------------------------------------------------------------------*/
void
CGUIContext::DestroyForm( GUCEF::GUI::CForm* form )
{GUCE_TRACE;
m_formSet.erase( form );
m_driver->DestroyForm( form );
}
/*-------------------------------------------------------------------------*/
CGUIContext::TStringSet
CGUIContext::GetAvailableFormTypes( void )
{GUCE_TRACE;
return m_driver->GetAvailableFormTypes();
}
/*-------------------------------------------------------------------------*/
CGUIContext::TStringSet
CGUIContext::GetAvailableWidgetTypes( void )
{GUCE_TRACE;
return m_driver->GetAvailableWidgetTypes();
}
/*-------------------------------------------------------------------------*/
GUCEF::GUI::CFormBackend*
CGUIContext::CreateFormBackend( void )
{GUCE_TRACE;
return m_driver->CreateFormBackend();
}
/*-------------------------------------------------------------------------*/
void
CGUIContext::DestroyFormBackend( GUCEF::GUI::CFormBackend* formBackend )
{GUCE_TRACE;
m_driver->DestroyFormBackend( formBackend );
}
/*-------------------------------------------------------------------------*/
GUCEF::GUI::CGUIDriver*
CGUIContext::GetDriver( void )
{GUCE_TRACE;
return m_driver;
}
/*-------------------------------------------------------------------------*/
CGUIContext::TWidgetSet
CGUIContext::GetOwnedWidgets( void )
{GUCE_TRACE;
return m_widgetSet;
}
/*-------------------------------------------------------------------------*/
CGUIContext::TFormSet
CGUIContext::GetOwnedForms( void )
{GUCE_TRACE;
return m_formSet;
}
/*-------------------------------------------------------------------------//
// //
// NAMESPACE //
// //
//-------------------------------------------------------------------------*/
}; /* namespace MYGUIOGRE */
}; /* namespace GUCE */
/*-------------------------------------------------------------------------*/
|
[
"[email protected]"
] |
[
[
[
1,
189
]
]
] |
6bfd5d1cfbe100b3422066d9f86f26c689b7d899
|
8ddac2310fb59dfbfb9b19963e3e2f54e063c1a8
|
/Logiciel_PC/WishBoneMonitor/wbreadregisterdoc.h
|
0df8dd6fc07a78cb6a1ade355d2a66a518d03a3e
|
[] |
no_license
|
Julien1138/WishBoneMonitor
|
75efb53585acf4fd63e75fb1ea967004e6caa870
|
3062132ecd32cd0ffdd89e8a56711ae9a93a3c48
|
refs/heads/master
| 2021-01-12T08:25:34.115470 | 2011-05-02T16:35:54 | 2011-05-02T16:35:54 | 76,573,671 | 0 | 0 | null | null | null | null |
UTF-8
|
C++
| false | false | 1,077 |
h
|
#ifndef WBREADREGISTERDOC_H
#define WBREADREGISTERDOC_H
#include "WishBoneWidgetDoc.h"
#include "WishBoneRegister.h"
#define WBREAD_WIDTH_MIN 100
#define WBREAD_HEIGHT_MIN 60
class WBReadRegisterDoc : public WishBoneWidgetDoc
{
public:
WBReadRegisterDoc(MailBoxDriver* pMailBox);
WBReadRegisterDoc(const QString &Title
, MailBoxDriver* pMailBox
, int X = 0
, int Y = 0
, int Width = WBREAD_WIDTH_MIN
, int Height = 80);
~WBReadRegisterDoc();
WidgetType GetType(){return eReadRegister;}
void Load(QSettings* pSettings, QList<WishBoneRegister*>* plistRegisters);
void Save(QSettings* pSettings);
void SetpRegister(WishBoneRegister* pReg){m_pRegister = pReg;}
WishBoneRegister* Register(){return m_pRegister;}
bool HasReadButton(){return !(m_pRegister->Period());}
void ReadRegister();
private:
WishBoneRegister* m_pRegister;
};
#endif // WBREADREGISTERDOC_H
|
[
"[email protected]"
] |
[
[
[
1,
37
]
]
] |
7e8b4baa404f37520cc4224f467ac1c8f886b155
|
26867688a923573593770ef4c25de34e975ff7cb
|
/mmokit/cpp/server/databaseServer/inc/database.h
|
3d878dba45d91edb20a1cd398816a8a904159515
|
[] |
no_license
|
JeffM2501/mmokit
|
2c2b873202324bd37d0bb2c46911dc254501e32b
|
9212bf548dc6818b364cf421778f6a36f037395c
|
refs/heads/master
| 2016-09-06T10:02:07.796899 | 2010-07-25T22:12:15 | 2010-07-25T22:12:15 | 32,234,709 | 1 | 0 | null | null | null | null |
UTF-8
|
C++
| false | false | 1,659 |
h
|
// database.cpp : Defines the entry point for the console application.
//
#ifndef _DATABASE_H_
#define _DATABASE_H_
#include <stdio.h>
#include <string>
#include <vector>
#include <map>
class DatabaseItem
{
public:
DatabaseItem(std::string _data){data = _data;}
std::string data;
};
typedef std::vector<DatabaseItem> DatabseItemList;
class DatabaseRecord
{
public:
DatabseItemList items;
};
typedef std::map<std::string,DatabaseRecord> DatabaseRecordMap;
typedef std::vector<std::string> DatabaseLabelList;
class DatabaseTable
{
public:
DatabaseRecordMap records;
DatabaseLabelList labels;
int getLabelIndex ( std::string &label );
DatabaseRecord* findRecordByKey ( std::string &key );
DatabaseItem* findRecordItemByKey ( std::string &key, std::string &label );
DatabaseItem* findRecordItemByKey ( std::string &key, int label );
DatabaseRecord* addRecord ( std::string &key );
void deleteRecord ( std::string &key );
void addLabel ( std::string &label, bool unique = true, std::string defaultData = std::string(""));
void deleteLabel ( std::string &label);
};
typedef std::map<std::string, DatabaseTable> DatabaseTableMap;
class Database
{
public:
Database( const char* filename = NULL );
virtual ~Database();
bool read ( const char* filename = NULL );
bool write ( void );
DatabaseTable* getTable ( std::string &table );
DatabaseTable* newTable ( std::string &table );
void invalidate ( void ){revision++;}
protected:
unsigned int revision;
unsigned int diskRev;
std::string diskFile;
DatabaseTableMap tables;
};
#endif //_DATABASE_H_
|
[
"JeffM2501@b8188ba6-572f-0410-9fd0-1f3cfbbf368d"
] |
[
[
[
1,
73
]
]
] |
a159a7bf71f6782c2cc902214111176cc3de9f6e
|
de2b54a7b68b8fa5d9bdc85bc392ef97dadc4668
|
/Tracker/Init/InitTracker.cpp
|
90943114993104b0cc3f17acb78943d9326f31d6
|
[] |
no_license
|
kumarasn/tracker
|
8c7c5b828ff93179078cea4db71f6894a404f223
|
a3e5d30a3518fe3836f007a81050720cef695345
|
refs/heads/master
| 2021-01-10T07:57:09.306936 | 2009-04-17T15:02:16 | 2009-04-17T15:02:16 | 55,039,695 | 0 | 0 | null | null | null | null |
UTF-8
|
C++
| false | false | 3,644 |
cpp
|
/*
* InitTracker.cpp
*
* Created on: 29/03/2009
* Author: Pablo
*/
#include "InitTracker.h"
#define _WIN32_WINNT 0x0501
#include "..\Camera\CamHandler.h"
#include "..\NeuralNetwork\NeuralNet.h"
#include "..\Filters\FilterHandler.h"
#include "..\Utils\ImageUtilities.h"
#include "..\ConfigurationHandler\ConfigHandler.h"
#include "..\stabilizers\LightStabilizer.h"
#include "..\Logger\LogHandler.h"
#include "iostream.h"
#include "cv.h"
#include <windows.h>
#include "iostream.h"
InitTracker::InitTracker(CoordsSaver* coordSaver, SystemInfo* sysInfo):InitializerCreator() {
this->coordSaver = coordSaver;
this->sysInfo = sysInfo;
}
InitTracker::~InitTracker() {
;
}
int InitTracker::start()
{
LogHandler *logger = new LogHandler();
ConfigHandler *config = new ConfigHandler(logger);
CamHandler *cam = new CamHandler(logger);
NeuralNet *net = new NeuralNet(logger);
LightStabilizer *lightStabilizer = new LightStabilizer(logger);
FilterHandler *filterHandler = new FilterHandler(logger);
ImageUtilities *util = new ImageUtilities();
logger->initLogger();
if ( !config->openConfigFile("config.data") ){
logger->closeLogger();
return -1;
}
if ( !cam->initCamDevice() ){
logger->closeLogger();
return -1;
}
net->setnetFile(config->getTrackerNetFile());
if ( !net->startNet()){
logger->closeLogger();
return -1;
}
filterHandler->setSkinMaskFile(config->getSkinMaskFile());
filterHandler->setSkinDelta(config->getSkinDelta());
filterHandler->init();
//Hand Diagnostic
lightStabilizer->setThreshold_delta(config->getLightStabilizerThresholdDelta());
lightStabilizer->runAmbientDiagnostic(cam,filterHandler);
//End Hand Diagnostic
filterHandler->setSkinThreshold(lightStabilizer->getSkinThreshold());
std::string MainWindow = cam->getFirstWindow();
std::string NetWindow = cam->getThirdWindow();
int Xcoord,Ycoord,XcoordFIR,YcoordFIR;
IplImage* Close = cvLoadImage("Images\\hand_close.jpg");
IplImage* Open = cvLoadImage("Images\\hand_open.jpg");
//int x_val, y_val,cx,cy;
//sysInfo->getSystemRatio(x_val,y_val);
//sysInfo->getSystemResolution(cx,cy);
IplImage* currentFrame;
IplImage* filteredImage;
while ( cam->stillTracking() ){
currentFrame = cam->retrieveFrame();
filteredImage = filterHandler->runPreFilters(currentFrame);
//Hand Tracker
net->run(filteredImage);
Xcoord = net->getXcoord();
Ycoord = net->getYcoord();
filterHandler->runLowPassFilter(Xcoord,Ycoord,XcoordFIR,YcoordFIR);
util->putMarker(currentFrame,XcoordFIR*4,YcoordFIR*4);
//SetCursorPos((cx - XcoordFIR * x_val) ,(cy - YcoordFIR * y_val) );
coordSaver->saveCoords(XcoordFIR,YcoordFIR);
cam->showFrame(NetWindow,filteredImage);
cam->showFrame(MainWindow,currentFrame);
//Static Gesture Recognition through skin pixel count
if ( filterHandler->getSkinCount() > filterHandler->getSkinThreshold()){ // Mano Abierta: mas pixeles blancos
cam->showFrame(cam->getSecondWindow(),Open);
//mouse_event(MOUSEEVENTF_LEFTUP, XcoordFIR * x_val, cy - YcoordFIR * y_val, 0, 0);
}
else{
//mouse_event(MOUSEEVENTF_LEFTDOWN, XcoordFIR * x_val, cy - YcoordFIR * y_val, 0, 0);
cam->showFrame(cam->getSecondWindow(),Close);
}
cvReleaseImage( &filteredImage );
}
cam->stopCamDevice();
net->shutDown();
logger->closeLogger();
return 0;
}
|
[
"latesisdegrado@048d8772-f3ab-11dd-a8e2-f7cb3c35fcff"
] |
[
[
[
1,
186
]
]
] |
908b338ca8f5d21b7f94ddf80ca40653982308a7
|
f9d55548d2d1044dc344bb9685393f6e820d44df
|
/src/bullet/btSoftRigidDynamicsWorld.cpp
|
dba6fb348973d214f66e5734a6d9a8cf9d51f755
|
[] |
no_license
|
schweikm/3DJoust
|
5709bed8e6ad5299faef576d4d754e8f15004fdb
|
d662b9379cd1afc8204535254343df42ff438b9d
|
refs/heads/master
| 2020-12-24T05:24:09.774415 | 2011-10-08T03:47:29 | 2011-10-08T03:47:29 | 61,953,068 | 0 | 0 | null | null | null | null |
UTF-8
|
C++
| false | false | 3,907 |
cpp
|
/*
Bullet Continuous Collision Detection and Physics Library
Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/
This software is provided 'as-is', without any express or implied warranty.
In no event will the authors be held liable for any damages arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it freely,
subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
*/
#include "btSoftRigidDynamicsWorld.h"
#include "btQuickprof.h"
//softbody & helpers
#include "btSoftBody.h"
#include "btSoftBodyHelpers.h"
btSoftRigidDynamicsWorld::btSoftRigidDynamicsWorld(btDispatcher* dispatcher,btBroadphaseInterface* pairCache,btConstraintSolver* constraintSolver,btCollisionConfiguration* collisionConfiguration)
:btDiscreteDynamicsWorld(dispatcher,pairCache,constraintSolver,collisionConfiguration)
{
m_drawFlags = fDrawFlags::Std;
m_drawNodeTree = true;
m_drawFaceTree = false;
m_drawClusterTree = false;
m_sbi.m_broadphase = pairCache;
m_sbi.m_dispatcher = dispatcher;
m_sbi.m_sparsesdf.Initialize();
m_sbi.m_sparsesdf.Reset();
}
btSoftRigidDynamicsWorld::~btSoftRigidDynamicsWorld()
{
}
void btSoftRigidDynamicsWorld::predictUnconstraintMotion(btScalar timeStep)
{
btDiscreteDynamicsWorld::predictUnconstraintMotion( timeStep);
for ( int i=0;i<m_softBodies.size();++i)
{
btSoftBody* psb= m_softBodies[i];
psb->predictMotion(timeStep);
}
}
void btSoftRigidDynamicsWorld::internalSingleStepSimulation( btScalar timeStep)
{
btDiscreteDynamicsWorld::internalSingleStepSimulation( timeStep );
///solve soft bodies constraints
solveSoftBodiesConstraints();
///update soft bodies
updateSoftBodies();
}
void btSoftRigidDynamicsWorld::updateSoftBodies()
{
BT_PROFILE("updateSoftBodies");
for ( int i=0;i<m_softBodies.size();i++)
{
btSoftBody* psb=(btSoftBody*)m_softBodies[i];
psb->integrateMotion();
}
}
void btSoftRigidDynamicsWorld::solveSoftBodiesConstraints()
{
BT_PROFILE("solveSoftConstraints");
if(m_softBodies.size())
{
btSoftBody::solveClusters(m_softBodies);
}
for(int i=0;i<m_softBodies.size();++i)
{
btSoftBody* psb=(btSoftBody*)m_softBodies[i];
psb->solveConstraints();
}
}
void btSoftRigidDynamicsWorld::addSoftBody(btSoftBody* body)
{
m_softBodies.push_back(body);
btCollisionWorld::addCollisionObject(body,
btBroadphaseProxy::DefaultFilter,
btBroadphaseProxy::AllFilter);
}
void btSoftRigidDynamicsWorld::removeSoftBody(btSoftBody* body)
{
m_softBodies.remove(body);
btCollisionWorld::removeCollisionObject(body);
}
void btSoftRigidDynamicsWorld::debugDrawWorld()
{
btDiscreteDynamicsWorld::debugDrawWorld();
if (getDebugDrawer())
{
int i;
for ( i=0;i<this->m_softBodies.size();i++)
{
btSoftBody* psb=(btSoftBody*)this->m_softBodies[i];
btSoftBodyHelpers::DrawFrame(psb,m_debugDrawer);
btSoftBodyHelpers::Draw(psb,m_debugDrawer,m_drawFlags);
if (m_debugDrawer && (m_debugDrawer->getDebugMode() & btIDebugDraw::DBG_DrawAabb))
{
if(m_drawNodeTree) btSoftBodyHelpers::DrawNodeTree(psb,m_debugDrawer);
if(m_drawFaceTree) btSoftBodyHelpers::DrawFaceTree(psb,m_debugDrawer);
if(m_drawClusterTree) btSoftBodyHelpers::DrawClusterTree(psb,m_debugDrawer);
}
}
}
}
|
[
"[email protected]"
] |
[
[
[
1,
135
]
]
] |
69cb703cce0894cf505abe4dba6b25b4f0ec4215
|
28aa891f07cc2240c771b5fb6130b1f4025ddc84
|
/eop/back_tracking_recursive.cpp
|
047975f5ee118a21a9eeda41f8f020a43ab2731a
|
[] |
no_license
|
Hincoin/mid-autumn
|
e7476d8c9826db1cc775028573fc01ab3effa8fe
|
5271496fb820f8ab1d613a1c2355504251997fef
|
refs/heads/master
| 2021-01-10T19:17:01.479703 | 2011-12-19T14:32:51 | 2011-12-19T14:32:51 | 34,730,620 | 0 | 0 | null | null | null | null |
UTF-8
|
C++
| false | false | 24,075 |
cpp
|
#include <algorithm>
#include <vector>
#include <set>
#include <stack>
#include <utility>
#include <cassert>
template<size_t N>
struct log2_n
{
enum{value = 1 + log2_n< (N >> 1) >::value};
};
template<>
struct log2_n<1>
{
enum{value = 0};
};
template<>
struct log2_n<0>
{
enum{value = 0};
};
typedef int ConnectorType;
static const ConnectorType UnknownConnector = -1;
enum DirectionType{L=1, U = L << 1, R = U << 1, D = R << 1};
enum PathType {UnknownPath = 0,
PL=0x01,PR = PL << 1,PU = PR << 1,PD = PU << 1};
template<int X>
struct dir_to_path{
enum{value = X};
};
template<int X>
struct opposite_dir;
template<>
struct opposite_dir<L>{enum {value = R};};
template<>
struct opposite_dir<U>{enum {value = D};};
template<>
struct opposite_dir<R>{enum {value = L};};
template<>
struct opposite_dir<D>{enum {value = U};};
class Connector;
class Connector{
typedef std::vector<Connector*> element_array;
element_array connectors[4];//allowable neighbors
int key_;//identifier of this element
int path_;
private:
template<int N>
bool check_connection(const std::vector<Connector*>& v)const
{
if(( path_ & PL ) && (N & L))
{
for(size_t i = 0;i < v.size(); ++i)
{
if(!(v[i]->get_path_type() & PR))return false;
}
}
if(( path_ & PU ) && (N & U))
{
for(size_t i = 0;i < v.size(); ++i)
{
if(!(v[i]->get_path_type() & PD))return false;
}
}
if(( path_ & PR ) && (N & R))
{
for(size_t i = 0;i < v.size(); ++i)
{
if(!(v[i]->get_path_type() & PL))return false;
}
}
if(( path_ & PD ) && (N & D))
{
for(size_t i = 0;i < v.size(); ++i)
{
if(!(v[i]->get_path_type() & PU))return false;
}
}
return true;
}
public:
Connector(int key,int path):key_(key),path_(path){}
template<int N>
void set_connector_1d(const std::vector<Connector*>& v)
{
assert(N == L || N == U || N == R || N == D);//or static_assert
connectors[log2_n<N>::value] = v;
assert(check_connection<N>(v));
}
template<int N>
void add_connector_1d(Connector* v);
template<int N>
void add_connector_1d(const std::vector<Connector*>& v)
{
for(size_t i = 0;i < v.size(); ++i)
add_connector_1d<N>(v[i]);
}
template<int N>
const std::vector<Connector*>& get_connector_1d()const
{
assert(N == L || N == U || N == R || N == D);//or static_assert
return connectors[log2_n<N>::value];
}
ConnectorType get_key()const{return key_;};
int get_path_type()const{return path_;}
};
struct unary_equal_by_key{
typedef bool result_type;
const Connector* c;
unary_equal_by_key(const Connector* cc):c(cc){}
bool operator()(const Connector* x)const
{
return c->get_key() == x->get_key();
}
};
template<int N>
void Connector::add_connector_1d(Connector* v)
{
std::vector<Connector*>& a = connectors[log2_n<N>::value];
if(std::find_if(a.begin(),a.end(),unary_equal_by_key(v)) != a.end())
return;
assert(N == L || N == U || N == R || N == D);//or static_assert
connectors[log2_n<N>::value].push_back(v);
assert(check_connection<N>(connectors[log2_n<N>::value]));
v->add_connector_1d<opposite_dir<N>::value>(this);
}
struct equal_by_key{
typedef bool result_type;
result_type operator()(Connector* a, Connector* b)const
{
return a->get_key() == b->get_key();
}
};
template<int Dir>
std::vector<Connector*> filter_by_impl(const std::vector<Connector*>& cs)
{
if(Dir == 0) return cs;
std::vector<Connector*> ret;
for(std::vector<Connector*>::const_iterator it = cs.begin(); it != cs.end(); ++it)
{
if(! (*it)->get_connector_1d<Dir>().empty())
ret.push_back(*it);
}
return ret;
}
std::vector<Connector*> filter_by_key(int K, const std::vector<Connector*>& cs)
{
if(K == 0) return cs;
std::vector<Connector*> ret;
for(std::vector<Connector*>::const_iterator it = cs.begin(); it != cs.end(); ++it)
{
if((*it)->get_key() & K)
ret.push_back(*it);
}
return ret;
}
std::vector<Connector*> filter_by_not_key(int K, const std::vector<Connector*>& cs)
{
if(K == 0) return cs;
std::vector<Connector*> ret;
for(std::vector<Connector*>::const_iterator it = cs.begin(); it != cs.end(); ++it)
{
if(!((*it)->get_key() & K))
ret.push_back(*it);
}
return ret;
}
//filter_by_path< (~R & ~D) & (L | U)>
std::vector<Connector*> filter_by_path(int P, const std::vector<Connector*>& cs)
{
std::vector<Connector*> ret;
for(std::vector<Connector*>::const_iterator it = cs.begin(); it != cs.end(); ++it)
{
if (( ((*it)->get_path_type()) & P)) ret.push_back(*it);
}
return ret;
}
std::vector<Connector*> filter_by_path_strict(int P, const std::vector<Connector*>& cs)
{
std::vector<Connector*> ret;
for(std::vector<Connector*>::const_iterator it = cs.begin(); it != cs.end(); ++it)
{
if (( ((*it)->get_path_type()) & P) == (*it)->get_path_type()) ret.push_back(*it);
}
return ret;
}
static int match_call_count = 0;
template<int CT1, int CT0>
bool is_connector_match(const Connector* a, const Connector* b)
{
assert(CT0 == opposite_dir<CT1>::value);
match_call_count ++;
return std::find_if(a->get_connector_1d<CT0>().begin(),
a->get_connector_1d<CT0>().end(),unary_equal_by_key(b)) != a->get_connector_1d<CT0>().end()
&& std::find_if(b->get_connector_1d<CT1>().begin(),
b->get_connector_1d<CT1>().end(),unary_equal_by_key(a)) != b->get_connector_1d<CT1>().end();
}
std::vector<Connector*> intersect_filter(Connector* const lc,
Connector* const uc,
Connector* const rc,
Connector* const dc,
const std::vector<Connector*>& normal_connectors
)
{
//
std::vector<Connector*> ret;
for (size_t i = 0;i < normal_connectors.size(); i++)
{
if((!lc || lc->get_key() == UnknownConnector || is_connector_match<L,R>(lc,normal_connectors[i]))
&& (!uc || uc->get_key() == UnknownConnector || is_connector_match<U,D>(uc,normal_connectors[i]))
&& (!dc || dc->get_key() == UnknownConnector || is_connector_match<D,U>(dc,normal_connectors[i]))
&& (!rc || rc->get_key() == UnknownConnector || is_connector_match<R,L>(rc,normal_connectors[i])))
ret.push_back(normal_connectors[i]);
}
return ret;
}
typedef std::vector< std::vector<Connector* > > ConnectorMatrix;
bool is_connected(const ConnectorMatrix& m)
{
if(m.size() == 0 || m[0].size() == 0) return true;
typedef std::pair<size_t , size_t > coord2d_t;
std::stack<coord2d_t> connector_stack;
std::set<coord2d_t> visited;
coord2d_t coord(0,0);
connector_stack.push(coord);
while(!connector_stack.empty())
{
coord = connector_stack.top();
connector_stack.pop();
if(visited.find(coord) != visited.end())
continue;
visited.insert(coord);
Connector* t = m[coord.first][coord.second];
if (t -> get_path_type() & PL)
{
connector_stack.push(std::make_pair(coord.first, coord.second - 1));
}
if (t -> get_path_type() & PU)
{
connector_stack.push(std::make_pair(coord.first - 1, coord.second ));
}
if (t -> get_path_type() & PR)
{
connector_stack.push(std::make_pair(coord.first, coord.second + 1));
}
if (t -> get_path_type() & PD)
{
connector_stack.push(std::make_pair(coord.first + 1, coord.second ));
}
if (t -> get_path_type() == UnknownPath)
{
if( coord.first > 0 &&
((m[coord.first-1][coord.second]->get_path_type() & PD) ||
m[coord.first-1][coord.second]->get_path_type() == UnknownPath))
{
connector_stack.push(std::make_pair(coord.first - 1, coord.second ));
}
if( coord.first < m.size() - 1 &&
((m[coord.first+1][coord.second]->get_path_type() & PU) ||
m[coord.first+1][coord.second]->get_path_type() == UnknownPath
))
{
connector_stack.push(std::make_pair(coord.first + 1, coord.second ));
}
if( coord.second > 0 &&
((m[coord.first][coord.second-1]->get_path_type() & PR) ||
m[coord.first][coord.second-1]->get_path_type() == UnknownPath
))
{
connector_stack.push(std::make_pair(coord.first, coord.second - 1));
}
if( coord.second < m[coord.first].size()-1&&
((m[coord.first][coord.second+1]->get_path_type() & PL) ||
m[coord.first][coord.second+1]->get_path_type() == UnknownPath
))
{
connector_stack.push(std::make_pair(coord.first, coord.second + 1));
}
}
}
for(size_t i= 0 ;i < m.size(); ++i)
{
for (size_t j = 0; j < m[i].size(); ++j)
{
if(visited.find(std::make_pair(i,j)) == visited.end())
return false;
}
}
return true;
}
bool is_solution_matrix(const ConnectorMatrix& m)
{
for(size_t i= 0 ;i < m.size(); ++i)
{
for (size_t j = 0; j < m[i].size(); ++j)
{
if(m[i][j]->get_key() == UnknownConnector)
return false;
}
}
return is_connected(m);
}
ConnectorMatrix construct_matrix(size_t z, size_t x, const ConnectorMatrix& m, const std::vector<Connector*> normal_connectors)
{
if( !(z < m.size() && x < m[z].size()) ) return m;
size_t pt = PL | PU | PR | PD;
Connector *lc,*uc,*rc,*dc;
lc = uc = rc = dc = 0;
size_t next_x,next_z;
next_x = x;
next_z = z;
if( x == 0)
{
pt = pt & ~PL;
}
else{
lc = (m[z][x-1]);
}
if( z == 0)
{
pt = pt & ~PU;
}
else
{
uc = (m[z-1][x]);
}
if( z == m.size() - 1)
{
pt = pt & ~PD;
}
else dc = m[z+1][x];
next_x ++;
if ( x == m[z].size() -1)
{
pt = pt & ~PR;
next_z++;
next_x = 0;
}
else rc = m[z][x+1];
std::vector<Connector*> cs = filter_by_path_strict(pt, intersect_filter(lc,uc,rc,dc,normal_connectors));
//std::random_shuffle(cs.begin(),cs.end());
ConnectorMatrix cur = m;
//filter by neibor
for(size_t i = 0;i < cs.size();++i)
{
cur[z][x] = cs[i];
if(is_connected(cur))
{
ConnectorMatrix ret;
construct_matrix(next_z,next_x, cur, normal_connectors).swap(ret);
if(is_solution_matrix(ret))
return ret;
}
}
return m;
}
struct connector_matrix_state{
private:
ConnectorMatrix m;
size_t x,z;//2d coord visitor
Connector* unknown_connector;
//cache path type ?
int pt_prev;
int pt_cur;
public:
connector_matrix_state(const ConnectorMatrix& cm, Connector* u):m(cm),x(0),z(0),unknown_connector(u),pt_prev(-1),pt_cur(-1){}
void next(Connector* c){
assert(z < m.size() && x < m[z].size());
m[z][x] = c;
if ( x == m[z].size() -1)
{
z++;
x = 0;
}
else
x++;
}
void prev(){
assert(x > 0 || z > 0);
if(z < m.size() && x < m[z].size())
m[z][x] = unknown_connector;
if(x > 0) x--;
else
{
z--;
assert(!m[z].empty());
x = m[z].size() - 1;
}
}
const ConnectorMatrix& get_matrix()const{return m;}
size_t get_x()const{return x;}
size_t get_z()const{return z;}
};
namespace back_tracking{
inline bool try_next(connector_matrix_state& state, Connector* c)
{
size_t x = state.get_x();
size_t z = state.get_z();
ConnectorMatrix& m = const_cast<ConnectorMatrix&>(state.get_matrix());
if( !(z < m.size() && x < m[z].size()) ) return false;
Connector *lc,*uc,*rc,*dc;
lc = uc = rc = dc = 0;
int pt = PL | PU | PD | PR;
if( x == 0)
{
pt = pt & ~PL;
}
else{
lc = (m[z][x-1]);
}
if( z == 0)
{
pt = pt & ~PU;
}
else
{
uc = (m[z-1][x]);
}
if( z == m.size() - 1)
{
pt = pt & ~PD;
}
else dc = m[z+1][x];
if ( x == m[z].size() -1)
{
pt = pt & ~PR;
}
else rc = m[z][x+1];
if ((c->get_path_type() & pt) != c->get_path_type())
{
return false;
}
if((!lc || lc->get_key() == UnknownConnector || is_connector_match<L,R>(lc,c))
&& (!uc || uc->get_key() == UnknownConnector || is_connector_match<U,D>(uc,c))
&& (!dc || dc->get_key() == UnknownConnector || is_connector_match<D,U>(dc,c))
&& (!rc || rc->get_key() == UnknownConnector || is_connector_match<R,L>(rc,c)))
{
//test connectivity
state.next(c);
if (is_connected(m))
{
return true;
}
state.prev();
}
return false;
}
inline void predecessor_action(connector_matrix_state& state)
{
state.prev();
}
inline bool is_solution(const connector_matrix_state& state)
{
return is_solution_matrix(state.get_matrix());
}
}
namespace back_tracking{
struct no_shuffle{
template<typename I>
void operator()(I , I )const
{}
};
struct default_shuffle{
template<typename I>
void operator()(I f, I l)const
{
// std::random_shuffle(f,l);
}
};
struct default_next{
template<typename I>
I operator()(I f) const
{
return ++f;
}
};
template<typename R, typename TI, typename N>
inline void back_tracking_step(R& state, TI& f, TI tf, TI tl, std::stack<TI>& s,const N& next)
{
if (try_next(state, *f))
{
s.push(next(f));//store next start pos
f = tf;
return;
}
++f;
while (!s.empty() && f == tl)
{
f = s.top();
s.pop();
predecessor_action(state);
}
}
template<typename R, typename TI, typename N>
bool back_tracking_iterate(R& state, TI tf, TI tl,const N& next)
{
TI f = tf;
std::stack<TI> s;
while(f != tl)
{
back_tracking_step(state, f, tf, tl, s, next);
if (f == tf && is_solution(state)) return true;
}
return false;
}
//EOP:this is an action that will change the input value
//bidirectional state required(reversable)
template<typename R,typename TI, typename N>
bool back_tracking_recursive(R& state,TI tf, TI tl,const N& next)
{
if(is_solution(state)) return true;
TI f = tf;
while(f != tl )
{
if( try_next(state, *f))
{
if(back_tracking_recursive(state,tf,tl,next))
return true;
predecessor_action(state);
}
f = next(f);
}
return false;//empty result
}
//this is an action change the input value
template<typename R,typename TI>
inline bool back_tracking_recursive(R& state,TI tf, TI tl)
{
return back_tracking_recursive(state, tf, tl, default_next());
}
}
struct bt_rec{
ConnectorMatrix operator()(ConnectorMatrix& m, Connector* u,std::vector<Connector*>& input_connectors)const{
connector_matrix_state s(m,u);
back_tracking::back_tracking_recursive(s, input_connectors.begin(), input_connectors.end(),back_tracking::default_next());
return s.get_matrix();
}
};
struct bt_iter{
ConnectorMatrix operator()(ConnectorMatrix& m, Connector* u,std::vector<Connector*>& input_connectors)const{
connector_matrix_state s(m,u);
back_tracking::back_tracking_iterate(s, input_connectors.begin(), input_connectors.end(),back_tracking::default_next());
return s.get_matrix();
}
};
struct cons_m{
ConnectorMatrix operator()(ConnectorMatrix& m, Connector* ,std::vector<Connector*>& input_connectors)const{
return construct_matrix(0, 0, m, input_connectors);
}
};
template<typename TF>
ConnectorMatrix test(int width,int height, int seed, const std::vector<Connector*>& normal_connectors,TF tf)
{
std::vector<Connector*> input_connectors = normal_connectors;
srand(seed);
std::random_shuffle(input_connectors.begin(), input_connectors.end());
Connector* unknown = new Connector(UnknownConnector, UnknownPath);
unknown->set_connector_1d<L>(normal_connectors);
unknown->set_connector_1d<U>(normal_connectors);
unknown->set_connector_1d<R>(normal_connectors);
unknown->set_connector_1d<D>(normal_connectors);
std::vector<Connector*> row(width, unknown);
ConnectorMatrix inited_matrix(height,row);
return tf(inited_matrix,unknown,input_connectors);
}
//left,right,up,down
enum TestConnectorType{
TUnknownConnector=0x0,
TL=0x01,TR = TL << 1,TU = TR << 1,TD = TU << 1,
TUR = TU | TR, TRD = TR | TD, TDL = TD|TL, TLU = TL|TU , TLR = TL|TR, TUD = TU|TD,
TLUR = TL|TUR,TDLU = TD|TLU ,TRDL = TR|TDL,TURD=TU|TRD,
TLURD = TLUR | TD
};
//for print
static const char* TestConnectTypeStr[] =
{
"UnknownOrCount",
"L ",//01
"R ",//02
"LR ",//03
"U ",//04
"LU ",//05
"UR ",//06
"LUR ",//07
"D ",//08
"DL ",//09
"RD ",//10
"RDL ",//11
"UD ",//12
"DLU ",//13
"URD ",//14
"LURD ",//15
};
std::vector<Connector*> init_connectors()
{
std::vector<Connector*> ret;
//Connector* l = new Connector(TL,PL);ret.push_back(l);
//Connector* r = new Connector(TR,PR);ret.push_back(r);
Connector* lr = new Connector(TLR,PL|PR);ret.push_back(lr);
//Connector* u = new Connector(TU,PU);ret.push_back(u);
Connector* lu = new Connector(TLU, PL|PU);ret.push_back(lu);
Connector* ur = new Connector(TUR, PR|PU);ret.push_back(ur);
Connector* lur = new Connector(TLUR, PL|PU|PR);ret.push_back(lur);
//Connector* d = new Connector(TD, PD);ret.push_back(d);
Connector* dl = new Connector(TDL, PD|PL);ret.push_back(dl);
Connector* rd = new Connector(TRD, PR|PD);ret.push_back(rd);
Connector* rdl = new Connector(TRDL, PR|PD|PL);ret.push_back(rdl);
Connector* ud = new Connector(TUD, PU|PD);ret.push_back(ud);
Connector* dlu = new Connector(TDLU, PD|PL|PU);ret.push_back(dlu);
Connector* urd = new Connector(TURD, PU|PR|PD);ret.push_back(urd);
//Connector* lurd = new Connector(TLURD, PL|PU|PR|PD);ret.push_back(lurd);
std::vector<Connector*> ls,nls,us,nus,rs,nrs,ds,nds;
ls = filter_by_key(TL,ret);nls = filter_by_not_key(TL,ret);
us = filter_by_key(TU,ret);nus = filter_by_not_key(TU,ret);
rs = filter_by_key(TR,ret);nrs = filter_by_not_key(TR,ret);
ds = filter_by_key(TD,ret);nds = filter_by_not_key(TD,ret);
/*
l->add_connector_1d<L>(rs);
l->add_connector_1d<U>(nds);
l->add_connector_1d<R>(nls);
l->add_connector_1d<D>(nus);
u->add_connector_1d<L>(nrs);
u->add_connector_1d<U>(ds);
u->add_connector_1d<R>(nls);
u->add_connector_1d<D>(nus);
r->add_connector_1d<L>(nrs);
r->add_connector_1d<U>(nds);
r->add_connector_1d<R>(ls);
r->add_connector_1d<D>(nus);
d->add_connector_1d<L>(nrs);
d->add_connector_1d<U>(nds);
d->add_connector_1d<R>(nls);
d->add_connector_1d<D>(us);
assert((!is_connector_match<L,R>(r,d)));
*/
lr->add_connector_1d<L>(rs);
lr->add_connector_1d<U>(nds);
lr->add_connector_1d<R>(ls);
lr->add_connector_1d<D>(nus);
lu->add_connector_1d<L>(rs);
lu->add_connector_1d<U>(ds);
lu->add_connector_1d<R>(nls);
lu->add_connector_1d<D>(nus);
dl->add_connector_1d<L>(rs);
dl->add_connector_1d<U>(nds);
dl->add_connector_1d<R>(nls);
dl->add_connector_1d<D>(us);
ur->add_connector_1d<L>(nrs);
ur->add_connector_1d<U>(ds);
ur->add_connector_1d<R>(ls);
ur->add_connector_1d<D>(nus);
rd->add_connector_1d<L>(nrs);
rd->add_connector_1d<U>(nds);
rd->add_connector_1d<R>(ls);
rd->add_connector_1d<D>(us);
ud->add_connector_1d<L>(nrs);
ud->add_connector_1d<U>(ds);
ud->add_connector_1d<R>(nls);
ud->add_connector_1d<D>(us);
lur->add_connector_1d<L>(rs);
lur->add_connector_1d<U>(ds);
lur->add_connector_1d<R>(ls);
lur->add_connector_1d<D>(nus);
rdl->add_connector_1d<L>(rs);
rdl->add_connector_1d<U>(nds);
rdl->add_connector_1d<R>(ls);
rdl->add_connector_1d<D>(us);
dlu->add_connector_1d<L>(rs);
dlu->add_connector_1d<U>(ds);
dlu->add_connector_1d<R>(nls);
dlu->add_connector_1d<D>(us);
urd->add_connector_1d<L>(nrs);
urd->add_connector_1d<U>(ds);
urd->add_connector_1d<R>(ls);
urd->add_connector_1d<D>(us);
// lurd->add_connector_1d<L>(rs);
// lurd->add_connector_1d<U>(ds);
// lurd->add_connector_1d<R>(ls);
// lurd->add_connector_1d<D>(us);
return ret;
}
#include <iostream>
#include <cstdlib>
#include <cstdio>
void output_matrix(const ConnectorMatrix& m)
{
for(size_t z = 0; z < m.size(); ++z)
{
for(size_t x = 0; x < m[z].size(); ++x)
{
printf("%s",TestConnectTypeStr[m[z][x]->get_key()]);
}
printf("\n");
}
printf("\n");
}
template<typename TF>
void test_case()
{
std::vector<Connector*> cs = init_connectors();
for(int i = 2;i < 13; ++i)
for(int j = 2;j < 13; ++j)
{
ConnectorMatrix m = test<TF>(i,j,i*20 + j,cs,TF());
if(!is_solution_matrix(m))
{ //output
//output_matrix(m);
throw "no solution found!";
}
else{
// output_matrix(m);
}
}
}
#include <ctime>
int main()
{
clock_t t0 = clock();
test_case<bt_rec>();
printf("bt_rec: %ld match_calls: %d \n",long(clock() - t0),match_call_count);
match_call_count = 0;
t0 = clock();
test_case<bt_iter>();
printf("bt_iter: %ld match_calls: %d \n",long(clock() - t0),match_call_count );
match_call_count = 0;
t0 = clock();
test_case<cons_m>();
printf("cons_m: %ld match_calls: %d \n",long(clock() - t0),match_call_count);
return 0;
}
|
[
"luozhiyuan@ea6f400c-e855-0410-84ee-31f796524d81"
] |
[
[
[
1,
782
]
]
] |
06aaf4ec9ee2f0ab529ad9ad5c372ba48a630b77
|
55196303f36aa20da255031a8f115b6af83e7d11
|
/private/tools/editor/OutputWnd.h
|
830dd9591fa27cf10ffd80320170175f72bd516f
|
[] |
no_license
|
Heartbroken/bikini
|
3f5447647d39587ffe15a7ae5badab3300d2a2ff
|
fe74f51a3a5d281c671d303632ff38be84d23dd7
|
refs/heads/master
| 2021-01-10T19:48:40.851837 | 2010-05-25T19:58:52 | 2010-05-25T19:58:52 | 37,190,932 | 0 | 0 | null | null | null | null |
UTF-8
|
C++
| false | false | 1,616 |
h
|
#pragma once
/////////////////////////////////////////////////////////////////////////////
// COutputList window
class COutputList : public CListBox
{
// Construction
public:
COutputList();
// Implementation
public:
virtual ~COutputList();
protected:
afx_msg void OnContextMenu(CWnd* pWnd, CPoint point);
afx_msg void OnEditCopy();
afx_msg void OnEditClear();
afx_msg void OnViewOutput();
DECLARE_MESSAGE_MAP()
};
// --------------------------------------
class COutputEdit : public CEdit
{
// Construction
public:
COutputEdit();
// Implementation
public:
virtual ~COutputEdit();
protected:
afx_msg void OnContextMenu(CWnd* pWnd, CPoint point);
afx_msg void OnEditCopy();
afx_msg void OnEditClear();
afx_msg void OnViewOutput();
DECLARE_MESSAGE_MAP()
};
// --------------------------------------
class COutputWnd : public CDockablePane
{
// Construction
public:
COutputWnd();
// Attributes
protected:
CFont m_Font;
//COutputEdit m_wndOutput;
COutputList m_wndOutput;
//CMFCTabCtrl m_wndTabs;
//COutputList m_wndOutputBuild;
//COutputList m_wndOutputDebug;
//COutputList m_wndOutputFind;
protected:
void FillOutput();
//void FillBuildWindow();
//void FillDebugWindow();
//void FillFindWindow();
void AdjustHorzScroll(CListBox& wndListBox);
// Implementation
public:
virtual ~COutputWnd();
void output_string(const bk::wstring &_string);
protected:
afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
afx_msg void OnSize(UINT nType, int cx, int cy);
DECLARE_MESSAGE_MAP()
};
|
[
"[email protected]",
"viktor.reutskyy@68c2588f-494f-0410-aecb-65da31d84587"
] |
[
[
[
1,
56
],
[
59,
78
],
[
81,
87
]
],
[
[
57,
58
],
[
79,
80
]
]
] |
340b1c004f5cd432920414d33b6eff7573818780
|
96e96a73920734376fd5c90eb8979509a2da25c0
|
/C3DE/Tree2.h
|
e331efdbf4f6a6a807be0be963d4037fb8880300
|
[] |
no_license
|
lianlab/c3de
|
9be416cfbf44f106e2393f60a32c1bcd22aa852d
|
a2a6625549552806562901a9fdc083c2cacc19de
|
refs/heads/master
| 2020-04-29T18:07:16.973449 | 2009-11-15T10:49:36 | 2009-11-15T10:49:36 | 32,124,547 | 0 | 0 | null | null | null | null |
UTF-8
|
C++
| false | false | 348 |
h
|
#ifndef TREE2_H
#define TREE2_H
#include "D3DMesh.h"
class Tree2 : public D3DMesh
{
public:
Tree2();
~Tree2();
void SetShaderHandlers();
void PreRender(Renderer * a_renderer);
void PosRender(Renderer * a_renderer);
protected:
D3DXHANDLE m_hTex;
D3DXHANDLE m_shaderAlpha;//galpha
};
#endif
|
[
"caiocsabino@7e2be596-0d54-0410-9f9d-cf4183935158"
] |
[
[
[
1,
31
]
]
] |
899b4fec731bf92dd03380a489f0c5c847c4274b
|
ea613c6a4d531be9b5d41ced98df1a91320c59cc
|
/SQLCEHelper/Source/DbPropSet.cpp
|
7f2525667e80f4d828d65c15fc39fc41a83c7471
|
[] |
no_license
|
f059074251/interested
|
939f938109853da83741ee03aca161bfa9ce0976
|
b5a26ad732f8ffdca64cbbadf9625dd35c9cdcb2
|
refs/heads/master
| 2021-01-15T14:49:45.217066 | 2010-09-16T10:42:30 | 2010-09-16T10:42:30 | 34,316,088 | 1 | 0 | null | null | null | null |
UTF-8
|
C++
| false | false | 1,749 |
cpp
|
#include "stdafx.h"
using namespace OLEDBCLI;
CDbPropSet::CDbPropSet(GUID guid)
{
guidPropertySet = guid;
cProperties = 0;
rgProperties = NULL;
}
CDbPropSet::~CDbPropSet()
{
Clear();
}
void CDbPropSet::Clear()
{
ULONG i;
for(i = 0; i < cProperties; ++i)
VariantClear(&rgProperties[i].vValue);
cProperties = 0;
CoTaskMemFree(rgProperties);
rgProperties = NULL;
}
bool CDbPropSet::AddProperty(const CDbProp &prop)
{
DBPROP* pProps = (DBPROP*)CoTaskMemRealloc(rgProperties, (cProperties + 1) * sizeof(DBPROP));
if(pProps != NULL)
{
prop.CopyTo(pProps + cProperties);
rgProperties = pProps;
++cProperties;
return true;
}
return false;
}
bool CDbPropSet::AddProperty(DBPROPID id, int propVal)
{
CDbProp prop;
prop.dwPropertyID = id;
prop.dwOptions = DBPROPOPTIONS_REQUIRED;
prop.dwStatus = DBPROPSTATUS_OK;
prop.colid = DB_NULLID;
prop.vValue.vt = VT_I4;
prop.vValue.intVal = propVal;
return AddProperty(prop);
}
bool CDbPropSet::AddProperty(DBPROPID id, bool propVal)
{
CDbProp prop;
prop.dwPropertyID = id;
prop.dwOptions = DBPROPOPTIONS_REQUIRED;
prop.dwStatus = DBPROPSTATUS_OK;
prop.colid = DB_NULLID;
prop.vValue.vt = VT_BOOL;
prop.vValue.boolVal = propVal ? VARIANT_TRUE : VARIANT_FALSE;
return AddProperty(prop);
}
bool CDbPropSet::AddProperty(DBPROPID id, LPCTSTR propVal)
{
CDbProp prop;
prop.dwPropertyID = id;
prop.dwOptions = DBPROPOPTIONS_REQUIRED;
prop.dwStatus = DBPROPSTATUS_OK;
prop.colid = DB_NULLID;
prop.vValue.vt = VT_BSTR;
prop.vValue.bstrVal = SysAllocString(propVal);
if(prop.vValue.bstrVal == NULL)
return false;
return AddProperty(prop);
}
|
[
"[email protected]@8d1da77e-e9f6-11de-9c2a-cb0f5ba72f9d"
] |
[
[
[
1,
94
]
]
] |
c1e62e715fba2f235a81f983c086dd2b11fc14a5
|
ef25bd96604141839b178a2db2c008c7da20c535
|
/src/src/Engine/Core/Time.h
|
977936f6f97b96196d4821c188a92c6e9545d5e9
|
[] |
no_license
|
OtterOrder/crock-rising
|
fddd471971477c397e783dc6dd1a81efb5dc852c
|
543dc542bb313e1f5e34866bd58985775acf375a
|
refs/heads/master
| 2020-12-24T14:57:06.743092 | 2009-07-15T17:15:24 | 2009-07-15T17:15:24 | 32,115,272 | 0 | 0 | null | null | null | null |
ISO-8859-1
|
C++
| false | false | 1,180 |
h
|
#ifndef _TIME_H_
#define _TIME_H_
//******************************************************************
#ifndef NOMINMAX
#define NOMINMAX
#endif
#include <windows.h>
//******************************************************************
class Time
{
public:
Time();
~Time();
// =========================================================
// Méthodes publiques
inline float GetDeltaTime() { return m_DeltaTime; } // Temps écoulé depuis le dernier tour moteur (s)
inline float GetDeltaTimeF() { return m_DeltaTimeF; } // Temps écoulé depuis la dernière frame (s)
float GetTime(); // Temps depuis la création du System (s)
float GetDeltaTimeMs();
float GetDeltaTimeFMs();
float GetTimeMs();
void EndE(); // Fin d'un tour moteur (System)
void EndF(); // Fin d'une frame (System)
protected:
// =========================================================
// Données protégées
float m_Freq;
LARGE_INTEGER m_TimeStart;
LARGE_INTEGER m_StartDeltaTime;
float m_DeltaTime;
float m_DeltaTimeF;
};
//******************************************************************
#endif // _TIME_H_
|
[
"mathieu.chabanon@7c6770cc-a6a4-11dd-91bf-632da8b6e10b"
] |
[
[
[
1,
49
]
]
] |
8f3051fd773b453c673d968f1f9629135013bee9
|
aad1b23210f64324190a93d998a13f9e42f27fbc
|
/Visualizers/TicTacToe/TicTacToe/Game.h
|
de7ede9cf77f29e87d479e6bf7cc5c752546c1ab
|
[] |
no_license
|
abreslav-from-google-code/abreslav
|
9272ecdd8d3abf1d541d8f85fad8756184d1c2db
|
2d0882e29de0833097bf604ece541b9258ed296f
|
refs/heads/master
| 2016-09-05T15:15:50.343707 | 2010-11-18T22:26:53 | 2010-11-18T22:26:53 | null | 0 | 0 | null | null | null | null |
UTF-8
|
C++
| false | false | 993 |
h
|
#pragma once
#pragma once
#include <exception>
#include "Observable.h"
#define H_CELLS 30
#define V_CELLS (H_CELLS + 5)
class FieldIndexOutOfBounds : public std::exception
{
virtual const char* what() const throw()
{
return "Field index out of bounds";
}
};
#define THROW(a)
class Game : public Observable
{
public:
typedef enum
{
EMPTY,
CROSS,
CIRCLE
} CellState;
typedef enum
{
PLAY = 0,
CROSS_WON = 1,
CIRCLE_WON = 2,
CROSS_ERROR = 3,
CIRCLE_ERROR = 4
} Status;
Game()
: status(PLAY)
{
clearField();
}
void clearField();
void setCellState(int x, int y, CellState value);
Status getStatus() const;
CellState getCellState(int x, int y) const THROW(FieldIndexOutOfBounds);
void playerSurrendered(CellState s);
private:
Status checkStatus(int xx, int yy);
Status checkLine(int x0, int y0, int dx, int dy);
CellState field[H_CELLS][V_CELLS];
Status status;
Status surrenderStatus;
};
|
[
"abreslav@f8d81c2c-b11e-0410-9df4-1f401b7bbd07"
] |
[
[
[
1,
58
]
]
] |
d3f6e4079cd208c94bd6b7dfcaa7acddda240170
|
e7c45d18fa1e4285e5227e5984e07c47f8867d1d
|
/Common/Com/ScdMdl/ScdMdl.cpp
|
ad26e30d671ddd9b3567131221610bfc6209db61
|
[] |
no_license
|
abcweizhuo/Test3
|
0f3379e528a543c0d43aad09489b2444a2e0f86d
|
128a4edcf9a93d36a45e5585b70dee75e4502db4
|
refs/heads/master
| 2021-01-17T01:59:39.357645 | 2008-08-20T00:00:29 | 2008-08-20T00:00:29 | null | 0 | 0 | null | null | null | null |
UTF-8
|
C++
| false | false | 4,411 |
cpp
|
// ScdMdl.cpp : Implementation of DLL Exports.
// Note: Proxy/Stub Information
// To build a separate proxy/stub DLL,
// run nmake -f ScdMdlps.mk in the project directory.
#include "stdafx.h"
#include "resource.h"
#include <initguid.h>
#define __SCDMDL_CPP
#include "ScdMdl.h"
#include "ScdMdl_i.c"
//#include "ScdSpModel.h"
//#include "ScdSpecieDB.h"
#include "ScdLicenseMdl.h"
//#include "ScdSpecieDefn.h"
#include "ScdSpecieDefns.h"
#include "ScdSpecieDefn.h"
//#include "ScdSpVectorDefn.h"
CComModule _Module;
BEGIN_OBJECT_MAP(ObjectMap)
//OBJECT_ENTRY(CLSID_ScdSpModel, CScdSpModel)
//OBJECT_ENTRY(CLSID_ScdSpecieDB, CScdSpecieDB)
OBJECT_ENTRY(CLSID_ScdLicenseMdl, CScdLicenseMdl)
//OBJECT_ENTRY(CLSID_ScdSpecieDefn, CScdSpecieDefn)
OBJECT_ENTRY(CLSID_ScdSpecieDefns, CScdSpecieDefns)
OBJECT_ENTRY(CLSID_ScdSpecieDefn, CScdSpecieDefn)
//OBJECT_ENTRY(CLSID_ScdSpVectorDefn, CScdSpVectorDefn)
END_OBJECT_MAP()
class CScdMdlApp : public CWinApp
{
public:
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CScdMdlApp)
public:
virtual BOOL InitInstance();
virtual int ExitInstance();
//}}AFX_VIRTUAL
//{{AFX_MSG(CScdMdlApp)
// NOTE - the ClassWizard will add and remove member functions here.
// DO NOT EDIT what you see in these blocks of generated code !
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
BEGIN_MESSAGE_MAP(CScdMdlApp, CWinApp)
//{{AFX_MSG_MAP(CScdMdlApp)
// NOTE - the ClassWizard will add and remove mapping macros here.
// DO NOT EDIT what you see in these blocks of generated code!
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
CScdMdlApp theApp;
BOOL CScdMdlApp::InitInstance()
{
_Module.Init(ObjectMap, m_hInstance, &LIBID_ScdMdl);
return CWinApp::InitInstance();
}
int CScdMdlApp::ExitInstance()
{
TRACE0("ScdMdl : ExitInstance\n");
_Module.Term();
return CWinApp::ExitInstance();
}
/////////////////////////////////////////////////////////////////////////////
// Used to determine whether the DLL can be unloaded by OLE
STDAPI DllCanUnloadNow(void)
{
AFX_MANAGE_STATE(AfxGetStaticModuleState());
TRACE0("ScdMdl : Calling AfxDllCanUnloadNow\n");
return (AfxDllCanUnloadNow()==S_OK && _Module.GetLockCount()==0) ? S_OK : S_FALSE;
}
/////////////////////////////////////////////////////////////////////////////
// Returns a class factory to create an object of the requested type
STDAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID* ppv)
{
return _Module.GetClassObject(rclsid, riid, ppv);
}
/////////////////////////////////////////////////////////////////////////////
// DllRegisterServer - Adds entries to the system registry
STDAPI DllRegisterServer(void)
{
// registers object, typelib and all interfaces in typelib
return _Module.RegisterServer(TRUE);
}
/////////////////////////////////////////////////////////////////////////////
// DllUnregisterServer - Removes entries from the system registry
STDAPI DllUnregisterServer(void)
{
return _Module.UnregisterServer(TRUE);
}
//===========================================================================
//
//
//
//===========================================================================
#define DLLEXPORT __declspec(dllexport)
//---------------------------------------------------------------------------
extern "C" DLLEXPORT BOOL IsFlowLibDLL()
{
return TRUE;
}
//---------------------------------------------------------------------------
extern "C" DLLEXPORT BOOL GetDLLInfo(MDLLInfo* pDLLInfo)
{
pDLLInfo->iPriority = 5;
pDLLInfo->sName = "ScdMdl";
return TRUE;
}
//---------------------------------------------------------------------------
extern "C" DLLEXPORT CMdlCfgBase* GetCfgPropPg(int iPage, CMdlCfgSheet * pSheet)
{
return NULL;
};
//===========================================================================
//
//
//
//===========================================================================
void ForceLoad_ScdMdl()
{
// Dummy Function to allow other libraries to force load this one
}
//===========================================================================
//
//
//
//===========================================================================
//#include "ScdMessages.h"
|
[
"[email protected]"
] |
[
[
[
1,
159
]
]
] |
72b56eab13b4c3e03d4898d9732fef0235003712
|
6ee200c9dba87a5d622c2bd525b50680e92b8dab
|
/Walkyrie Dx9/Valkyrie/Moteur/EnvCollision.cpp
|
db150d7fe4dcb55be19bf1e14ea471bdeeaffabd
|
[] |
no_license
|
Ishoa/bizon
|
4dbcbbe94d1b380f213115251e1caac5e3139f4d
|
d7820563ab6831d19e973a9ded259d9649e20e27
|
refs/heads/master
| 2016-09-05T11:44:00.831438 | 2010-03-10T23:14:22 | 2010-03-10T23:14:22 | 32,632,823 | 0 | 0 | null | null | null | null |
ISO-8859-1
|
C++
| false | false | 13,062 |
cpp
|
#include "EnvCollision.h"
CEnvCollision::CEnvCollision()
{
m_nNbCollision = 0;
for(int i = 0;i < MAXOBJET;i++)
{
m_pTabCollision[i].m_pObjetDeCollision = NULL;
m_pTabCollision[i].m_nIdObjet = -1;
}
}
CEnvCollision::~CEnvCollision()
{
}
void CEnvCollision::Release()
{
for(int i = 0;i < MAXOBJET;i++)
{
m_pTabCollision[i].m_pObjetDeCollision = NULL;
m_pTabCollision[i].m_nIdObjet = -1;
}
m_nNbCollision = 0;
}
bool CEnvCollision::AddObjetDeCollision(CObjetDeCollision* ObjetDeCollision,CTypeDeCheckCollision eTypeCollision,float fAvatarHeight,CCalculsCollisions::eCollisionType eCollisionType)
{
if(m_nNbCollision > MAXOBJET)
return false;
m_pTabCollision[m_nNbCollision].m_eTypeCheckDeCollision = eTypeCollision;
m_pTabCollision[m_nNbCollision].m_nIdObjet = m_nNbCollision;
m_pTabCollision[m_nNbCollision].m_pObjetDeCollision = ObjetDeCollision;
m_pTabCollision[m_nNbCollision].m_eCollisionType = eCollisionType;
m_pTabCollision[m_nNbCollision].m_fAvatarHeight = fAvatarHeight;
m_nNbCollision++;
return true;
}
D3DXVECTOR3 CEnvCollision::CheckNextPosition( D3DXVECTOR3 CurrentPosition,D3DXVECTOR3 NextPosition)
{
unsigned int indiceCollision = -1;
// Sinon, il faut tester s'il y a eu une collision.
bool MultipleCollisions = false;
D3DXPLANE SlidingPlane;
D3DXPLANE CollisionPlane;
for ( int i = 0; i < m_nNbCollision; i++ )
{
if(m_pTabCollision[i].m_eCollisionType != CCalculsCollisions::NO_COLLISION)
{
switch(m_pTabCollision[i].m_eTypeCheckDeCollision)
{
case LIST_POLYGON :
{
// On obtient le pointeur sur la liste de polygones de l'objet.
CPolygonContainer* CurrentPolygon =
m_pTabCollision[i].m_pObjetDeCollision->GetPolygonList()->GetFirst();
// On recherche une collision dans toute la liste de polygones.
while ( CurrentPolygon != NULL )
{
// On obtient le polygone courant, et on lui applique une
// transformation pour le placer dans le bon système d'axes.
// Une meilleure méthode serait de convertir uniquement la
// position à tester dans le système d'axes du polygone, en
// appliquant l'inverse de la matrice du polygone sur la
// position, afin d'économiser quelques calculs. Mais parce-
// qu'on devra utiliser le plan du polygone pour le Sliding,
// plus tard, il vaut mieux pour notre cas convertir les
// coordonnées du polygone, et obtenir directement le bon plan.
CPolygon TestPolygon =
CurrentPolygon->GetPolygon()->ApplyMatrix
( m_pTabCollision[i].m_pObjetDeCollision->GetWorldMatrix() );
// On teste ensuite si l'avatar est en collision avec le
// polygone. Au passage, on récupère le plan de collision,
// si celui-ci existe. Remarquez que la position à tester est
// inversée, afin de travailler avec le bon système d'axes.
if ( CCalculsCollisions::
Check( NextPosition,
m_pTabCollision[i].m_fAvatarHeight,
TestPolygon,
&SlidingPlane ) == true )
{
//Console<<"Collision"<<i<<endl;
// Si une collision a déjà eu lieu, et si le plan trouvé
// n'est pas identique au plan de la collision précédente,
// ni à l'inverse du plan de la collision précédente,
// alors on indique que le joueur est en collision avec
// plusieurs murs.
if ( ( SlidingPlane.a != CollisionPlane.a ||
SlidingPlane.b != CollisionPlane.b ||
SlidingPlane.c != CollisionPlane.c ||
SlidingPlane.d != CollisionPlane.d ) &&
( SlidingPlane.a != -CollisionPlane.a ||
SlidingPlane.b != -CollisionPlane.b ||
SlidingPlane.c != -CollisionPlane.c ||
SlidingPlane.d != -CollisionPlane.d ) &&
indiceCollision != -1 )
{
MultipleCollisions = true;
//Console<<"COllision Multiple"<<endl;
}
// On copie le plan de collision.
CollisionPlane = SlidingPlane;
// Puis, on indique qu'une collision a eu lieu.
indiceCollision = i;
}
// On passe au polygone suivant, pour parcourir toute la liste.
CurrentPolygon = CurrentPolygon->GetNext();
}
}
break;
case LIST_POLYGON_LOW_DETAIL :
{
if(m_pTabCollision[i].m_pObjetDeCollision->GetPolygonListLowDetail() != NULL)
{
// On obtient le pointeur sur la liste de polygones de l'objet.
CPolygonContainer* CurrentPolygon =
m_pTabCollision[i].m_pObjetDeCollision->GetPolygonListLowDetail()->GetFirst();
// On recherche une collision dans toute la liste de polygones.
while ( CurrentPolygon != NULL )
{
// On obtient le polygone courant, et on lui applique une
// transformation pour le placer dans le bon système d'axes.
// Une meilleure méthode serait de convertir uniquement la
// position à tester dans le système d'axes du polygone, en
// appliquant l'inverse de la matrice du polygone sur la
// position, afin d'économiser quelques calculs. Mais parce-
// qu'on devra utiliser le plan du polygone pour le Sliding,
// plus tard, il vaut mieux pour notre cas convertir les
// coordonnées du polygone, et obtenir directement le bon plan.
CPolygon TestPolygon =
CurrentPolygon->GetPolygon()->ApplyMatrix
( m_pTabCollision[i].m_pObjetDeCollision->GetWorldMatrix() );
// On teste ensuite si l'avatar est en collision avec le
// polygone. Au passage, on récupère le plan de collision,
// si celui-ci existe. Remarquez que la position à tester est
// inversée, afin de travailler avec le bon système d'axes.
if ( CCalculsCollisions::
Check( NextPosition,
m_pTabCollision[i].m_fAvatarHeight,
TestPolygon,
&SlidingPlane ) == true )
{
//Console<<"Collision"<<i<<endl;
// Si une collision a déjà eu lieu, et si le plan trouvé
// n'est pas identique au plan de la collision précédente,
// ni à l'inverse du plan de la collision précédente,
// alors on indique que le joueur est en collision avec
// plusieurs murs.
if ( ( SlidingPlane.a != CollisionPlane.a ||
SlidingPlane.b != CollisionPlane.b ||
SlidingPlane.c != CollisionPlane.c ||
SlidingPlane.d != CollisionPlane.d ) &&
( SlidingPlane.a != -CollisionPlane.a ||
SlidingPlane.b != -CollisionPlane.b ||
SlidingPlane.c != -CollisionPlane.c ||
SlidingPlane.d != -CollisionPlane.d ) &&
indiceCollision != -1 )
{
MultipleCollisions = true;
//Console<<"COllision Multiple"<<endl;
}
// On copie le plan de collision.
CollisionPlane = SlidingPlane;
// Puis, on indique qu'une collision a eu lieu.
indiceCollision = i;
}
// On passe au polygone suivant, pour parcourir toute la liste.
CurrentPolygon = CurrentPolygon->GetNext();
}
}
else
indiceCollision = -1;
}
break;
case BOUNDING_BOX :
{
// On obtient le pointeur sur la liste de polygones de l'objet.
CPolygonContainer* CurrentPolygon =
m_pTabCollision[i].m_pObjetDeCollision->GetPolygonList()->GetFirstBox();
// On recherche une collision dans toute la liste de polygones.
while ( CurrentPolygon != NULL )
{
// On obtient le polygone courant, et on lui applique une
// transformation pour le placer dans le bon système d'axes.
// Une meilleure méthode serait de convertir uniquement la
// position à tester dans le système d'axes du polygone, en
// appliquant l'inverse de la matrice du polygone sur la
// position, afin d'économiser quelques calculs. Mais parce-
// qu'on devra utiliser le plan du polygone pour le Sliding,
// plus tard, il vaut mieux pour notre cas convertir les
// coordonnées du polygone, et obtenir directement le bon plan.
D3DXMATRIXA16 matrix = m_pTabCollision[i].m_pObjetDeCollision->GetWorldMatrix();
D3DXMATRIXA16 matrixInverse;
float det=D3DXMatrixDeterminant(&matrix);
D3DXMatrixInverse(&matrixInverse,&det,&matrix);
CPolygon* pTestPolygon = CurrentPolygon->GetPolygon();//->ApplyMatrix( m_pTabCollision[i].m_pObjetDeCollision->GetWorldMatrix() );
CPolygon TestPolygon = *pTestPolygon;
D3DXVECTOR3 NextPositionInverse;
D3DXVec3TransformCoord(&NextPositionInverse,&NextPosition,&matrixInverse);
// On teste ensuite si l'avatar est en collision avec le
// polygone. Au passage, on récupère le plan de collision,
// si celui-ci existe. Remarquez que la position à tester est
// inversée, afin de travailler avec le bon système d'axes.
if ( CCalculsCollisions::
Check( NextPositionInverse,
m_pTabCollision[i].m_fAvatarHeight,
TestPolygon,
&SlidingPlane ) == true )
{
D3DXVECTOR3 plantrans;
D3DXVec3TransformCoord(&plantrans,&D3DXVECTOR3(SlidingPlane.a,SlidingPlane.b,SlidingPlane.c),&matrix);
SlidingPlane.a = plantrans.x;
SlidingPlane.b = plantrans.y;
SlidingPlane.c = plantrans.z;
//Console<<SlidingPlane.a<<":"<<SlidingPlane.b<<":"<<SlidingPlane.c<<endl;
D3DXPlaneNormalize(&SlidingPlane,&SlidingPlane);
// Si une collision a déjà eu lieu, et si le plan trouvé
// n'est pas identique au plan de la collision précédente,
// ni à l'inverse du plan de la collision précédente,
// alors on indique que le joueur est en collision avec
// plusieurs murs.
if ( ( SlidingPlane.a != CollisionPlane.a ||
SlidingPlane.b != CollisionPlane.b ||
SlidingPlane.c != CollisionPlane.c ||
SlidingPlane.d != CollisionPlane.d ) &&
( SlidingPlane.a != -CollisionPlane.a ||
SlidingPlane.b != -CollisionPlane.b ||
SlidingPlane.c != -CollisionPlane.c ||
SlidingPlane.d != -CollisionPlane.d ) &&
indiceCollision != -1 )
{
MultipleCollisions = true;
//Console<<"COllision Multiple"<<endl;
}
// On copie le plan de collision.
CollisionPlane = SlidingPlane;
// Puis, on indique qu'une collision a eu lieu.
indiceCollision = i;
}
// On passe au polygone suivant, pour parcourir toute la liste.
CurrentPolygon = CurrentPolygon->GetNext();
}
}
break;
case BOUNDING_SPHERE :
{
D3DXMATRIX matrix = m_pTabCollision[i].m_pObjetDeCollision->GetWorldMatrix();
D3DXVECTOR3 vPositionObjet (0.0f,0.0f,0.0f);
D3DXVECTOR3 vMin,VMax;
vMin = m_pTabCollision[i].m_pObjetDeCollision->GetBoundingBox().GetMin();
VMax = m_pTabCollision[i].m_pObjetDeCollision->GetBoundingBox().GetMax();
D3DXVec3TransformCoord(&vMin, &vMin, &matrix );
D3DXVec3TransformCoord(&VMax, &VMax, &matrix );
// On calcule, puis on inscrit le centre de la sphère.
D3DXVECTOR3 vPositionBoundingSphere = D3DXVECTOR3( ( vMin.x + VMax.x ) / 2.0f,
( vMin.y + VMax.y ) / 2.0f,
( vMin.z + VMax.z ) / 2.0f ) ;
// Ensuite, on calcule le rayon de la sphère.
D3DXVECTOR3 vRadiusVector = D3DXVECTOR3( ( VMax.x - vMin.x ) / 2.0f,
( VMax.y - vMin.y ) / 2.0f,
( VMax.z - vMin.z ) / 2.0f );
float fRayonBoundingSphere = D3DXVec3Length( &vRadiusVector );
if(CCalculsCollisions::SphereIntersectSphere ( NextPosition,
m_pTabCollision[i].m_fAvatarHeight,
vPositionBoundingSphere,
fRayonBoundingSphere))
{
indiceCollision = i;
MultipleCollisions = true;
}
}
break;
default:break;
}
}
}
if(indiceCollision == -1)
{
return NextPosition;
}
else
{
if(m_pTabCollision[indiceCollision].m_eCollisionType == CCalculsCollisions::COLLISION_AND_SLIDING )
{
if( MultipleCollisions == false )
{
// Si une seule collision a été détectée, on corrige la
// position du joueur en fonction du plan du mur touché.
// Remarquez que la position est inversée, pour qu'elle
// corresponde au système d'axes du plan, et que la réponse est
// à nouveau inversée, pour la reconvertir aux systèmes d'axes
// de la caméra.
return ( CCalculsCollisions::GetSlidingPoint( CollisionPlane,
NextPosition,
m_pTabCollision[indiceCollision].m_fAvatarHeight ) );
}
}
else
return CurrentPosition;
}
return CurrentPosition;
}
|
[
"Colas.Vincent@ab19582e-f48f-11de-8f43-4547254af6c6"
] |
[
[
[
1,
379
]
]
] |
1be5ae610d9af143817536616e0ebe7e237a045b
|
99d3989754840d95b316a36759097646916a15ea
|
/trunk/2011_09_07_to_baoxin_gpd/ferrylibs/src/ferry/util/Observer.cpp
|
ac5e09178d0a5bda8c9b83ce7cdef73cbee9bb7d
|
[] |
no_license
|
svn2github/ferryzhouprojects
|
5d75b3421a9cb8065a2de424c6c45d194aeee09c
|
482ef1e6070c75f7b2c230617afe8a8df6936f30
|
refs/heads/master
| 2021-01-02T09:20:01.983370 | 2011-10-20T11:39:38 | 2011-10-20T11:39:38 | 11,786,263 | 1 | 0 | null | null | null | null |
UTF-8
|
C++
| false | false | 27 |
cpp
|
#include ".\observer.h"
|
[
"ferryzhou@b6adba56-547e-11de-b413-c5e99dc0a8e2"
] |
[
[
[
1,
2
]
]
] |
73b618c143683b2f4c48716b4a3aa79a1f838ae3
|
b67f9fa50b816d0c8a0d6328cafe711c8c21f75e
|
/trunk/moc/moc_ManageSerialPort.cpp
|
480113085f5451ea4fea21eca7cef8cb3b646462
|
[] |
no_license
|
BackupTheBerlios/osibs-svn
|
d46db4e3f78fe872f3dad81d2767d8d8e530e831
|
151911e8fb044c183fca251d226a21cfbf4c6c8f
|
refs/heads/master
| 2021-01-20T12:42:52.308488 | 2011-08-17T19:51:02 | 2011-08-17T19:51:02 | 40,800,844 | 0 | 0 | null | null | null | null |
UTF-8
|
C++
| false | false | 6,116 |
cpp
|
/****************************************************************************
** Meta object code from reading C++ file 'ManageSerialPort.h'
**
** Created: Mon 25. Apr 18:57:41 2011
** by: The Qt Meta Object Compiler version 62 (Qt 4.7.0)
**
** WARNING! All changes made in this file will be lost!
*****************************************************************************/
#include "../SerialPort/ManageSerialPort.h"
#if !defined(Q_MOC_OUTPUT_REVISION)
#error "The header file 'ManageSerialPort.h' doesn't include <QObject>."
#elif Q_MOC_OUTPUT_REVISION != 62
#error "This file was generated using the moc from 4.7.0. It"
#error "cannot be used with the include files from this version of Qt."
#error "(The moc has changed too much.)"
#endif
QT_BEGIN_MOC_NAMESPACE
static const uint qt_meta_data_ManageSerialPort[] = {
// content:
4, // revision
0, // classname
0, 0, // classinfo
1, 14, // methods
0, 0, // properties
0, 0, // enums/sets
0, 0, // constructors
0, // flags
1, // signalCount
// signals: signature, parameters, type, tag, flags
31, 18, 17, 17, 0x05,
0 // eod
};
static const char qt_meta_stringdata_ManageSerialPort[] = {
"ManageSerialPort\0\0dataReceived\0"
"newDataReceived(QByteArray)\0"
};
const QMetaObject ManageSerialPort::staticMetaObject = {
{ &QObject::staticMetaObject, qt_meta_stringdata_ManageSerialPort,
qt_meta_data_ManageSerialPort, 0 }
};
#ifdef Q_NO_DATA_RELOCATION
const QMetaObject &ManageSerialPort::getStaticMetaObject() { return staticMetaObject; }
#endif //Q_NO_DATA_RELOCATION
const QMetaObject *ManageSerialPort::metaObject() const
{
return QObject::d_ptr->metaObject ? QObject::d_ptr->metaObject : &staticMetaObject;
}
void *ManageSerialPort::qt_metacast(const char *_clname)
{
if (!_clname) return 0;
if (!strcmp(_clname, qt_meta_stringdata_ManageSerialPort))
return static_cast<void*>(const_cast< ManageSerialPort*>(this));
return QObject::qt_metacast(_clname);
}
int ManageSerialPort::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
_id = QObject::qt_metacall(_c, _id, _a);
if (_id < 0)
return _id;
if (_c == QMetaObject::InvokeMetaMethod) {
switch (_id) {
case 0: newDataReceived((*reinterpret_cast< const QByteArray(*)>(_a[1]))); break;
default: ;
}
_id -= 1;
}
return _id;
}
// SIGNAL 0
void ManageSerialPort::newDataReceived(const QByteArray & _t1)
{
void *_a[] = { 0, const_cast<void*>(reinterpret_cast<const void*>(&_t1)) };
QMetaObject::activate(this, &staticMetaObject, 0, _a);
}
static const uint qt_meta_data_ThreadSend[] = {
// content:
4, // revision
0, // classname
0, 0, // classinfo
0, 0, // methods
0, 0, // properties
0, 0, // enums/sets
0, 0, // constructors
0, // flags
0, // signalCount
0 // eod
};
static const char qt_meta_stringdata_ThreadSend[] = {
"ThreadSend\0"
};
const QMetaObject ThreadSend::staticMetaObject = {
{ &QThread::staticMetaObject, qt_meta_stringdata_ThreadSend,
qt_meta_data_ThreadSend, 0 }
};
#ifdef Q_NO_DATA_RELOCATION
const QMetaObject &ThreadSend::getStaticMetaObject() { return staticMetaObject; }
#endif //Q_NO_DATA_RELOCATION
const QMetaObject *ThreadSend::metaObject() const
{
return QObject::d_ptr->metaObject ? QObject::d_ptr->metaObject : &staticMetaObject;
}
void *ThreadSend::qt_metacast(const char *_clname)
{
if (!_clname) return 0;
if (!strcmp(_clname, qt_meta_stringdata_ThreadSend))
return static_cast<void*>(const_cast< ThreadSend*>(this));
return QThread::qt_metacast(_clname);
}
int ThreadSend::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
_id = QThread::qt_metacall(_c, _id, _a);
if (_id < 0)
return _id;
return _id;
}
static const uint qt_meta_data_ThreadReceive[] = {
// content:
4, // revision
0, // classname
0, 0, // classinfo
1, 14, // methods
0, 0, // properties
0, 0, // enums/sets
0, 0, // constructors
0, // flags
1, // signalCount
// signals: signature, parameters, type, tag, flags
28, 15, 14, 14, 0x05,
0 // eod
};
static const char qt_meta_stringdata_ThreadReceive[] = {
"ThreadReceive\0\0dataReceived\0"
"newDataReceived(QByteArray)\0"
};
const QMetaObject ThreadReceive::staticMetaObject = {
{ &QThread::staticMetaObject, qt_meta_stringdata_ThreadReceive,
qt_meta_data_ThreadReceive, 0 }
};
#ifdef Q_NO_DATA_RELOCATION
const QMetaObject &ThreadReceive::getStaticMetaObject() { return staticMetaObject; }
#endif //Q_NO_DATA_RELOCATION
const QMetaObject *ThreadReceive::metaObject() const
{
return QObject::d_ptr->metaObject ? QObject::d_ptr->metaObject : &staticMetaObject;
}
void *ThreadReceive::qt_metacast(const char *_clname)
{
if (!_clname) return 0;
if (!strcmp(_clname, qt_meta_stringdata_ThreadReceive))
return static_cast<void*>(const_cast< ThreadReceive*>(this));
return QThread::qt_metacast(_clname);
}
int ThreadReceive::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
_id = QThread::qt_metacall(_c, _id, _a);
if (_id < 0)
return _id;
if (_c == QMetaObject::InvokeMetaMethod) {
switch (_id) {
case 0: newDataReceived((*reinterpret_cast< const QByteArray(*)>(_a[1]))); break;
default: ;
}
_id -= 1;
}
return _id;
}
// SIGNAL 0
void ThreadReceive::newDataReceived(const QByteArray & _t1)
{
void *_a[] = { 0, const_cast<void*>(reinterpret_cast<const void*>(&_t1)) };
QMetaObject::activate(this, &staticMetaObject, 0, _a);
}
QT_END_MOC_NAMESPACE
|
[
"osiair@cc7348f7-d3be-4701-adbb-128cb98a0978"
] |
[
[
[
1,
203
]
]
] |
748b980e30459e8b967741f4acb7fedf9105582d
|
9b786d478560dfe2b99084f5d9338c0729634700
|
/vxWorks/cpp_test_src/Template/template3.cpp
|
0b7f23ee3ff7ca98ebda336b895a925172ac4037
|
[] |
no_license
|
hejunbok/demoCode
|
e33809c13f783cceb47d1bd2a57e2f07b31e42b9
|
fb7a7a9c87ba61d104dabf291805c99f76ae9aac
|
refs/heads/master
| 2021-01-18T08:33:07.654385 | 2011-04-25T06:27:11 | 2011-04-25T06:27:11 | null | 0 | 0 | null | null | null | null |
UTF-8
|
C++
| false | false | 540 |
cpp
|
/* Template3.cpp */
/* Copyright 2004 Wind River Systems, Inc. */
/*
modification history
--------------------
01a,26feb04,pp written.
*/
/* Description
*This function uses the friend template function of a template class
*to access the private data member of the template class
*It also shows overloaded friend functions
*/
/* includes */
#include <iostream>
#include "template3.h"
using namespace std;
int tdfeTestCase23Execute()
{
TempFriend<float> data1(8.9);
foo <float>(data1);
return 0;
}
|
[
"[email protected]"
] |
[
[
[
1,
30
]
]
] |
1d55d544a3c58270e795cecab0757a9f040cd3a9
|
ade474acec1699b0b0c85e84e7fe669b30eecdfd
|
/game/src/map.cpp
|
264e1a6acad833cf14761a3fcb098d43c6880018
|
[] |
no_license
|
f3yagi/mysrc
|
e9f3e67c114b54e3743676ac4a5084db82c1f112
|
4775b9673ba8d3cff5e3f440865a23e51b30e9ce
|
refs/heads/master
| 2020-05-07T15:00:47.180429 | 2009-05-27T12:15:05 | 2009-05-27T12:15:05 | null | 0 | 0 | null | null | null | null |
UTF-8
|
C++
| false | false | 2,928 |
cpp
|
#include <stdio.h>
#include "lib.h"
#include "engine.h"
#include "res.h"
#include "action.h"
/* lib.cpp */
FILE *FOpen(char *name, char *mode);
void FClose(FILE *fp);
#define POS(x, y) (map->width * (y) + (x))
Map *ReadMap(char *name)
{
char *buf;
int x, y, i, n;
Map *map = NULL;
char *data;
buf = LoadFile(name, &n);
data = buf;
map = (Map *)Malloc(sizeof(Map));
map->object = NULL;
MemCpy(&map->width, buf, sizeof(int));
buf += sizeof(int);
MemCpy(&map->height, buf, sizeof(int));
buf += sizeof(int);
map->data = (struct MapData *)Malloc(sizeof(struct MapData) * map->width * map->height);
for (y = 0; y < map->height; y++) {
for (x = 0; x < map->width; x++) {
MemCpy(&map->data[POS(x, y)], buf, sizeof(struct MapData));
buf += sizeof(struct MapData);
}
}
MemCpy(&map->objectNum, buf, sizeof(int));
buf += sizeof(int);
map->object = (struct ObjectData *)Malloc(sizeof(struct ObjectData) * map->objectNum);
for (i = 0; i < map->objectNum; i++) {
MemCpy(&map->object[i], buf, sizeof(struct ObjectData));
buf += sizeof(struct ObjectData);
}
Free(data);
return map;
}
void InitMap(Map *map)
{
map->x = 0;
map->y = 0;
}
void FreeMap(Map *map)
{
if (map->object != NULL) {
Free(map->object);
}
Free(map);
}
void MoveMap(Map *map)
{
Object *o = TO_OBJECT(GetPlayer());
float x = CX(o);
float y = CY(o);
float width = (float)ENGINE_WIDTH;
float height = (float)ENGINE_HEIGTH;
if (x + width / 2.0f > map->width * BLOCK_WIDTH) {
map->x = map->width * BLOCK_WIDTH - width;
}
if (x - width / 2.0f >= 0 &&
x + width / 2.0f < map->width * BLOCK_WIDTH) {
map->x = x - width / 2.0f;
}
/*
if (y + height / 2.0f > map->height * BLOCK_HEIGHT) {
map->y = map->height * BLOCK_HEIGHT - height;
}
if (y - height / 2.0f >= 0 &&
y + height / 2.0f < map->height * BLOCK_HEIGHT) {
map->y = y - height / 2.0f;
}
*/
}
int IsWall(Map *map, int x, int y)
{
if (0 > x || x >= map->width || 0 > y || y >= map->height) {
return 0;
}
return map->data[POS(x, y)].wall;
}
void CreateObject(Map *map)
{
int i;
InitEnemy();
InitItem();
InitBomb();
InitEffect();
for (i = 0; i < map->objectNum; i++) {
float x = (float)map->object[i].x * BLOCK_WIDTH;
float y = (float)map->object[i].y * BLOCK_HEIGHT;
char type = map->object[i].type;
int r;
if (type == PLAYER) {
InitPlayer(x, y);
}
r = CreateEnemy(type, x, y);
if (r) {
continue;
}
CreateItem(type, x, y);
}
MoveMap(map);
}
|
[
"pochi@debian.(none)"
] |
[
[
[
1,
117
]
]
] |
e86a804aea9d2093ec07fc9625c1fa6ab58dd73c
|
11da90929ba1488c59d25c57a5fb0899396b3bb2
|
/Src/StringListPayloadHandler.cpp
|
1b1e0348e8a7ac42c19f41fd4748a14e79266fb1
|
[] |
no_license
|
danste/ars-framework
|
5e7864630fd8dbf7f498f58cf6f9a62f8e1d95c6
|
90f99d43804d3892432acbe622b15ded6066ea5d
|
refs/heads/master
| 2022-11-11T15:31:02.271791 | 2005-10-17T15:37:36 | 2005-10-17T15:37:36 | 263,623,421 | 0 | 0 | null | 2020-05-13T12:28:22 | 2020-05-13T12:28:21 | null |
UTF-8
|
C++
| false | false | 854 |
cpp
|
#include <StringListPayloadHandler.hpp>
#include <Text.hpp>
StringListPayloadHandler::~StringListPayloadHandler()
{
StrArrFree(strings, stringsCount);
}
status_t StringListPayloadHandler::handleIncrement(const char_t* payload, ulong_t& length, bool finish)
{
status_t error = LineBufferedPayloadHandler::handleIncrement(payload, length, finish);
if (finish && errNone == error)
error = notifyFinished();
return error;
}
status_t StringListPayloadHandler::handleLine(const char_t* line, ulong_t length)
{
if (NULL == StrArrAppendStrCopy(strings, stringsCount, line, length))
return memErrNotEnoughSpace;
return errNone;
}
StringListPayloadHandler::StringListPayloadHandler():
strings(NULL),
stringsCount(0)
{}
status_t StringListPayloadHandler::notifyFinished()
{
return errNone;
}
|
[
"andrzejc@10a9aba9-86da-0310-ac04-a2df2cc00fd9",
"kjk@10a9aba9-86da-0310-ac04-a2df2cc00fd9"
] |
[
[
[
1,
3
],
[
5,
7
],
[
11,
11
],
[
16,
17
],
[
19,
22
],
[
25,
27
]
],
[
[
4,
4
],
[
8,
10
],
[
12,
15
],
[
18,
18
],
[
23,
24
],
[
28,
33
]
]
] |
52959d186578480883679a2524da19a2cdc9d21b
|
57c3ef7177f9bf80874fbd357fceb8625e746060
|
/Personal_modle_file/Dean_Zhang/IMServer/mainwindow.h
|
e198fd02b2e09745c8ba1f8be61fb45306942f57
|
[] |
no_license
|
kref/mobileim
|
0c33cc01b312704d71e74db04c4ba9b624b4ff73
|
15894fa006095428727b0530e9337137262818ac
|
refs/heads/master
| 2016-08-10T08:33:27.761030 | 2011-08-13T13:15:37 | 2011-08-13T13:15:37 | 45,781,075 | 0 | 0 | null | null | null | null |
UTF-8
|
C++
| false | false | 770 |
h
|
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <QMainWindow>
#include "myserver.h"
#include <QListWidget>
namespace Ui {
class MainWindow;
}
class MyServer;
typedef struct ClientNode clientNode;
class MainWindow : public QMainWindow {
Q_OBJECT
public:
MainWindow(QWidget *parent = 0);
~MainWindow();
//Ui::MainWindow *ui;
protected:
void changeEvent(QEvent *e);
private:
Ui::MainWindow *ui;
MyServer* server;
public slots:
void setTextBrowser(QString str);
void addNodetoList(QString str);
void deleteNodefromList(QString str);
void ProcessInterAction(QListWidgetItem *item);
private slots:
void on_pushButton_clicked();
void on_pushButton_2_clicked();
};
#endif // MAINWINDOW_H
|
[
"[email protected]"
] |
[
[
[
1,
41
]
]
] |
bdf20be92a8bbdc36eba7187725740a7f73da892
|
55196303f36aa20da255031a8f115b6af83e7d11
|
/private/external/gameswf/gameswf/gameswf_object.h
|
76d24c2aff280c9650f6efa7a7a5ecec38cacd8f
|
[] |
no_license
|
Heartbroken/bikini
|
3f5447647d39587ffe15a7ae5badab3300d2a2ff
|
fe74f51a3a5d281c671d303632ff38be84d23dd7
|
refs/heads/master
| 2021-01-10T19:48:40.851837 | 2010-05-25T19:58:52 | 2010-05-25T19:58:52 | 37,190,932 | 0 | 0 | null | null | null | null |
UTF-8
|
C++
| false | false | 4,088 |
h
|
// gameswf_object.h -- Thatcher Ulrich <[email protected]> 2003
// This source code has been donated to the Public Domain. Do
// whatever you want with it.
// A generic bag of attributes. Base-class for ActionScript
// script-defined objects.
#ifndef GAMESWF_OBJECT_H
#define GAMESWF_OBJECT_H
#include "gameswf/gameswf_value.h"
#include "gameswf/gameswf_environment.h"
#include "gameswf/gameswf_types.h"
#include "gameswf/gameswf_player.h"
#include "base/container.h"
#include "base/smart_ptr.h"
#include "base/tu_loadlib.h"
namespace gameswf
{
exported_module void as_object_addproperty(const fn_call& fn);
exported_module void as_object_registerclass( const fn_call& fn );
exported_module void as_object_hasownproperty(const fn_call& fn);
exported_module void as_object_watch(const fn_call& fn);
exported_module void as_object_unwatch(const fn_call& fn);
exported_module void as_object_dump(const fn_call& fn);
exported_module void as_global_object_ctor(const fn_call& fn);
// flash9
exported_module void as_object_add_event_listener(const fn_call& fn);
struct as_object : public as_object_interface
{
// Unique id of a gameswf resource
enum { m_class_id = AS_OBJECT };
exported_module virtual bool is(int class_id) const
{
return m_class_id == class_id;
}
stringi_hash<as_value> m_members;
// It is used to register an event handler to be invoked when
// a specified property of object changes.
// TODO: create container based on stringi_hash<as_value>
// watch should be coomon
struct as_watch
{
as_watch() : m_func(NULL)
{
}
as_function* m_func;
as_value m_user_data;
};
// primitive data type has no dynamic members
stringi_hash<as_watch>* m_watch;
// it's used for passing new created object pointer to constructors chain
weak_ptr<as_object> m_this_ptr;
// We can place reference to __proto__ into members but it's used very often
// so for optimization we place it into instance
smart_ptr<as_object> m_proto; // for optimization
// pointer to owner
weak_ptr<player> m_player;
exported_module as_object(player* player);
exported_module virtual ~as_object();
exported_module virtual const char* to_string() { return "[object Object]"; }
exported_module virtual double to_number();
exported_module virtual bool to_bool() { return true; }
exported_module virtual const char* typeof() { return "object"; }
exported_module void builtin_member(const tu_stringi& name, const as_value& val);
exported_module virtual bool set_member(const tu_stringi& name, const as_value& val);
exported_module virtual bool get_member(const tu_stringi& name, as_value* val);
exported_module virtual bool on_event(const event_id& id);
exported_module virtual void enumerate(as_environment* env);
exported_module virtual as_object* get_proto() const;
exported_module virtual bool watch(const tu_string& name, as_function* callback, const as_value& user_data);
exported_module virtual bool unwatch(const tu_string& name);
exported_module virtual void clear_refs(hash<as_object*, bool>* visited_objects, as_object* this_ptr);
exported_module virtual void this_alive();
exported_module virtual void alive() { return; }
exported_module virtual void copy_to(as_object* target);
exported_module virtual void dump(tu_string& tabs);
exported_module virtual void dump();
exported_module as_object* find_target(const as_value& target);
exported_module virtual root* get_root() const;
exported_module virtual as_environment* get_environment() { return 0; }
exported_module virtual void advance(float delta_time) { assert(0); }
player* get_player() const { return m_player.get_ptr(); }
bool is_instance_of(const as_function* constructor) const;
as_object* get_global() const;
// get/set constructor of object
bool get_ctor(as_value* val) const;
void set_ctor(const as_value& val);
as_object* create_proto(const as_value& constructor);
};
}
#endif
|
[
"viktor.reutskyy@68c2588f-494f-0410-aecb-65da31d84587"
] |
[
[
[
1,
112
]
]
] |
0f9c2deea25250e82bb7503df1bf457329b767d7
|
3449de09f841146a804930f2a51ccafbc4afa804
|
/C++/CodeJam/practice/BallBouncing.cpp
|
c1679c212c036773d8b1c747d1cfd944ffac5d81
|
[] |
no_license
|
davies/daviescode
|
0c244f4aebee1eb909ec3de0e4e77db3a5bbacee
|
bb00ee0cfe5b7d5388485c59211ebc9ba2d6ecbd
|
refs/heads/master
| 2020-06-04T23:32:27.360979 | 2007-08-19T06:31:49 | 2007-08-19T06:31:49 | 32,641,672 | 1 | 1 | null | null | null | null |
UTF-8
|
C++
| false | false | 8,268 |
cpp
|
// BEGIN CUT HERE
// PROBLEM STATEMENT
// A ball is moving diagonally on a rectangular board
// composed of unit squares in rows rows and columns columns.
// Each square is identified by its row and column number.
// The lowermost row is marked row 0 and the leftmost column
// is column 0.
//
// The ball is initially located in the middle of a starting
// square given by two integers, startrow and startcol, and
// is moving diagonally up-right at an angle of 45 degrees.
// Whenever it reaches a wall, it bounces off it at a right
// angle (an angle of 90 degrees) and continues moving. If
// the ball runs into a corner, it bounces back in the
// opposite direction from which it came..
//
//
//
// A number of holes have been drilled in the board and the
// ball will fall in upon reaching a square with a hole.
// Given the board size, starting location and locations of
// holes, return the number of times the ball will bounce off
// a wall before falling into a hole, or -1 if the ball will
// continue bouncing indefinitely.
//
// DEFINITION
// Class:BallBouncing
// Method:bounces
// Parameters:int, int, int, int, vector <string>
// Returns:int
// Method signature:int bounces(int rows, int columns, int
// startrow, int startcol, vector <string> holes)
//
//
// NOTES
// -Bouncing back from a corner counts as only one bounce.
//
//
// CONSTRAINTS
// -rows and columns will be between 1 and 1000000, inclusive.
// -startrow will be between 0 and rows-1, inclusive.
// -startcol will be between 0 and columns-1, inclusive.
// -holes will contain between 0 and 50 elements, inclusive.
// -Each element of holes will be formatted as "row column"
// (quotes for clarity), where row and column will be
// integers with no leading zeros representing a square
// inside the board.
// -There will be no holes at the starting position of the
// ball.
// -No two holes will occupy the same position on the board.
//
//
// EXAMPLES
//
// 0)
// 8
// 11
// 2
// 1
// { "1 5", "5 3", "4 4" }
//
// Returns: 3
//
// This example corresponds to the image in the problem
// statement.
//
// 1)
// 6
// 5
// 5
// 3
// { "1 3" }
//
// Returns: 7
//
// Bouncing back from a corner counts as only one bounce.
//
// 2)
// 6
// 7
// 4
// 4
// { }
//
// Returns: -1
//
// With no holes, the ball is bound to bounce around for
// quite a while.
//
// 3)
// 3
// 3
// 1
// 1
// { "2 2" }
//
// Returns: 0
//
// 4)
// 6
// 6
// 0
// 5
// { "4 1", "3 2", "4 3", "2 1", "3 0", "5 2" }
//
// Returns: -1
//
// 5)
// 1000000
// 999999
// 66246
// 84332
// { "854350 4982" }
//
// Returns: 1662562
//
// 6)
// 5
// 7
// 3
// 4
// { "0 6", "2 3" }
//
// Returns: 5
//
// 7)
// 1
// 5
// 0
// 1
// { "0 3" }
//
// Returns: 2
//
#line 136 "BallBouncing.cpp"
// END CUT HERE
#include <string>
#include <iostream>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <complex>
#include <cmath>
#include <valarray>
#include <numeric>
#include <functional>
#include <algorithm>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector< VI > VVI;
typedef vector<char> VC;
typedef vector<string> VS;
typedef map<int,int> MII;
typedef map<string,int> MSI;
#define SZ(v) ((int)(v).size())
#define FOR(i,a,b) for(int i=(a);i<int(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define FOUND(v,p) (find(ALL(v),p)!=v.end())
#define SUM(v) accumulate(ALL(v),0)
#define SE(i) (i)->second
#define DV(v) REP(i,SZ(v)) cout << v[i] << " "; cout << endl
typedef stringstream SS;
typedef istringstream ISS;
typedef ostringstream OSS;
template<class U,class T> T cast(U x){T y; OSS a; a<<x; ISS b(a.str());b>>y;return y;}
class BallBouncing
{
public:
int bounces(int rows, int columns, int startrow, int startcol, vector <string> holes)
{
if( holes.empty() ) return -1;
vector<complex<int> > hole;
REP(i,SZ(holes)){
ISS in(holes[i]);
int r,c;in >> r >> c;
hole.push_back( complex<int>(r*2,c*2));
}
vector<pair<complex<int>,complex<int> > > his;
int re = 0;
complex<int> p = complex<int>(startrow*2,startcol*2);
complex<int> dir = complex<int>(2,2);
while(true){
complex<int> q = p + dir;
complex<int> n = q;
if( q.real() < 0 ) n = complex<int>(q.real()+2,q.imag());
if( q.real() > rows*2 ) n = complex<int>(q.real()-2,q.imag());
if( q.imag() < 0 ) n = complex<int>(q.real(),q.imag()+2);
if( q.imag() > columns*2 ) n = complex<int>(q.real(),q.imag()-2);
if( find(ALL(hole),n) != hole.end() ) return re;
if( n != q ){
complex<int> c = (q+p)/2;
pair<complex<int>,complex<int> > s = make_pair(p,n);
if( find(ALL(his), s) != his.end() ){
return -1;
}else{
his.push_back( s );
re ++;
dir = (n-c)*2;
}
}
p=n;
}
}
// BEGIN CUT HERE
public:
void run_test(int Case) { if ((Case == -1) || (Case == 0)) test_case_0(); if ((Case == -1) || (Case == 1)) test_case_1(); if ((Case == -1) || (Case == 3)) test_case_3(); if ((Case == -1) || (Case == 4)) test_case_4(); if ((Case == -1) || (Case == 5)) test_case_5(); if ((Case == -1) || (Case == 6)) test_case_6(); if ((Case == -1) || (Case == 7)) test_case_7(); }
private:
template <typename T> string print_array(const vector<T> &V) { ostringstream os; os << "{ "; for (typename vector<T>::const_iterator iter = V.begin(); iter != V.end(); ++iter) os << '\"' << *iter << "\","; os << " }"; return os.str(); }
void verify_case(int Case, const int &Expected, const int &Received) { cerr << "Test Case #" << Case << "..."; if (Expected == Received) cerr << "PASSED" << endl; else { cerr << "FAILED" << endl; cerr << "\tExpected: \"" << Expected << '\"' << endl; cerr << "\tReceived: \"" << Received << '\"' << endl; } }
void test_case_0() { int Arg0 = 8; int Arg1 = 11; int Arg2 = 2; int Arg3 = 1; string Arr4[] = { "1 5", "5 3", "4 4" }; vector <string> Arg4(Arr4, Arr4 + (sizeof(Arr4) / sizeof(Arr4[0]))); int Arg5 = 3; verify_case(0, Arg5, bounces(Arg0, Arg1, Arg2, Arg3, Arg4)); }
void test_case_1() { int Arg0 = 6; int Arg1 = 5; int Arg2 = 5; int Arg3 = 3; string Arr4[] = { "1 3" }; vector <string> Arg4(Arr4, Arr4 + (sizeof(Arr4) / sizeof(Arr4[0]))); int Arg5 = 7; verify_case(1, Arg5, bounces(Arg0, Arg1, Arg2, Arg3, Arg4)); }//
// void test_case_2() { int Arg0 = 6; int Arg1 = 7; int Arg2 = 4; int Arg3 = 4; string Arr4[] = { }; vector <string> Arg4(Arr4, Arr4 + (sizeof(Arr4) / sizeof(Arr4[0]))); int Arg5 = -1; verify_case(2, Arg5, bounces(Arg0, Arg1, Arg2, Arg3, Arg4)); }
void test_case_3() { int Arg0 = 3; int Arg1 = 3; int Arg2 = 1; int Arg3 = 1; string Arr4[] = { "2 2" }; vector <string> Arg4(Arr4, Arr4 + (sizeof(Arr4) / sizeof(Arr4[0]))); int Arg5 = 0; verify_case(3, Arg5, bounces(Arg0, Arg1, Arg2, Arg3, Arg4)); }
void test_case_4() { int Arg0 = 6; int Arg1 = 6; int Arg2 = 0; int Arg3 = 5; string Arr4[] = { "4 1", "3 2", "4 3", "2 1", "3 0", "5 2" }; vector <string> Arg4(Arr4, Arr4 + (sizeof(Arr4) / sizeof(Arr4[0]))); int Arg5 = -1; verify_case(4, Arg5, bounces(Arg0, Arg1, Arg2, Arg3, Arg4)); }
void test_case_5() { int Arg0 = 1000000; int Arg1 = 999999; int Arg2 = 66246; int Arg3 = 84332; string Arr4[] = { "854350 4982" }; vector <string> Arg4(Arr4, Arr4 + (sizeof(Arr4) / sizeof(Arr4[0]))); int Arg5 = 1662562; verify_case(5, Arg5, bounces(Arg0, Arg1, Arg2, Arg3, Arg4)); }
void test_case_6() { int Arg0 = 5; int Arg1 = 7; int Arg2 = 3; int Arg3 = 4; string Arr4[] = { "0 6", "2 3" }; vector <string> Arg4(Arr4, Arr4 + (sizeof(Arr4) / sizeof(Arr4[0]))); int Arg5 = 5; verify_case(6, Arg5, bounces(Arg0, Arg1, Arg2, Arg3, Arg4)); }
void test_case_7() { int Arg0 = 1; int Arg1 = 5; int Arg2 = 0; int Arg3 = 1; string Arr4[] = { "0 3" }; vector <string> Arg4(Arr4, Arr4 + (sizeof(Arr4) / sizeof(Arr4[0]))); int Arg5 = 2; verify_case(7, Arg5, bounces(Arg0, Arg1, Arg2, Arg3, Arg4)); }
// END CUT HERE
};
// BEGIN CUT HERE
int main()
{
BallBouncing ___test;
___test.run_test(1);
}
// END CUT HERE
|
[
"davies.liu@32811f3b-991a-0410-9d68-c977761b5317"
] |
[
[
[
1,
242
]
]
] |
a513d620cb2fb62479d502a9f78e3f3743b624b6
|
52f70251d04ca4f42ba3cb991727003a87d2c358
|
/src/pragma/image/functions.h
|
41ac0dd476ef8868b05eda3562b822f637745fda
|
[
"MIT"
] |
permissive
|
vicutrinu/pragma-studios
|
71a14e39d28013dfe009014cb0e0a9ca16feb077
|
181fd14d072ccbb169fa786648dd942a3195d65a
|
refs/heads/master
| 2016-09-06T14:57:33.040762 | 2011-09-11T23:20:24 | 2011-09-11T23:20:24 | 2,151,432 | 0 | 0 | null | null | null | null |
UTF-8
|
C++
| false | false | 310 |
h
|
#pragma once
#include <pragma/types.h>
namespace pragma
{
class Image;
bool ExportToTGA (const Image& aImage, const char* aFilename);
bool ExportToTGA (const uint8* aImage, size_t aWidth, size_t aHeight, const char* aFilename);
bool ImportFromTGA (Image& aImage, const char* aFilename);
}
|
[
"[email protected]"
] |
[
[
[
1,
13
]
]
] |
acf515f82797c5285d8867f1a2bcac5c427f8ca2
|
36d0ddb69764f39c440089ecebd10d7df14f75f3
|
/プログラム/Ngllib/include/Ngl/IMeshCollision.h
|
3be33250e3bafcb263a3429ece46da7db5d9a49d
|
[] |
no_license
|
weimingtom/tanuki-mo-issyo
|
3f57518b4e59f684db642bf064a30fc5cc4715b3
|
ab57362f3228354179927f58b14fa76b3d334472
|
refs/heads/master
| 2021-01-10T01:36:32.162752 | 2009-04-19T10:37:37 | 2009-04-19T10:37:37 | 48,733,344 | 0 | 0 | null | null | null | null |
SHIFT_JIS
|
C++
| false | false | 3,432 |
h
|
/*******************************************************************************/
/**
* @file IMeshCollision.h.
*
* @brief メッシュデータ衝突判定クラスインターフェース定義.
*
* @date 2008/07/19.
*
* @version 1.00.
*
* @author Kentarou Nishimura.
*/
/******************************************************************************/
#ifndef _NGL_IMESHCOLLISION_H_
#define _NGL_IMESHCOLLISION_H_
#include "CollisionReport.h"
namespace Ngl{
/**
* @class IMeshCollision.
* @brief メッシュデータ衝突判定クラスインターフェース.
*/
class IMeshCollision
{
public:
/*=========================================================================*/
/**
* @brief デストラクタ
*
* @param[in] なし.
*/
~IMeshCollision() {}
/*===========================================================================*/
/**
* @brief 線分との衝突判定
*
* @param[in] line0 線分の始点.
* @param[in] line1 線分の終点.
* @return 衝突結果構造体の参照.
*/
virtual const PlaneCollisionReport& line( const float* line0, const float* line1 ) = 0;
/*===========================================================================*/
/**
* @brief 指定のポリゴンと線分との衝突判定
*
* @param[in] polygonNo ポリゴンデータ番号.
* @param[in] line0 線分の始点.
* @param[in] line1 線分の終点.
* @return 衝突結果構造体の参照.
*/
virtual const PlaneCollisionReport& polygonAndLine( int polygonNo, const float* line0, const float* line1 ) = 0;
/*===========================================================================*/
/**
* @brief 3D線との衝突判定
*
* @param[in] rayPos 3D線の始点座標.
* @param[in] rayDir 3D線の方向.
* @return 面データ衝突パラメーター.
*/
virtual const PlaneCollisionReport& ray( const float* rayPos, const float* rayDir ) = 0;
/*===========================================================================*/
/**
* @brief 指定のポリゴンと3D線との衝突判定
*
* @param[in] polygonNo ポリゴンデータ番号.
* @param[in] rayPos 3D線の始点座標.
* @param[in] rayDir 3D線の方向.
* @return 面データ衝突パラメーター.
*/
virtual const PlaneCollisionReport& polygonAndRay( int polygonNo, const float* rayPos, const float* rayDir ) = 0;
/*===========================================================================*/
/**
* @brief 球体との衝突判定
*
* @param[in] center 球体の中心位置.
* @param[in] radius 球体の半径.
* @return 面データ衝突パラメーター.
*/
virtual const PlaneCollisionReport& sphere( const float* center, float radius ) = 0;
/*===========================================================================*/
/**
* @brief 指定のポリゴンと球体との衝突判定
*
* @param[in] polygonNo ポリゴンデータ番号.
* @param[in] center 球体の中心位置.
* @param[in] radius 球体の半径.
* @return 面データ衝突パラメーター.
*/
virtual const PlaneCollisionReport& polygonAndSphere( int polygonNo, const float* center, float radius ) = 0;
};
} // namespace Ngl
#endif
/*===== EOF ==================================================================*/
|
[
"rs.drip@aa49b5b2-a402-11dd-98aa-2b35b7097d33"
] |
[
[
[
1,
114
]
]
] |
aaf0ab07001f4d59494f0bcfe2a2910b9e22139b
|
91b964984762870246a2a71cb32187eb9e85d74e
|
/SRC/OFFI SRC!/boost_1_34_1/boost_1_34_1/libs/python/pyste/tests/inherit2.h
|
aa27509bd78a4f7412630244f7d35bc2a354470c
|
[
"BSL-1.0",
"LicenseRef-scancode-unknown-license-reference"
] |
permissive
|
willrebuild/flyffsf
|
e5911fb412221e00a20a6867fd00c55afca593c7
|
d38cc11790480d617b38bb5fc50729d676aef80d
|
refs/heads/master
| 2021-01-19T20:27:35.200154 | 2011-02-10T12:34:43 | 2011-02-10T12:34:43 | 32,710,780 | 3 | 0 | null | null | null | null |
UTF-8
|
C++
| false | false | 613 |
h
|
/* Copyright Bruno da Silva de Oliveira 2003. Use, modification and
distribution is subject to the Boost Software License, Version 1.0.
(See accompanying file LICENSE_1_0.txt or copy at
http:#www.boost.org/LICENSE_1_0.txt)
*/
namespace inherit2 {
struct A
{
int x;
int getx() { return x; }
int foo() { return 0; }
int foo(int x) { return x; }
};
struct B : A
{
int y;
int gety() { return y; }
int foo() { return 1; }
};
struct C : B
{
int z;
int getz() { return z; }
};
struct D : C
{
int w;
int getw() { return w; }
};
}
|
[
"[email protected]@e2c90bd7-ee55-cca0-76d2-bbf4e3699278"
] |
[
[
[
1,
35
]
]
] |
b9df9f919a4e21ecfc2b8466fbe365efa777f687
|
709cd826da3ae55945fd7036ecf872ee7cdbd82a
|
/Term/WildMagic2/Source/Physics/WmlIntersectingBoxes.h
|
fb51589c9e07d24d49b120b104b62c48bcf747cb
|
[] |
no_license
|
argapratama/kucgbowling
|
20dbaefe1596358156691e81ccceb9151b15efb0
|
65e40b6f33c5511bddf0fa350c1eefc647ace48a
|
refs/heads/master
| 2018-01-08T15:27:44.784437 | 2011-06-19T15:23:39 | 2011-06-19T15:23:39 | 36,738,655 | 0 | 0 | null | null | null | null |
UTF-8
|
C++
| false | false | 3,678 |
h
|
// Magic Software, Inc.
// http://www.magic-software.com
// http://www.wild-magic.com
// Copyright (c) 2003. All Rights Reserved
//
// The Game Physics source code is supplied under the terms of the license
// agreement http://www.magic-software.com/License/GamePhysics.pdf and may not
// be copied or disclosed except in accordance with the terms of that
// agreement.
#ifndef WMLINTERSECTINGBOXES_H
#define WMLINTERSECTINGBOXES_H
#include "WmlAxisAlignedBox3.h"
#include <set>
#include <vector>
namespace Wml
{
template <class Real>
class WML_ITEM IntersectingBoxes
{
public:
typedef typename std::pair<int,int> BoxPair;
// construction and destruction
IntersectingBoxes (std::vector<AxisAlignedBox3<Real> >& rkBoxes);
~IntersectingBoxes ();
// This function is called by the constructor and does the sort-and-sweep
// to initialize the update system. However, if you add or remove items
// from the array of boxes after the constructor call, you will need
// to call this function once before you start the multiple calls of the
// update function.
void Initialize ();
// After the system is initialized, you can move the boxes using this
// function. It is not enough to modify the input array of boxes
// since the end point values stored internally by this class must also
// change. You can also retrieve the current rectangles information.
void SetBox (int i, const AxisAlignedBox3<Real>& rkRect);
void GetBox (int i, AxisAlignedBox3<Real>& rkRect) const;
// When you are finished moving rectangles, call this function to
// determine the overlapping boxes. An incremental update is applied
// to determine the new set of overlapping boxes.
void Update ();
// If (i,j) is in the overlap set, then box i and box j are
// overlapping. The indices are those for the the input array. The
// set elements (i,j) are stored so that i < j.
const std::set<BoxPair>& GetOverlap () const;
private:
class WML_ITEM EndPoint
{
public:
Real Value;
int Type; // '0' if interval min, '1' if interval max
int Index; // index of interval containing this end point
// support for sorting of end points
bool operator< (const EndPoint& rkEP) const
{
if ( Value < rkEP.Value )
return true;
if ( Value > rkEP.Value )
return false;
return Type < rkEP.Type;
}
};
void InsertionSort (std::vector<EndPoint>& rkEndPoint,
std::vector<int>& rkLookup);
std::vector<AxisAlignedBox3<Real> >& m_rkBoxes;
std::vector<EndPoint> m_kXEndPoint, m_kYEndPoint, m_kZEndPoint;
std::set<BoxPair> m_kOverlap;
// The intervals are indexed 0 <= i < n. The end point array has 2*n
// entries. The original 2*n interval values are ordered as b[0], e[0],
// b[1], e[1], ..., b[n-1], e[n-1]. When the end point array is sorted,
// the mapping between interval values and end points is lost. In order
// to modify interval values that are stored in the end point array, we
// need to maintain the mapping. This is done by the following lookup
// table of 2*n entries. The value m_kLookup[2*i] is the index of b[i]
// in the end point array. The value m_kLookup[2*i+1] is the index of
// e[i] in the end point array.
std::vector<int> m_kXLookup, m_kYLookup, m_kZLookup;
};
typedef IntersectingBoxes<float> IntersectingBoxesf;
typedef IntersectingBoxes<double> IntersectingBoxesd;
}
#endif
|
[
"[email protected]"
] |
[
[
[
1,
98
]
]
] |
11599c411bdbab39868461f31e3a261d11a24c37
|
c86f787916e295d20607cbffc13c524018888a0f
|
/tp2/codigo/ejercicio3/listas/nodo_listas_PATRICIA.h
|
d4dde76653bbabdc4f872509c32bfcd49f33ed2e
|
[] |
no_license
|
federicoemartinez/algo3-2008
|
0039a4bc6d83ab8005fa2169b919e6c03524bad5
|
3b04cbea4583d76d7a97f2aee72493b4b571a77b
|
refs/heads/master
| 2020-06-05T05:56:20.127248 | 2008-08-04T04:59:32 | 2008-08-04T04:59:32 | 32,117,945 | 0 | 0 | null | null | null | null |
UTF-8
|
C++
| false | false | 2,272 |
h
|
#ifndef _NODO_LISTAS_PATRICIA_H_
#define _NODO_LISTAS_PATRICIA_H_
#include <string>
#include <list>
using namespace std;
class nodo{
friend class PATRICIA;
friend ostream& operator<<(ostream&, const nodo&);
public:
// Constructor
// Parametros: void
// Proposito: Inicializa la estructura de datos.
nodo(){_existe = false;}
// Parametros: cadena del puntero que linkea this con nuevonodo, el nodo a ser linkeado
// Proposito: agregar un nuevo nodo relacionandolo con la cadena
void agregar (const string& s, nodo* nuevonodo = NULL);
// Parametros: cadena del puntero a eliminar
// Proposito: eliminar el puntero relacionado a la cadena s
void sacar (const string& s);
// Parametros: cadena a verificar si tiene un puntero asignado
// Proposito: ver si una cadena tiene un puntero asignado en el nodo this
bool pertenece (const string& s);
// Parametros: void
// Proposito: ver si el nodo existe
bool getExiste(void);
// Parametros: void
// Proposito: asignar la existencia o no existencia del nodo
void setExiste(bool);
// Parametros: void
// Proposito: ver la cantidad de elementos que hay linkeados en el nodo
unsigned int cantHijos(void);
// Parametros: void
// Proposito: ver si el nodo no tiene ningun elemento linkeado
bool esHoja(void);
// Destructor
// Parametros: void
// Proposito: Destruye la estructura de datos.
~nodo(){};
private:
struct eje{
nodo* puntero;
string cadena;
};
bool _existe;
list<eje> listaEjes;
// Parametros: cadena con un solo elemento que simboliza el
// primer caracter de la cadena que se quiere ver
// Proposito: ver un elemento especifico
nodo::eje* ejeQueEmpiezaCon(char c);
// Parametros: posicion de la cadena que se quiere ver (0-n)
// Proposito: ver un elemento especifico
nodo::eje* iesimoEje(int i);
// Parametros: posicion de la cadena que se quiere ver (0-n)
// Proposito: ver un elemento
nodo::eje* primerEje(void);
};
#endif
|
[
"HadesKleizer@bfd18afd-6e49-0410-abef-09437ef2666c"
] |
[
[
[
1,
74
]
]
] |
6c0617abbf4b87f7d09f8e4021b89e8ad43d9797
|
989aa92c9dab9a90373c8f28aa996c7714a758eb
|
/HydraIRC/include/propertylist/PropertyItemImpl.h
|
6fd15a1b9691e9ffff44912e5dc16af68115f1ed
|
[] |
no_license
|
john-peterson/hydrairc
|
5139ce002e2537d4bd8fbdcebfec6853168f23bc
|
f04b7f4abf0de0d2536aef93bd32bea5c4764445
|
refs/heads/master
| 2021-01-16T20:14:03.793977 | 2010-04-03T02:10:39 | 2010-04-03T02:10:39 | null | 0 | 0 | null | null | null | null |
UTF-8
|
C++
| false | false | 26,550 |
h
|
#ifndef __PROPERTYITEMIMPL__H
#define __PROPERTYITEMIMPL__H
#pragma once
/////////////////////////////////////////////////////////////////////////////
// CPropertyItemImpl - Property implementations for the Property controls
//
// Written by Bjarke Viksoe ([email protected])
// Copyright (c) 2001-2002 Bjarke Viksoe.
//
// This code may be used in compiled form in any way you desire. This
// file may be redistributed by any means PROVIDING it is
// not sold for profit without the authors written consent, and
// providing that this notice and the authors name is included.
//
// This file is provided "as is" with no expressed or implied warranty.
// The author accepts no liability if it causes any damage to you or your
// computer whatsoever. It's free, so don't hassle me about it.
//
// Beware of bugs.
//
#ifndef __PROPERTYITEM__H
#error PropertyItemImpl.h requires PropertyItem.h to be included first
#endif
#ifndef __PROPERTYITEMEDITORS__H
#error PropertyItemImpl.h requires PropertyItemEditors.h to be included first
#endif
#ifndef __ATLBASE_H__
#error PropertyItem.h requires atlbase.h to be included first
#endif
/////////////////////////////////////////////////////////////////////////////
// Base CProperty class
class CProperty : public IProperty
{
protected:
HWND m_hWndOwner;
LPTSTR m_pszName;
bool m_fEnabled;
LPARAM m_lParam;
public:
CProperty(LPCTSTR pstrName, LPARAM lParam) : m_fEnabled(true), m_lParam(lParam), m_hWndOwner(NULL)
{
ATLASSERT(!::IsBadStringPtr(pstrName,-1));
ATLTRY(m_pszName = new TCHAR[ (::lstrlen(pstrName) * sizeof(TCHAR)) + 1 ]);
ATLASSERT(m_pszName);
::lstrcpy(m_pszName, pstrName);
}
virtual ~CProperty()
{
delete [] m_pszName;
}
virtual void SetOwner(HWND hWnd, LPVOID /*pData*/)
{
ATLASSERT(::IsWindow(hWnd));
ATLASSERT(m_hWndOwner==NULL); // Cannot set it twice
m_hWndOwner = hWnd;
}
virtual LPCTSTR GetName() const
{
return m_pszName; // Dangerous!
}
virtual void SetEnabled(BOOL bEnable)
{
m_fEnabled = bEnable == TRUE;
}
virtual BOOL IsEnabled() const
{
return m_fEnabled;
}
virtual void SetItemData(LPARAM lParam)
{
m_lParam = lParam;
}
virtual LPARAM GetItemData() const
{
return m_lParam;
}
virtual void DrawName(PROPERTYDRAWINFO& di)
{
CDCHandle dc(di.hDC);
COLORREF clrBack, clrFront;
if( di.state & ODS_DISABLED ) {
clrFront = di.clrDisabled;
clrBack = di.clrBack;
}
else if( di.state & ODS_SELECTED ) {
clrFront = di.clrSelText;
clrBack = di.clrSelBack;
}
else {
clrFront = di.clrText;
clrBack = di.clrBack;
}
RECT rcItem = di.rcItem;
dc.FillSolidRect(&rcItem, clrBack);
rcItem.left += 2; // Indent text
dc.SetBkMode(TRANSPARENT);
dc.SetBkColor(clrBack);
dc.SetTextColor(clrFront);
dc.DrawText(m_pszName, -1, &rcItem, DT_LEFT | DT_SINGLELINE | DT_EDITCONTROL | DT_NOPREFIX | DT_VCENTER);
}
virtual void DrawValue(PROPERTYDRAWINFO& /*di*/)
{
}
virtual HWND CreateInplaceControl(HWND /*hWnd*/, const RECT& /*rc*/)
{
return NULL;
}
virtual BOOL Activate(UINT /*action*/, LPARAM /*lParam*/)
{
return TRUE;
}
virtual BOOL GetDisplayValue(LPTSTR /*pstr*/, UINT /*cchMax*/) const
{
return FALSE;
}
virtual UINT GetDisplayValueLength() const
{
return 0;
}
virtual BOOL GetValue(VARIANT* /*pValue*/) const
{
return FALSE;
}
virtual BOOL SetValue(const VARIANT& /*value*/)
{
ATLASSERT(false);
return FALSE;
}
virtual BOOL SetValue(HWND /*hWnd*/)
{
ATLASSERT(false);
return FALSE;
}
};
/////////////////////////////////////////////////////////////////////////////
// Simple property (displays text)
class CPropertyItem : public CProperty
{
protected:
CComVariant m_val;
public:
CPropertyItem(LPCTSTR pstrName, LPARAM lParam) : CProperty(pstrName, lParam)
{
}
BYTE GetKind() const
{
return PROPKIND_SIMPLE;
}
void DrawValue(PROPERTYDRAWINFO& di)
{
UINT cchMax = GetDisplayValueLength() + 1;
LPTSTR pszText = (LPTSTR) _alloca(cchMax * sizeof(TCHAR));
ATLASSERT(pszText);
if( !GetDisplayValue(pszText, cchMax) ) return;
CDCHandle dc(di.hDC);
dc.SetBkMode(TRANSPARENT);
dc.SetTextColor(di.state & ODS_DISABLED ? di.clrDisabled : di.clrText);
dc.SetBkColor(di.clrBack);
RECT rcText = di.rcItem;
rcText.left += PROP_TEXT_INDENT;
dc.DrawText(pszText, -1,
&rcText,
DT_LEFT | DT_SINGLELINE | DT_EDITCONTROL | DT_NOPREFIX | DT_END_ELLIPSIS | DT_VCENTER);
}
BOOL GetDisplayValue(LPTSTR pstr, UINT cchMax) const
{
ATLASSERT(!::IsBadStringPtr(pstr, cchMax));
// Convert VARIANT to string and use that as display string...
CComVariant v;
if( FAILED( v.ChangeType(VT_BSTR, &m_val) ) ) return FALSE;
USES_CONVERSION;
::lstrcpyn(pstr, OLE2CT(v.bstrVal), cchMax);
return TRUE;
}
UINT GetDisplayValueLength() const
{
// Hmm, need to convert it to display string first and
// then take the length...
// TODO: Call GetDisplayValue() instead...
CComVariant v;
if( FAILED( v.ChangeType(VT_BSTR, &m_val) ) ) return 0;
return v.bstrVal == NULL ? 0 : ::lstrlenW(v.bstrVal);
}
BOOL GetValue(VARIANT* pVal) const
{
return SUCCEEDED( CComVariant(m_val).Detach(pVal) );
}
BOOL SetValue(const VARIANT& value)
{
m_val = value;
return TRUE;
}
};
/////////////////////////////////////////////////////////////////////////////
// ReadOnly property (enhanced display feature)
class CPropertyReadOnlyItem : public CPropertyItem
{
protected:
UINT m_uStyle;
HICON m_hIcon;
COLORREF m_clrBack;
COLORREF m_clrText;
public:
CPropertyReadOnlyItem(LPCTSTR pstrName, LPARAM lParam) :
CPropertyItem(pstrName, lParam),
m_uStyle( DT_LEFT | DT_SINGLELINE | DT_EDITCONTROL | DT_NOPREFIX | DT_END_ELLIPSIS | DT_VCENTER ),
m_clrBack( (COLORREF) -1 ),
m_clrText( (COLORREF) -1 ),
m_hIcon(NULL)
{
}
void DrawValue(PROPERTYDRAWINFO& di)
{
// Get property text
UINT cchMax = GetDisplayValueLength() + 1;
LPTSTR pszText = (LPTSTR) _alloca(cchMax * sizeof(TCHAR));
ATLASSERT(pszText);
if( !GetDisplayValue(pszText, cchMax) ) return;
// Prepare paint
RECT rcText = di.rcItem;
CDCHandle dc(di.hDC);
dc.SetBkMode(OPAQUE);
// Set background color
COLORREF clrBack = di.clrBack;
if( m_clrBack != (COLORREF) -1 ) clrBack = m_clrBack;
dc.SetBkColor(clrBack);
// Set text color
COLORREF clrText = di.clrText;
if( m_clrText != (COLORREF) -1 ) clrText = m_clrText;
if( di.state & ODS_DISABLED ) clrText = di.clrDisabled;
dc.SetTextColor(clrText);
// Draw icon if available
if( m_hIcon ) {
POINT pt = { rcText.left + 2, rcText.top + 2 };
SIZE sz = { ::GetSystemMetrics(SM_CXSMICON), ::GetSystemMetrics(SM_CYSMICON) };
::DrawIconEx(dc, pt.x, pt.y, m_hIcon, sz.cx, sz.cy, 0, NULL, DI_NORMAL);
rcText.left += sz.cx + 4;
}
// Draw text with custom style
rcText.left += PROP_TEXT_INDENT;
dc.DrawText(pszText, -1,
&rcText,
m_uStyle);
}
// Operations
// NOTE: To use these methods, you must cast the HPROPERTY
// handle back to the CPropertyReadOnlyItem class.
// Nasty stuff, but so far I've settled with this approach.
COLORREF SetBkColor(COLORREF clrBack)
{
COLORREF clrOld = m_clrBack;
m_clrBack = clrBack;
return clrOld;
}
COLORREF SetTextColor(COLORREF clrText)
{
COLORREF clrOld = m_clrText;
m_clrText = clrText;
return clrOld;
}
HICON SetIcon(HICON hIcon)
{
HICON hOldIcon = m_hIcon;
m_hIcon = hIcon;
return hOldIcon;
}
void ModifyDrawStyle(UINT uRemove, UINT uAdd)
{
m_uStyle = (m_uStyle & ~uRemove) | uAdd;
}
};
/////////////////////////////////////////////////////////////////////////////
// Simple Value property
class CPropertyEditItem : public CPropertyItem
{
protected:
HWND m_hwndEdit;
public:
CPropertyEditItem(LPCTSTR pstrName, LPARAM lParam) :
CPropertyItem(pstrName, lParam),
m_hwndEdit(NULL)
{
}
BYTE GetKind() const
{
return PROPKIND_EDIT;
}
HWND CreateInplaceControl(HWND hWnd, const RECT& rc)
{
// Get default text
UINT cchMax = GetDisplayValueLength() + 1;
LPTSTR pszText = (LPTSTR) _alloca(cchMax * sizeof(TCHAR));
ATLASSERT(pszText);
if( !GetDisplayValue(pszText, cchMax) ) return NULL;
// Create EDIT control
CPropertyEditWindow* win = new CPropertyEditWindow();
ATLASSERT(win);
RECT rcWin = rc;
m_hwndEdit = win->Create(hWnd, rcWin, pszText, WS_VISIBLE | WS_CHILD | ES_LEFT | ES_AUTOHSCROLL);
ATLASSERT(::IsWindow(m_hwndEdit));
// Simple hack to validate numbers
switch( m_val.vt ) {
case VT_UI1:
case VT_UI2:
case VT_UI4:
win->ModifyStyle(0, ES_NUMBER);
}
return m_hwndEdit;
}
BOOL SetValue(const VARIANT& value)
{
if( m_val.vt == VT_EMPTY ) m_val = value;
return SUCCEEDED( m_val.ChangeType(m_val.vt, &value) );
}
BOOL SetValue(HWND hWnd)
{
ATLASSERT(::IsWindow(hWnd));
int len = ::GetWindowTextLength(hWnd) + 1;
LPTSTR pstr = (LPTSTR) _alloca(len * sizeof(TCHAR));
ATLASSERT(pstr);
if( ::GetWindowText(hWnd, pstr, len) == 0 ) {
// Bah, an empty string AND an error causes the same return code!
if( ::GetLastError() != 0 ) return FALSE;
}
CComVariant v = pstr;
return SetValue(v);
}
BOOL Activate(UINT action, LPARAM /*lParam*/)
{
switch( action ) {
case PACT_TAB:
case PACT_SPACE:
case PACT_DBLCLICK:
if( ::IsWindow(m_hwndEdit) ) {
::SetFocus(m_hwndEdit);
::SendMessage(m_hwndEdit, EM_SETSEL, 0, -1);
}
break;
}
return TRUE;
}
};
/////////////////////////////////////////////////////////////////////////////
// Simple Value property
class CPropertyDateItem : public CPropertyEditItem
{
public:
CPropertyDateItem(LPCTSTR pstrName, LPARAM lParam) :
CPropertyEditItem(pstrName, lParam)
{
}
HWND CreateInplaceControl(HWND hWnd, const RECT& rc)
{
// Get default text
UINT cchMax = GetDisplayValueLength() + 1;
LPTSTR pszText = (LPTSTR) _alloca(cchMax * sizeof(TCHAR));
ATLASSERT(pszText);
if( !GetDisplayValue(pszText, cchMax) ) return NULL;
// Create window
CPropertyDateWindow* win = new CPropertyDateWindow();
ATLASSERT(win);
RECT rcWin = rc;
m_hwndEdit = win->Create(hWnd, rcWin, pszText);
ATLASSERT(win->IsWindow());
return *win;
}
BOOL GetDisplayValue(LPTSTR pstr, UINT cchMax) const
{
if( m_val.date == 0.0 ) {
::lstrcpy(pstr, _T(""));
return TRUE;
}
return CPropertyEditItem::GetDisplayValue(pstr, cchMax);
}
BOOL SetValue(const VARIANT& value)
{
if( value.vt == VT_BSTR && ::SysStringLen(value.bstrVal) == 0 ) {
m_val.date = 0.0;
return TRUE;
}
return CPropertyEditItem::SetValue(value);
}
BOOL SetValue(HWND hWnd)
{
if( ::GetWindowTextLength(hWnd) == 0 ) {
m_val.date = 0.0;
return TRUE;
}
return CPropertyEditItem::SetValue(hWnd);
}
};
/////////////////////////////////////////////////////////////////////////////
// Checkmark button
class CPropertyCheckButtonItem : public CProperty
{
protected:
bool m_bValue;
public:
CPropertyCheckButtonItem(LPCTSTR pstrName, bool bValue, LPARAM lParam) :
CProperty(pstrName, lParam),
m_bValue(bValue)
{
}
BYTE GetKind() const
{
return PROPKIND_CHECK;
}
BOOL GetValue(VARIANT* pVal) const
{
return SUCCEEDED( CComVariant(m_bValue).Detach(pVal) );
}
BOOL SetValue(const VARIANT& value)
{
// Set a new value
switch( value.vt ) {
case VT_BOOL:
m_bValue = value.boolVal != VARIANT_FALSE;
return TRUE;
default:
ATLASSERT(false);
return FALSE;
}
}
void DrawValue(PROPERTYDRAWINFO& di)
{
int cxThumb = ::GetSystemMetrics(SM_CXMENUCHECK);
int cyThumb = ::GetSystemMetrics(SM_CYMENUCHECK);
RECT rcMark = di.rcItem;
rcMark.left += 10;
rcMark.right = rcMark.left + cxThumb;
rcMark.top += 2;
if( rcMark.top + cyThumb >= rcMark.bottom ) rcMark.top -= rcMark.top + cyThumb - rcMark.bottom + 1;
rcMark.bottom = rcMark.top + cyThumb;
UINT uState = DFCS_BUTTONCHECK | DFCS_FLAT;
if( m_bValue ) uState |= DFCS_CHECKED;
if( di.state & ODS_DISABLED ) uState |= DFCS_INACTIVE;
::DrawFrameControl(di.hDC, &rcMark, DFC_BUTTON, uState);
}
BOOL Activate(UINT action, LPARAM /*lParam*/)
{
switch( action ) {
case PACT_SPACE:
case PACT_CLICK:
case PACT_DBLCLICK:
if( IsEnabled() ) {
CComVariant v = !m_bValue;
::SendMessage(m_hWndOwner, WM_USER_PROP_CHANGEDPROPERTY, (WPARAM) (VARIANT*) &v, (LPARAM) this);
}
break;
}
return TRUE;
}
};
/////////////////////////////////////////////////////////////////////////////
// FileName property
class CPropertyFileNameItem : public CPropertyItem
{
public:
CPropertyFileNameItem(LPCTSTR pstrName, LPARAM lParam) : CPropertyItem(pstrName, lParam)
{
}
HWND CreateInplaceControl(HWND hWnd, const RECT& rc)
{
// Get default text
TCHAR szText[MAX_PATH] = { 0 };
if( !GetDisplayValue(szText, (sizeof(szText)/sizeof(TCHAR))-1) ) return NULL;
// Create EDIT control
CPropertyButtonWindow* win = new CPropertyButtonWindow();
ATLASSERT(win);
RECT rcWin = rc;
win->m_prop = this;
win->Create(hWnd, rcWin, szText);
ATLASSERT(win->IsWindow());
return *win;
}
BOOL SetValue(const VARIANT& value)
{
ATLASSERT(V_VT(&value)==VT_BSTR);
m_val = value;
return TRUE;
}
BOOL SetValue(HWND /*hWnd*/)
{
// Do nothing... A value should be set on reacting to the button notification.
// In other words: Use SetItemValue() in response to the PLN_BROWSE notification!
return FALSE;
}
BOOL Activate(UINT action, LPARAM /*lParam*/)
{
switch( action ) {
case PACT_SPACE:
case PACT_BROWSE:
case PACT_DBLCLICK:
// Let control owner know
NMPROPERTYITEM nmh = { m_hWndOwner, ::GetDlgCtrlID(m_hWndOwner), PIN_BROWSE, this };
::SendMessage(::GetParent(m_hWndOwner), WM_NOTIFY, nmh.hdr.idFrom, (LPARAM)&nmh);
}
return TRUE;
}
BOOL GetDisplayValue(LPTSTR pstr, UINT cchMax) const
{
ATLASSERT(!::IsBadStringPtr(pstr, cchMax));
*pstr = _T('\0');
if( m_val.bstrVal == NULL ) return TRUE;
// Only display actual filename (strip path)
USES_CONVERSION;
LPCTSTR pstrFileName = OLE2CT(m_val.bstrVal);
LPCTSTR p = pstrFileName;
while( *p ) {
if( *p == _T(':') || *p == _T('\\') ) pstrFileName = p + 1;
p = ::CharNext(p);
}
::lstrcpyn(pstr, pstrFileName, cchMax);
return TRUE;
}
UINT GetDisplayValueLength() const
{
TCHAR szPath[MAX_PATH] = { 0 };
if( !GetDisplayValue(szPath, (sizeof(szPath)/sizeof(TCHAR)) - 1) ) return 0;
return ::lstrlen(szPath);
}
};
/////////////////////////////////////////////////////////////////////////////
// DropDown List property
class CPropertyListItem : public CPropertyItem
{
protected:
CSimpleArray<CComBSTR> m_arrList;
HWND m_hwndCombo;
public:
CPropertyListItem(LPCTSTR pstrName, LPARAM lParam) :
CPropertyItem(pstrName, lParam),
m_hwndCombo(NULL)
{
m_val = -1L;
}
BYTE GetKind() const
{
return PROPKIND_LIST;
}
HWND CreateInplaceControl(HWND hWnd, const RECT& rc)
{
// Get default text
UINT cchMax = GetDisplayValueLength() + 1;
LPTSTR pszText = (LPTSTR) _alloca(cchMax * sizeof(TCHAR));
ATLASSERT(pszText);
if( !GetDisplayValue(pszText, cchMax) ) return NULL;
// Create 'faked' DropDown control
CPropertyListWindow* win = new CPropertyListWindow();
ATLASSERT(win);
RECT rcWin = rc;
m_hwndCombo = win->Create(hWnd, rcWin, pszText);
ATLASSERT(win->IsWindow());
// Add list
USES_CONVERSION;
for( int i = 0; i < m_arrList.GetSize(); i++ ) win->AddItem(OLE2CT(m_arrList[i]));
win->SelectItem(m_val.lVal);
// Go...
return *win;
}
BOOL Activate(UINT action, LPARAM /*lParam*/)
{
switch( action ) {
case PACT_SPACE:
if( ::IsWindow(m_hwndCombo) ) {
// Fake button click...
::SendMessage(m_hwndCombo, WM_COMMAND, MAKEWPARAM(0, BN_CLICKED), 0);
}
break;
case PACT_DBLCLICK:
// Simulate neat VB control effect. DblClick cycles items in list...
// Set value and recycle edit control
if( IsEnabled() ) {
CComVariant v = m_val.lVal + 1;
::SendMessage(m_hWndOwner, WM_USER_PROP_CHANGEDPROPERTY, (WPARAM) (VARIANT*) &v, (LPARAM) this);
}
break;
}
return TRUE;
}
BOOL GetDisplayValue(LPTSTR pstr, UINT cchMax) const
{
ATLASSERT(m_val.vt==VT_I4);
ATLASSERT(!::IsBadStringPtr(pstr, cchMax));
*pstr = _T('\0');
if( m_val.lVal < 0 || m_val.lVal >= m_arrList.GetSize() ) return FALSE;
USES_CONVERSION;
::lstrcpyn( pstr, OLE2CT(m_arrList[m_val.lVal]), cchMax) ;
return TRUE;
}
UINT GetDisplayValueLength() const
{
ATLASSERT(m_val.vt==VT_I4);
if( m_val.lVal < 0 || m_val.lVal >= m_arrList.GetSize() ) return 0;
BSTR bstr = m_arrList[m_val.lVal];
return bstr == NULL ? 0 : ::lstrlenW(bstr);
};
BOOL SetValue(const VARIANT& value)
{
switch( value.vt ) {
case VT_BSTR:
{
m_val = 0;
for( long i = 0; i < m_arrList.GetSize(); i++ ) {
if( ::wcscmp(value.bstrVal, m_arrList[i]) == 0 ) {
m_val = i;
return TRUE;
}
}
return FALSE;
}
break;
default:
// Treat as index into list
if( FAILED( m_val.ChangeType(VT_I4, &value) ) ) return FALSE;
if( m_val.lVal >= m_arrList.GetSize() ) m_val.lVal = 0;
return TRUE;
}
}
BOOL SetValue(HWND hWnd)
{
ATLASSERT(::IsWindow(hWnd));
int len = ::GetWindowTextLength(hWnd) + 1;
LPTSTR pstr = (LPTSTR) _alloca(len * sizeof(TCHAR));
ATLASSERT(pstr);
if( !::GetWindowText(hWnd, pstr, len) ) {
if( ::GetLastError() != 0 ) return FALSE;
}
CComVariant v = pstr;
return SetValue(v);
}
void SetList(LPCTSTR* ppList)
{
ATLASSERT(ppList);
m_arrList.RemoveAll();
while( *ppList ) {
CComBSTR bstr(*ppList);
m_arrList.Add(bstr);
ppList++;
}
if( m_val.lVal == -1 ) m_val = 0;
}
void AddListItem(LPCTSTR pstrText)
{
ATLASSERT(!::IsBadStringPtr(pstrText,-1));
CComBSTR bstr(pstrText);
m_arrList.Add(bstr);
if( m_val.lVal == -1 ) m_val = 0;
}
};
/////////////////////////////////////////////////////////////////////////////
// Boolean property
class CPropertyBooleanItem : public CPropertyListItem
{
public:
CPropertyBooleanItem(LPCTSTR pstrName, LPARAM lParam) : CPropertyListItem(pstrName, lParam)
{
#ifdef IDS_TRUE
TCHAR szBuffer[32];
::LoadString(_Module.GetResourceInstance(), IDS_FALSE, szBuffer, sizeof(szBuffer)/sizeof(TCHAR));
AddListItem(szBuffer);
::LoadString(_Module.GetResourceInstance(), IDS_TRUE, szBuffer, sizeof(szBuffer)/sizeof(TCHAR));
AddListItem(szBuffer);
#else
AddListItem(_T("False"));
AddListItem(_T("True"));
#endif
}
};
/////////////////////////////////////////////////////////////////////////////
// ListBox Control property
class CPropertyComboItem : public CPropertyItem
{
public:
CListBox m_ctrl;
CPropertyComboItem(LPCTSTR pstrName, LPARAM lParam) :
CPropertyItem(pstrName, lParam)
{
}
HWND CreateInplaceControl(HWND hWnd, const RECT& rc)
{
ATLASSERT(::IsWindow(m_ctrl));
// Create window
CPropertyComboWindow* win = new CPropertyComboWindow();
ATLASSERT(win);
RECT rcWin = rc;
win->m_hWndCombo = m_ctrl;
win->Create(hWnd, rcWin);
ATLASSERT(::IsWindow(*win));
return *win;
}
BYTE GetKind() const
{
return PROPKIND_CONTROL;
}
void DrawValue(PROPERTYDRAWINFO& di)
{
RECT rc = di.rcItem;
::InflateRect(&rc, 0, -1);
DRAWITEMSTRUCT dis = { 0 };
dis.hDC = di.hDC;
dis.hwndItem = m_ctrl;
dis.CtlID = m_ctrl.GetDlgCtrlID();
dis.CtlType = ODT_LISTBOX;
dis.rcItem = rc;
dis.itemState = ODS_DEFAULT | ODS_COMBOBOXEDIT;
dis.itemID = m_ctrl.GetCurSel();
dis.itemData = (int) m_ctrl.GetItemData(dis.itemID);
::SendMessage(m_ctrl, OCM_DRAWITEM, dis.CtlID, (LPARAM) &dis);
}
BOOL GetValue(VARIANT* pValue) const
{
CComVariant v = (int) m_ctrl.GetItemData(m_ctrl.GetCurSel());
return SUCCEEDED( v.Detach(pValue) );
}
BOOL SetValue(HWND /*hWnd*/)
{
int iSel = m_ctrl.GetCurSel();
CComVariant v = (int) m_ctrl.GetItemData(iSel);
return SetValue(v);
}
BOOL SetValue(const VARIANT& value)
{
ATLASSERT(value.vt==VT_I4);
for( int i = 0; i < m_ctrl.GetCount(); i++ ) {
if( m_ctrl.GetItemData(i) == (DWORD_PTR) value.lVal ) {
m_ctrl.SetCurSel(i);
return TRUE;
}
}
return FALSE;
}
};
/////////////////////////////////////////////////////////////////////////////
//
// CProperty creators
//
inline HPROPERTY PropCreateVariant(LPCTSTR pstrName, const VARIANT& vValue, LPARAM lParam = 0)
{
CPropertyEditItem* prop = NULL;
ATLTRY( prop = new CPropertyEditItem(pstrName, lParam) );
ATLASSERT(prop);
if( prop ) prop->SetValue(vValue);
return prop;
}
inline HPROPERTY PropCreateSimple(LPCTSTR pstrName, LPCTSTR pstrValue, LPARAM lParam = 0)
{
CComVariant vValue = pstrValue;
return PropCreateVariant(pstrName, vValue, lParam);
}
inline HPROPERTY PropCreateSimple(LPCTSTR pstrName, int iValue, LPARAM lParam = 0)
{
CComVariant vValue = iValue;
return PropCreateVariant(pstrName, vValue, lParam);
}
inline HPROPERTY PropCreateSimple(LPCTSTR pstrName, bool bValue, LPARAM lParam = 0)
{
// NOTE: Converts to integer, since we're using value as an index to dropdown
CComVariant vValue = (int) bValue & 1;
CPropertyBooleanItem* prop = NULL;
ATLTRY( prop = new CPropertyBooleanItem(pstrName, lParam) );
ATLASSERT(prop);
if( prop ) prop->SetValue(vValue);
return prop;
}
inline HPROPERTY PropCreateFileName(LPCTSTR pstrName, LPCTSTR pstrFileName, LPARAM lParam = 0)
{
ATLASSERT(!::IsBadStringPtr(pstrFileName,-1));
CPropertyFileNameItem* prop = NULL;
ATLTRY( prop = new CPropertyFileNameItem(pstrName, lParam) );
ATLASSERT(prop);
if( prop == NULL ) return NULL;
CComVariant vValue = pstrFileName;
prop->SetValue(vValue);
return prop;
}
inline HPROPERTY PropCreateDate(LPCTSTR pstrName, const SYSTEMTIME stValue, LPARAM lParam = 0)
{
IProperty* prop = NULL;
ATLTRY( prop = new CPropertyDateItem(pstrName, lParam) );
ATLASSERT(prop);
if( prop == NULL ) return NULL;
CComVariant vValue;
vValue.vt = VT_DATE;
vValue.date = 0.0; // NOTE: Clears value in case of conversion error below!
if( stValue.wYear > 0 ) ::SystemTimeToVariantTime( (LPSYSTEMTIME) &stValue, &vValue.date );
prop->SetValue(vValue);
return prop;
}
inline HPROPERTY PropCreateList(LPCTSTR pstrName, LPCTSTR* ppList, int iValue = 0, LPARAM lParam = 0)
{
ATLASSERT(ppList);
CPropertyListItem* prop = NULL;
ATLTRY( prop = new CPropertyListItem(pstrName, lParam) );
ATLASSERT(prop);
if( prop && ppList ) {
prop->SetList(ppList);
CComVariant vValue = iValue;
prop->SetValue(vValue);
}
return prop;
}
inline HPROPERTY PropCreateComboControl(LPCTSTR pstrName, HWND hWnd, int iValue, LPARAM lParam = 0)
{
ATLASSERT(::IsWindow(hWnd));
CPropertyComboItem* prop = NULL;
ATLTRY( prop = new CPropertyComboItem(pstrName, lParam) );
ATLASSERT(prop);
if( prop ) {
prop->m_ctrl = hWnd;
CComVariant vValue = iValue;
prop->SetValue(vValue);
}
return prop;
}
inline HPROPERTY PropCreateCheckButton(LPCTSTR pstrName, bool bValue, LPARAM lParam = 0)
{
return new CPropertyCheckButtonItem(pstrName, bValue, lParam);
}
inline HPROPERTY PropCreateReadOnlyItem(LPCTSTR pstrName, LPCTSTR pstrValue = _T(""), LPARAM lParam = 0)
{
ATLASSERT(!::IsBadStringPtr(pstrValue,-1));
CPropertyItem* prop = NULL;
ATLTRY( prop = new CPropertyReadOnlyItem(pstrName, lParam) );
ATLASSERT(prop);
if( prop ) {
CComVariant v = pstrValue;
prop->SetValue(v);
}
return prop;
}
#endif // __PROPERTYITEMIMPL__H
|
[
"hydra@b2473a34-e2c4-0310-847b-bd686bddb4b0"
] |
[
[
[
1,
895
]
]
] |
fd7645ca0b4c2c9a37bcab52f3054daf6d17b948
|
d37a1d5e50105d82427e8bf3642ba6f3e56e06b8
|
/DVR/HaohanITPlayer/public/Common/SysUtils/UTimecodeUtil.h
|
be362bfafb3b6f8778de0a7886b4dc223741614a
|
[] |
no_license
|
080278/dvrmd-filter
|
176f4406dbb437fb5e67159b6cdce8c0f48fe0ca
|
b9461f3bf4a07b4c16e337e9c1d5683193498227
|
refs/heads/master
| 2016-09-10T21:14:44.669128 | 2011-10-17T09:18:09 | 2011-10-17T09:18:09 | 32,274,136 | 0 | 0 | null | null | null | null |
UTF-8
|
C++
| false | false | 916 |
h
|
//-----------------------------------------------------------------------------
// UTimecodeUtil.h
// Copyright (c) 1997 - 2004, Haohanit. All rights reserved.
//-----------------------------------------------------------------------------
/*
File: UTimecodeUtil.h
Contains:
Written by:
Change History (most recent first):
x.x.x spg Initial file creation.
*/
//SR FS: Reviewed [JAW 20040912]
//SR FS: Reviewed [wwt 20040915]: safe input param; no MBCS; no dangerous API; no registry/sys folder/temp file
#ifndef __UTimecodeUtil_h
#define __UTimecodeUtil_h
#include <string>
namespace UTimecodeUtil
{
double StringToTimecode(const std::string &inString, bool isNTSC=true, bool dropFrameMode=false, bool useFract=false);
void TimecodeToString(double timecode, std::string &outString, bool isNTSC=true, bool dropFrameMode=false, bool useFract=false);
}
#endif
|
[
"[email protected]@27769579-7047-b306-4d6f-d36f87483bb3"
] |
[
[
[
1,
31
]
]
] |
3ae631265a75110e2938d329202613270f027b39
|
d9a78f212155bb978f5ac27d30eb0489bca87c3f
|
/PB/src/PbLib/pbtable.cpp
|
2a052651a988393a85dc960808284859c4141919
|
[] |
no_license
|
marchon/pokerbridge
|
1ed4a6a521f8644dcd0b6ec66a1ac46879b8473c
|
97d42ef318bf08f3bc0c0cb1d95bd31eb2a3a8a9
|
refs/heads/master
| 2021-01-10T07:15:26.496252 | 2010-05-17T20:01:29 | 2010-05-17T20:01:29 | 36,398,892 | 0 | 0 | null | null | null | null |
UTF-8
|
C++
| false | false | 511 |
cpp
|
#include "stdafx.h"
#include "pbtable.h"
#include "pbseatedplayer.h"
#include "pbseats.h"
PBTable::PBTable(QObject *parent) : QObject(parent)
{
setSeats(new PBSeats(this));
}
PBHandId PBTable::handId()
{
return _handId;
}
void PBTable::setHandId(const PBHandId &handId)
{
_handId = handId;
}
PBSeats *PBTable::seats()
{
return _seats;
}
void PBTable::setSeats(PBSeats *seats)
{
_seats = seats;
}
PBGameOptions &PBTable::gameOptions()
{
return _gameOptions;
}
|
[
"[email protected]",
"mikhail.mitkevich@a5377438-2eb2-11df-b28a-19025b8c0740"
] |
[
[
[
1,
6
],
[
8,
28
],
[
30,
32
],
[
38,
38
]
],
[
[
7,
7
],
[
29,
29
],
[
33,
37
]
]
] |
717fe5dd9de179dbcc60e54a36c183d945b94ad1
|
e7bda3446c387088350cad477c90cac4f3f2b3bf
|
/Freedom/source/FPad.cpp
|
83fccb262628731d3581ae8c6f053ad519d13463
|
[] |
no_license
|
MathewWi/freedom-wii
|
260abe88f0fe147eb163c8d78818866a86c7cd9f
|
9d4957cd6fa443a5e4365f4cd4f5e0108962f4c7
|
refs/heads/master
| 2021-01-10T20:18:40.893079 | 2009-12-30T02:32:56 | 2009-12-30T02:32:56 | 32,203,986 | 1 | 0 | null | null | null | null |
UTF-8
|
C++
| false | false | 6,546 |
cpp
|
/*
Freedom - A system menu replacement for Nintendo Wii
Copyright (C) 2008-2009 crediar
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation version 2.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include "FPad.h"
//#define FPAD_DEBUG
extern "C"
{
#include "misc.h"
}
u32 WPADDown[4];
u32 PADDown[4];
u32 WPADHeld[4];
u32 PADHeld[4];
u32 WPADUp[4];
u32 PADUp[4];
u32 WButtonMap[10]={0};
u32 CButtonMap[10]={0};
u32 PButtonMap[10]={0};
WiimoteNames WiimoteName[] = {
{ "A", WPAD_BUTTON_A },
{ "B", WPAD_BUTTON_B },
{ "Up", WPAD_BUTTON_UP },
{ "Down", WPAD_BUTTON_DOWN },
{ "Left", WPAD_BUTTON_LEFT },
{ "Right", WPAD_BUTTON_RIGHT },
{ "1", WPAD_BUTTON_1 },
{ "2", WPAD_BUTTON_2 },
{ "Plus", WPAD_BUTTON_PLUS },
{ "Minus", WPAD_BUTTON_MINUS },
{ "Home", WPAD_BUTTON_HOME },
};
s32 FPad_Init( void )
{
s32 r = PAD_Init();
#ifdef FPAD_DEBUG
gprintf("PAD_Init():%d\n", r);
if( r < 0 )
return r;
#endif
r = WPAD_Init();
#ifdef FPAD_DEBUG
gprintf("WPAD_Init():%d\n", r);
if( r < 0 )
return r;
#endif
r = WPAD_SetDataFormat(WPAD_CHAN_0, WPAD_FMT_BTNS_ACC_IR);
#ifdef FPAD_DEBUG
gprintf("WPAD_SetDataFormat():%d\n", r);
if( r < 0 )
return r;
#endif
WPAD_SetIdleTimeout(60);
//Add loading from file code!
WButtonMap[LEFT] = WPAD_BUTTON_LEFT;
CButtonMap[LEFT] = WPAD_CLASSIC_BUTTON_LEFT;
PButtonMap[LEFT] = PAD_BUTTON_LEFT;
WButtonMap[RIGHT] = WPAD_BUTTON_RIGHT;
CButtonMap[RIGHT] = WPAD_CLASSIC_BUTTON_RIGHT;
PButtonMap[RIGHT] = PAD_BUTTON_RIGHT;
WButtonMap[DOWN] = WPAD_BUTTON_DOWN;
CButtonMap[DOWN] = WPAD_CLASSIC_BUTTON_DOWN;
PButtonMap[DOWN] = PAD_BUTTON_DOWN;
WButtonMap[UP] = WPAD_BUTTON_UP;
CButtonMap[UP] = WPAD_CLASSIC_BUTTON_UP;
PButtonMap[UP] = PAD_BUTTON_UP;
WButtonMap[OK] = WPAD_BUTTON_A;
CButtonMap[OK] = WPAD_CLASSIC_BUTTON_A;
PButtonMap[OK] = PAD_BUTTON_A;
WButtonMap[CANCEL] = WPAD_BUTTON_B;
CButtonMap[CANCEL] = WPAD_CLASSIC_BUTTON_B;
PButtonMap[CANCEL] = PAD_BUTTON_B;
WButtonMap[START] = WPAD_BUTTON_HOME;
CButtonMap[START] = WPAD_CLASSIC_BUTTON_HOME;
PButtonMap[START] = PAD_BUTTON_START;
WButtonMap[SPECIAL_1] = WPAD_BUTTON_1;
CButtonMap[SPECIAL_1] = WPAD_CLASSIC_BUTTON_X;
PButtonMap[SPECIAL_1] = PAD_BUTTON_X;
return 1;
}
s32 FPad_LoadMapping( void )
{
FILE *f=fopen("sd:/freedom/mapping.bin", "rb" );
if( f == NULL )
return -1;
fread( WButtonMap, sizeof(u32), 10, f );
fread( CButtonMap, sizeof(u32), 10, f );
fread( PButtonMap, sizeof(u32), 10, f );
fclose( f );
return 1;
}
s32 FPad_SaveMapping( void )
{
FILE *f=fopen("sd:/freedom/mapping.bin", "wb" );
if( f == NULL )
return -1;
fwrite( WButtonMap, sizeof(u32), 10, f );
fwrite( CButtonMap, sizeof(u32), 10, f );
fwrite( PButtonMap, sizeof(u32), 10, f );
fclose( f );
return 1;
}
s32 FPad_Update( void )
{
WPAD_ScanPads();
PAD_ScanPads();
for( u32 i=0; i<4; ++i )
{
WPADDown[i] = WPAD_ButtonsDown(i);
WPADHeld[i] = WPAD_ButtonsHeld(i);
WPADUp[i] = WPAD_ButtonsUp(i);
PADDown[i] = PAD_ButtonsDown(i);
PADHeld[i] = PAD_ButtonsHeld(i);
PADUp[i] = PAD_ButtonsUp(i);
}
return 1;
}
u32 FPad_IsPressed( u32 Channel, u32 ButtonMask )
{
u32 value=0;
for( u32 i=0; i < 8; ++i)
{
u32 bit = Channel&(1<<i);
switch( bit )
{
case WPAD_CHANNEL_0:
value |= WPADDown[0];
break;
case WPAD_CHANNEL_1:
value |= WPADDown[1];
break;
case WPAD_CHANNEL_2:
value |= WPADDown[2];
break;
case WPAD_CHANNEL_3:
value |= WPADDown[3];
break;
case WPAD_CHANNEL_ALL:
for( u32 i=0; i<4; ++i )
value |= WPADDown[i];
break;
case PAD_CHANNEL_0:
value |= PADDown[0];
break;
case PAD_CHANNEL_1:
value |= PADDown[1];
break;
case PAD_CHANNEL_2:
value |= PADDown[2];
break;
case PAD_CHANNEL_3:
value |= PADDown[3];
break;
case PAD_CHANNEL_ALL:
for( u32 i=0; i<4; ++i )
value |= PADDown[i];
break;
//case CHANNEL_ALL:
// for( u32 i=0; i<4; ++i )
// {
// value |= WPADDown[i];
// value |= PADDown[i];
// }
// break;
}
}
return (bool)(value & ButtonMask);
}
u32 FPad_Pressed( u32 Button )
{
if( Button >= SPECIAL_4 )
return 0;
return FPad_IsPressed( WPAD_CHANNEL_ALL, WButtonMap[Button]|CButtonMap[Button] ) |
FPad_IsPressed( PAD_CHANNEL_ALL, PButtonMap[Button] );
}
void FPad_ClearButtonMapping( u32 Controller )
{
if( Controller > 3 )
return;
for( u32 i=0; i < 10; ++i )
{
switch( Controller )
{
case 0:
WButtonMap[i] = 0;
break;
case 1:
CButtonMap[i] = 0;
break;
case 2:
PButtonMap[i] = 0;
break;
}
}
}
u32 FPadGetButtonMapping( u32 Controller, u32 Button )
{
if( Controller > 3 )
return 0;
for( u32 i=0; i < 10; ++i )
{
switch( Controller )
{
case 0:
if( WButtonMap[i] == Button )
return i;
break;
case 1:
if( CButtonMap[i] == Button )
return i;
break;
case 2:
if( PButtonMap[i] == Button )
return i;
break;
}
}
return 0xFFFF;
}
u32 FPadSetButtonMapping( u32 Controller, u32 Button, u32 FButton )
{
if( Controller > 3 )
return 0;
switch( Controller )
{
case 0:
WButtonMap[FButton] = Button;
break;
case 1:
CButtonMap[FButton] = Button;
break;
case 2:
PButtonMap[FButton] = Button;
break;
}
return 0;
}
char *FPadGetButtonName( u32 Button )
{
switch( Button )
{
case OK:
return (char*)"OK";
case CANCEL:
return (char*)"Cancel";
case UP:
return (char*)"Up";
case DOWN:
return (char*)"Down";
case LEFT:
return (char*)"Left";
case RIGHT:
return (char*)"Right";
case START:
return (char*)"Home";
case SPECIAL_1:
return (char*)"Play/Pause";
default:
return (char*)"Unmapped";
}
return NULL;
}
|
[
"[email protected]@165ff104-ec95-11de-9229-05bbbb8527c3"
] |
[
[
[
1,
330
]
]
] |
bdd2f17d55f57f14abb79647e7f8588a9fdde062
|
cfb0fafddd1df76e22b1b4212ba9102693f100fa
|
/Kernel/USBRemover/ApiWrapper.cpp
|
d0c7b72bdabfe49524bd605a58fcb8e6f8891d43
|
[] |
no_license
|
ExaByt3s/usbremover
|
ef8fecc6030d23f178c2cd50dbc5557e06c42322
|
13a6b6802a2f968d6cf923fd1821b03999292d5e
|
refs/heads/master
| 2020-04-11T14:48:34.107832 | 2011-04-09T07:51:39 | 2011-04-09T07:51:39 | null | 0 | 0 | null | null | null | null |
UTF-8
|
C++
| false | false | 24,398 |
cpp
|
/*
ApiWrapper.cpp
Started: 21.05.2010
Author: Asha'man
Email: [email protected]
License: LGPL v3 <?>
Implementation of wrapper for Windows API functions
*/
#include "ApiWrapper.h"
//Internal constants
const DWORD SIZE_MAGIC_VALUE = (DWORD)5; //magic value needed in some functions
const LPTSTR VOLNAME_MASK = _T("\\\\.\\%s"); //mask for the volume name
const TCHAR QUESTION_TAG = _T('?'); //question tag used as separator
const TCHAR VOLUME_SEPARATOR = _T('.'); //subsitution for question tag in volume name
const int SEPARATOR_POS = (int)2; //separator position
const int VOLUME_OFFSET = (int)4; //offset for the volume name
const LPTSTR FLOPPY_DOS = _T("\\Device\\Floppy"); //floppy device pattern
const LPTSTR FLOPPY_WIN = _T("\\\\?\\fdc#"); //floppy windows manager pattern
const TCHAR EOLN = _T('\0'); //string separator
/*
Purpose:
Get the handle for the device information set
Parameters:
classGUID - the GUID of the device class
flags - filter for the device
Return value:
Handle to the device information set (see MSDN for further info)
Verified 27.05.2010 by Asha'man
*/
HANDLE WINAPI GetDeviceInformationSet(GUID classGUID, DWORD flags)
{
return SetupDiGetClassDevs(&classGUID, NULL, 0, flags);
} //GetDeviceInformationSet
/*
Purpose:
Get the device string identifier by the device's instance handle
Parameters:
instanceHandle - handle of the device in the device information set
Return value:
A C-string which represents the device's ID in the system
Throws:
WinAPI exception
Verified 27.05.2010 by Asha'man
*/
LPTSTR WINAPI GetDeviceId(HANDLE instanceHandle)
{
//allocate new memory + 1 for zero
LPTSTR idBuffer = NULL;
//get device ID by its device handle in the device information set
try
{
idBuffer = new TCHAR[MAX_PATH+1];
if (CM_Get_Device_ID((DEVINST)instanceHandle, idBuffer, MAX_PATH, ZERO_FLAGS) != CR_SUCCESS)
{
throw WinAPIException(GetLastError());
}
}
catch (...)
{
DELARRAY(idBuffer);
#ifdef DEBUG
_ASSERT(idBuffer == NULL);
#endif
throw;
}
return idBuffer;
}
/*
Purpose:
Get the device information by its instance handle in the device
information set
Parameters:
idString - string which stores the device ID
setHandle - handle of the device information set
Return value:
An SP_DEVINFO_DATA structure which defines the device instance that
is a member of the specified device information set.
Verified 27.05.2010 by Asha'man
*/
SP_DEVINFO_DATA WINAPI GetDeviceInformation(PTCHAR idString, HANDLE setHandle)
{
SP_DEVINFO_DATA result;
//set result size
result.cbSize = sizeof(result);
//opening device information
try
{
if (!SetupDiOpenDeviceInfo(setHandle, idString, 0, ZERO_FLAGS, &result))
{
throw WinAPIException(GetLastError());
}
}
catch(...)
{
throw;
}
return result;
} //GetDeviceInformation
/*
Purpose:
Get the device information by its instance handle in the device
information set and save it to the cache
Parameters:
instanceHandle - handle of the device in the device information set
setHandle - handle of the device information set
Return value:
A DeviceDataSet cache with all the necessary devices
Verified 27.05.2010 by Asha'man
Fixed 11.08.2010 by Asha'man
*/
DeviceDataSet WINAPI
GetDeviceInformationCache(GUID classGUID, HANDLE setHandle)
{
//TO BE FOUND
SP_DEVINFO_DATA deviceData; //information about the device
DeviceDataSet dataSet; //device data set to be returned
//AUXILIARY DATA
DWORD index = 0; //index of the current element
SP_DEVICE_INTERFACE_DATA deviceInterfaceData; //information about the device interface
PSP_DEVICE_INTERFACE_DETAIL_DATA deviceInterfaceDetailData; //interface details
DWORD difaceBufferSize; //size of the device interface detail structure
DWORD dwSize = 0; //variable needed for function call. Indicates the size required for
//the structure
try
{
deviceInterfaceData.InterfaceClassGuid = classGUID;
deviceInterfaceData.cbSize = sizeof(deviceInterfaceData);
//iteration over the device information set
while (SetupDiEnumDeviceInterfaces((HDEVINFO)setHandle, NULL, &classGUID,
index, &deviceInterfaceData))
{
//prepare for the function call
deviceData.cbSize = sizeof(deviceData);
/*
fixed 11.08.2010 - from MSDN pages
*/
deviceInterfaceDetailData = (PSP_DEVICE_INTERFACE_DETAIL_DATA)
(new BYTE[sizeof(SP_DEVICE_INTERFACE_DETAIL_DATA)]);
//deviceInterfaceDetailData->cbSize =
// offsetof(SP_DEVICE_INTERFACE_DETAIL_DATA, DevicePath) + sizeof(TCHAR);
difaceBufferSize = sizeof(SP_DEVICE_INTERFACE_DETAIL_DATA);
deviceInterfaceDetailData->cbSize = difaceBufferSize;
/*
Short description of SetupDiGetDeviceInterfaceDetail parameters
Taken from MSDN
DeviceInfoSet
A pointer to the device information set that contains the
interface for which to retrieve details
DeviceInterfaceData
A pointer to an SP_DEVICE_INTERFACE_DATA structure that specifies
the interface in DeviceInfoSet for which to retrieve details
DeviceInterfaceDetailData
A pointer to an SP_DEVICE_INTERFACE_DETAIL_DATA structure
to receive information about the specified interface
DeviceInterfaceDetailDataSize
The size of the DeviceInterfaceDetailData buffer. The buffer must be
at least (offsetof(SP_DEVICE_INTERFACE_DETAIL_DATA, DevicePath) + sizeof(TCHAR))
bytes
RequiredSize
A pointer to a variable of type DWORD that receives the required size of the
DeviceInterfaceDetailData buffer
DeviceInfoData
A pointer buffer to receive information about the device that supports the
requested interface
*/
if (!SetupDiGetDeviceInterfaceDetail((HDEVINFO)setHandle, &deviceInterfaceData,
deviceInterfaceDetailData, difaceBufferSize, &dwSize, &deviceData))
{
//buffer is too small to contain data
//calling function again
if (GetLastError() == ERROR_INSUFFICIENT_BUFFER)
{
/*
Fixed 11.08.2010 by Asha'man
Magic value is no more needed
*/
difaceBufferSize = dwSize;
//reallocating memory for data
DELARRAY(deviceInterfaceDetailData);
#ifdef DEBUG
_ASSERT(deviceInterfaceDetailData == NULL);
#endif
deviceInterfaceDetailData = (PSP_DEVICE_INTERFACE_DETAIL_DATA)
(new BYTE[dwSize]);
deviceInterfaceDetailData->cbSize = sizeof(SP_DEVICE_INTERFACE_DETAIL_DATA);
//offsetof(SP_DEVICE_INTERFACE_DETAIL_DATA, DevicePath) + sizeof(TCHAR);
//call it again
if (!SetupDiGetDeviceInterfaceDetail((HDEVINFO)setHandle, &deviceInterfaceData,
deviceInterfaceDetailData, difaceBufferSize, &dwSize, &deviceData))
{
throw WinAPIException(GetLastError());
}
}
else
{
throw WinAPIException(GetLastError());
}
}
//Fixed 11.08.2010 by Asha'man - avoid floppy drives
if (_tcsstr(deviceInterfaceDetailData->DevicePath, FLOPPY_WIN) == NULL)
{
//open the device as a file
HANDLE deviceHandle = CreateFile(deviceInterfaceDetailData->DevicePath,
GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING,
ZERO_FLAGS, ZERO_HANDLE);
if (deviceHandle == INVALID_HANDLE_VALUE)
{
throw WinAPIException(GetLastError());
}
else
{
//get device DeviceNumber and PartitionNumber in order to
//obtain a key for the map
//cache the obtained information
STORAGE_DEVICE_NUMBER deviceNumber;
try
{
deviceNumber = GetDeviceNumber(deviceHandle);
dataSet.insert(DeviceDataSet::value_type(
std::make_pair(deviceNumber.DeviceNumber,
deviceNumber.PartitionNumber),deviceData));
}
//if WinAPIExcwption - that means that some problems occured
//with getting device number
catch(WinAPIException&)
{
}
catch(...)
{
throw;
}
//close the handle after all
CloseHandle(deviceHandle);
}
}
/*
Fixed by Asha'man 11.08.2010
*/
DELARRAY(deviceInterfaceDetailData);
#ifdef DEBUG
_ASSERT(deviceInterfaceDetailData == NULL);
#endif
++index;
}
}
catch (...)
{
DELARRAY(deviceInterfaceDetailData);
#ifdef DEBUG
_ASSERT(deviceInterfaceDetailData == NULL);
#endif
throw;
}
return dataSet;
}
/*
Purpose:
Get the device number via DeviceIoControl
Parameters:
fileHandle - handle of the device (got by CreateFile)
Return value:
The STORAGE_DEVICE_NUMBER structure. It is used in conjunction
with the IOCTL_STORAGE_GET_DEVICE_NUMBER request to retrieve
the FILE_DEVICE_XXX device type, the device number, and,
for a device that can be partitioned, the partition number
assigned to a device by the driver when the device is started.
See MSDN for further information
Verified 27.05.2010 by Asha'man
Tested 27.05.2010 - Works correctly
*/
STORAGE_DEVICE_NUMBER WINAPI GetDeviceNumber(HANDLE fileHandle)
{
STORAGE_DEVICE_NUMBER result;
DWORD dummy;
try
{
//call DeviceIoControl with the parameter IOCTL_STORAGE_GET_DEVICE_NUMBER
if (!DeviceIoControl(fileHandle, IOCTL_STORAGE_GET_DEVICE_NUMBER, NULL, 0,
(LPVOID)&result, sizeof(result), &dummy, NULL))
{
throw WinAPIException(GetLastError());
}
}
catch(...)
{
throw;
}
return result;
} //GetDeviceNumber
/*
Purpose:
Get the bus type for the specified device
Parameters:
path - Path do the device
Return value
Member of the enumeration STORAGE_BUS_TYPE
Verified 27.05.2010 by Asha'man
Tested 27.05.2010 - Works correctly
*/
STORAGE_BUS_TYPE WINAPI GetBusType(LPTSTR name)
{
//open device as file
LPTSTR path = NULL;
STORAGE_BUS_TYPE result = BusTypeUnknown;
try
{
path = ::FormatDeviceName(name);
HANDLE handle = CreateFile(path, GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE,
NULL, OPEN_EXISTING, ZERO_FLAGS, ZERO_HANDLE);
if (handle == INVALID_HANDLE_VALUE)
{
throw WinAPIException(GetLastError());
}
//define all the necessary parameters for the function call
STORAGE_DEVICE_DESCRIPTOR deviceDescriptor;
STORAGE_PROPERTY_QUERY propertyQuery;
//free memory
ZeroMemory(&deviceDescriptor, sizeof(deviceDescriptor));
ZeroMemory(&propertyQuery, sizeof(propertyQuery));
deviceDescriptor.Size = sizeof(deviceDescriptor);
DWORD dummy;
if (!DeviceIoControl(handle, IOCTL_STORAGE_QUERY_PROPERTY, &propertyQuery, sizeof(propertyQuery),
&deviceDescriptor, sizeof(deviceDescriptor), &dummy, ZERO_FLAGS))
{
CloseHandle(handle);
throw WinAPIException(GetLastError());
}
result = deviceDescriptor.BusType;
//close the handle
CloseHandle(handle);
DELARRAY(path);
#ifdef DEBUG
_ASSERT(path == NULL);
#endif
}
catch(...)
{
DELARRAY(path);
#ifdef DEBUG
_ASSERT(path == NULL);
#endif
throw;
}
return result;
}
/*
Purpose:
Ejection of the device
WARNING: USE ONLY FOR THE USB TOP DEVICE!!!
Parameters:
devInst - device instance handle
Return value:
true
Verified 27.05.2010 by Asha'man
Updated 10.08.2010 by Asha'man
*/
bool WINAPI EjectDevice(DEVINST devInst)
{
//Prepare for the function call
TCHAR vetoName[MAX_PATH+1];
ZeroMemory(&vetoName, sizeof(TCHAR)*(MAX_PATH+1));
//call ejection
CONFIGRET result = CM_Request_Device_Eject(devInst, NULL, vetoName, MAX_PATH, ZERO_FLAGS);
return (result == CR_SUCCESS) && (vetoName[0] == EOLN);
}
/*
Purpose:
Formats the device name to be compatible with the
CreateFile function
Parameters:
devName - C-string representing device name.
It is not affected inside the function
Return value:
A C-string repesenting formatted volume name
Verified 27.05.2010 by Asha'man
Tested 27.05.2010 - Works correctly
*/
LPTSTR FormatDeviceName(LPTSTR devName)
{
LPTSTR result = NULL;
//length of the input
size_t len = _tcslen(devName);
//for volume - copy and format
if (devName[SEPARATOR_POS] == QUESTION_TAG)
{
//allocate new string with length len-1.
//Note: the last is for zero(sz)
result = new TCHAR[len];
//clean memory
ZeroMemory(result, sizeof(TCHAR)*len);
//copy all sympols except the last one
_tcsncpy(result, devName, len-1);
//substitute question tag by the dot
result[SEPARATOR_POS] = VOLUME_SEPARATOR;
}
//for drive - only copy
else
{
result = new TCHAR[len+1];
_tcscpy(result, devName);
}
return result;
}
/*
Purpose:
Formats the volume name to be compatible with
the QueryDOSDevice function
Parameters:
volName - C-string representing volume name
It is not affected inside the function
Return value:
A C-string representing DOS formatted volume name
Verified 27.05.2010 by Asha'man
Tested 27.05.2010 - Works correctly
*/
LPTSTR FormatDOSVolumeName(LPTSTR volName)
{
//string length
size_t len = _tcslen(volName);
//allocate new memory for result
//1 symbol for '\0' - sz
LPTSTR result = new TCHAR[len-VOLUME_OFFSET];
ZeroMemory(result, sizeof(TCHAR)*(len-VOLUME_OFFSET));
//copy the reslut. The last -1 is for trailing backslash
_tcsncpy(result, volName+VOLUME_OFFSET, len-VOLUME_OFFSET-1);
return result;
}
/*
Purpose:
Filters only removable volumes.
Excludes floppies
Parameters:
path - Path to the volume
Return value:
true, if the volume is removable
false, otherwise
Verified 27.05.2010 by Asha'man
Tested 27.05.2010 - Works correctly
*/
bool FilterRemovableVolume(LPTSTR path)
{
//result
bool result = false;
LPTSTR dospath = NULL;
LPTSTR buffer = NULL;
//checking if the volume belongs to the removable drive
try
{
if (GetDriveType(path) == DRIVE_REMOVABLE)
{
//formatting device path
dospath = FormatDOSVolumeName(path);
//allocate buffer
buffer = new TCHAR[MAX_PATH+1];
ZeroMemory(buffer, sizeof(TCHAR)*(MAX_PATH+1));
//get DOS device name to filter floppies
if (!QueryDosDevice(dospath, buffer, MAX_PATH))
{
throw WinAPIException(GetLastError());
}
else
{
//check if it is a floppy drive
if (_tcsstr(buffer, FLOPPY_DOS) == NULL)
{
result = true; //not a floppy drive
}
}
DELARRAY(buffer);
DELARRAY(dospath);
#ifdef DEBUG
_ASSERT(buffer == NULL);
_ASSERT(dospath == NULL);
#endif
}
}
catch(...)
{
DELARRAY(buffer);
DELARRAY(dospath);
#ifdef DEBUG
_ASSERT(buffer == NULL);
_ASSERT(dospath == NULL);
#endif
throw;
}
return result;
}
/*
Purpose:
Gets the volume size (in bytes)
Parameters:
path - Path to the volume
Return value:
A LARGE_INTEGER value representing the volume size
Verified 18.06.2010 by Asha'man
*/
LARGE_INTEGER WINAPI GetVolumeSize(LPTSTR path)
{
GET_LENGTH_INFORMATION lengthInfo;
LPTSTR volName = ::FormatDeviceName(path);
try
{
//Opening device as a file
HANDLE handle = CreateFile(volName, GENERIC_READ, FILE_SHARE_READ |
FILE_SHARE_WRITE, NULL, OPEN_EXISTING, ZERO_FLAGS, ZERO_HANDLE);
if (handle == INVALID_HANDLE_VALUE)
{
throw WinAPIException(GetLastError());
}
else
{
//prepare for the DeviceIoControl call
DWORD dummy;
ZeroMemory(&lengthInfo, sizeof(lengthInfo));
//calling DeviceIoControl for getting disk size
if (!DeviceIoControl(handle, IOCTL_DISK_GET_LENGTH_INFO,
NULL, 0, &lengthInfo, sizeof(lengthInfo), &dummy, ZERO_HANDLE))
{
CloseHandle(handle);
throw WinAPIException(GetLastError());
}
else
{
DELARRAY(volName);
#ifdef DEBUG
_ASSERT(volName == NULL);
#endif
CloseHandle(handle);
}
}
}
catch(...)
{
DELARRAY(volName);
#ifdef DEBUG
_ASSERT(volName == NULL);
#endif
throw;
}
return lengthInfo.Length;
}
/*
Purpose:
Gets the disk number for a volume
Parameters:
path - Path to the volume
Return value:
A DWORD value representing the number of a disk
Verified 18.06.2010 by Asha'man
Tested 18.06.2010 - Works correctly
*/
DWORD WINAPI GetDiskNumber(LPTSTR path)
{
DWORD result;
LPTSTR volName = ::FormatDeviceName(path);
PVOLUME_DISK_EXTENTS extents = (PVOLUME_DISK_EXTENTS)new BYTE[sizeof(VOLUME_DISK_EXTENTS)];
try
{
HANDLE handle = CreateFile(volName, GENERIC_READ, FILE_SHARE_READ |
FILE_SHARE_WRITE, NULL, OPEN_EXISTING, ZERO_FLAGS, ZERO_HANDLE);
if (handle == INVALID_HANDLE_VALUE)
{
throw WinAPIException(GetLastError());
}
else
{
//prepare to call DeviceIoControl
DWORD dummy;
/*
WARNING!!!
There may be some problems with the disk-device extents
because someone can organize a RAID massive on flash
drives - the extents may not be filled
*/
if (!DeviceIoControl(handle, IOCTL_VOLUME_GET_VOLUME_DISK_EXTENTS,
NULL, 0, extents, sizeof(VOLUME_DISK_EXTENTS), &dummy, 0))
{
CloseHandle(handle);
throw WinAPIException(GetLastError());
}
else
{
//return the result
result = extents->Extents[0].DiskNumber;
DELARRAY(extents);
DELARRAY(volName);
#ifdef DEBUG
_ASSERT(extents == NULL);
_ASSERT(volName == NULL);
#endif
CloseHandle(handle);
}
}
}
catch(...)
{
DELARRAY(extents);
DELARRAY(volName);
#ifdef DEBUG
_ASSERT(extents == NULL);
_ASSERT(volName == NULL);
#endif
throw;
}
return result;
}
/*
Purpose:
Gets the volume mount points
Parameters:
path - Path to the volume
Return value:
A C-string vector containing all mount points for the volume
Verified 18.06.2010 by Asha'man
Tested 18.06.2010 - Works correctly
*/
StringList* GetVolumeMountPoints(LPTSTR path)
{
StringList *result = new StringList();
LPTSTR mountPoints = new TCHAR[MAX_PATH+1];
ZeroMemory(mountPoints, sizeof(TCHAR)*(MAX_PATH+1));
DWORD numPoints;
try
{
if (!GetVolumePathNamesForVolumeName(path, mountPoints, MAX_PATH, &numPoints))
{
throw WinAPIException(GetLastError());
}
else
{
LPTSTR pmp = mountPoints;
while (mountPoints[0] != EOLN)
{
LPTSTR buffer = new TCHAR[_tcslen(mountPoints)+1];
_tcscpy(buffer, mountPoints);
result->push_back(buffer);
mountPoints += _tcslen(mountPoints)+1;
}
DELARRAY(pmp);
#ifdef DEBUG
_ASSERT(pmp == NULL);
#endif
}
}
catch(...)
{
DELARRAY(mountPoints);
#ifdef DEBUG
_ASSERT(mountPoints == NULL);
#endif
throw;
}
return result;
}
/*
Purpose:
Gets the specified system information table
Parameters:
tableType - type of the table to get
Return value:
A pointer to the system information table
*/
PVOID GetSystemInformationTable(DWORD tableType)
{
//result buffer
PVOID result = NULL;
//initial buffer size is 32
DWORD bufSize = 32;
//function status
NTSTATUS status;
do
{
//allocating the buffer
result = (PVOID)new BYTE[bufSize];
ZeroMemory(result, bufSize);
//trying to call the function
status = NtQuerySystemInformation((SYSTEMINFOCLASS)tableType, result, bufSize, NULL);
//if buffer is too small, we realloc it
if (status == STATUS_INFO_LENGTH_MISMATCH)
{
DELARRAY(result);
bufSize *= 2;
}
}
while(status == STATUS_INFO_LENGTH_MISMATCH);
if (!NT_SUCCESS(status))
{
DELARRAY(result);
throw WinAPIException(status);
}
return result;
}
/*
Purpose:
Gets file handle type using the NUL device
It solves the first problem - getting file type on different systems
Parameters:
None
Return value:
A DWORD value repsesenting file type
*/
DWORD GetFileHandleType()
{
HANDLE hFile;
PSYSTEM_HANDLE_INFORMATION systemHandleInfo = NULL;
DWORD result = 0;
try
{
//opening "NUL" device in order to obtain its handle
hFile = CreateFile(_T("NUL"), GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE,
NULL, OPEN_EXISTING, ZERO_FLAGS, ZERO_HANDLE);
if (hFile == INVALID_HANDLE_VALUE)
{
throw WinAPIException(GetLastError());
}
//getting system handle information table
systemHandleInfo = (PSYSTEM_HANDLE_INFORMATION)
GetSystemInformationTable(SystemHandleInformation);
//if the table is ready
if (systemHandleInfo != NULL)
{
//iteration over table items
for (size_t i = 0; i<systemHandleInfo->uCount; ++i)
{
//if the handle is for "NUL" device and if it belongs
//to the application, we get the object file type
if (systemHandleInfo->aSH[i].Handle == (USHORT)hFile &&
systemHandleInfo->aSH[i].uIdProcess == GetCurrentProcessId())
{
result = systemHandleInfo->aSH[i].ObjectType;
break;
}
}
}
}
catch(...)
{
CloseHandle(hFile);
DELARRAY(systemHandleInfo);
throw;
}
CloseHandle(hFile);
DELARRAY(systemHandleInfo);
return result;
}
//Thread parameters for getting the file name
typedef struct _FN_INFO
{
FILE_NAME_INFORMATION fileNameInfo;
TCHAR Name[2*MAX_PATH+1];
} FN_INFO, *PFN_INFO;
typedef struct _ON_INFO
{
OBJECT_NAME_INFORMATION objectNameInfo;
TCHAR Device[2*MAX_PATH+1];
} ON_INFO, *PON_INFO;
typedef struct _FILE_INFO
{
HANDLE hFile;
FN_INFO fnInfo;
ON_INFO onInfo;
} FILE_INFO, *PFILE_INFO;
/*
Purpose:
Gets file name in a separate thread
Parameters:
lpParameters - thread parameters
Return value:
A DWORD value repsesenting thread status
*/
DWORD WINAPI GetFileNameThread(LPVOID lpParameters)
{
//converting data
PFILE_INFO info = (PFILE_INFO)lpParameters;
//input-output status
IO_STATUS_BLOCK ioStatus;
ZeroMemory(&ioStatus, sizeof(ioStatus));
//name info parameters
ZeroMemory(&info->fnInfo, sizeof(FILE_NAME_INFO));
//calling the function in order to identify if the file is "hanging"
if (NtQueryInformationFile(info->hFile, &ioStatus, &info->fnInfo.fileNameInfo,
sizeof(FILE_INFO)-sizeof(HANDLE), FileNameInformation) == STATUS_SUCCESS)
{
DWORD retLength;
//getting object name info - full path
NtQueryObject(info->hFile, ObjectNameInformation, &info->onInfo.objectNameInfo,
sizeof(FILE_INFO)-sizeof(HANDLE)-sizeof(FN_INFO), &retLength);
}
return NO_ERROR;
}
/*
Purpose:
Gets file name by its handle
Parameters:
hFile - file handle
Return value:
A C-string with file name or NULL if the call was timeouted
*/
LPTSTR GetFileName(HANDLE hFile)
{
//result buffer
PWCHAR result = NULL;
//allocating the buffer
PFILE_INFO info = (PFILE_INFO)new BYTE[sizeof(FILE_INFO)];
ZeroMemory(info, sizeof(FILE_INFO));
//saving file handle in parameters
info->hFile = hFile;
//creating a new thread for getting the file name
HANDLE hThread = CreateThread(NULL, ZERO_BUFFER, &GetFileNameThread,
info, ZERO_FLAGS, NULL);
//waiting for thread to finish
if (WaitForSingleObject(hThread, WAIT_PIPE_TIMEOUT) == WAIT_TIMEOUT)
{
//if the thread timeouted, we kill it
TerminateThread(hThread, 0);
//closing thread handle
CloseHandle(hThread);
}
else
{
//closing thread handle
CloseHandle(hThread);
//if the buffer was filled
if (info->onInfo.Device[0] != EOLN)
{
//copying file name
result = new WCHAR[_tcslen(info->onInfo.Device)+1];
_tcscpy(result,info->onInfo.Device);
}
}
DELARRAY(info);
return result;
}
/*
Purpose:
Gets the process name from the process info table
Parameters:
processInfo - pointer to the process info table
processId - process ID to find
Return value:
A C-string with the process name
*/
LPTSTR GetProcessName (PSYSTEM_PROCESS_INFORMATION processInfo, DWORD processId)
{
//copying pointer
PSYSTEM_PROCESS_INFORMATION pProcessInfo = processInfo;
//result buffer
LPTSTR result = NULL;
//loop until offset is zero or result is found
do
{
//going to the next element
pProcessInfo = (PSYSTEM_PROCESS_INFORMATION)((PCHAR)pProcessInfo + pProcessInfo->NextEntryOffset);
if (pProcessInfo->ProcessId == (HANDLE)processId)
{
//if the process ID's are matching,
//we copy the result
result = new TCHAR[pProcessInfo->ImageName.Length+1];
_tcscpy(result, pProcessInfo->ImageName.Buffer);
break;
}
}
while(pProcessInfo->NextEntryOffset != 0);
return result;
}
|
[
"[email protected]@8417aba2-bd37-11de-8784-f7ad4773dbab"
] |
[
[
[
1,
918
]
]
] |
403b49ba7f42d507cf292861e70ec7efeddc2119
|
f89e32cc183d64db5fc4eb17c47644a15c99e104
|
/pcsx2-rr/plugins/GSdx/GSDrawScanlineCodeGenerator.cpp
|
54df9b55105aa5a986140caf0efe9155ce1ae0b2
|
[] |
no_license
|
mauzus/progenitor
|
f99b882a48eb47a1cdbfacd2f38505e4c87480b4
|
7b4f30eb1f022b08e6da7eaafa5d2e77634d7bae
|
refs/heads/master
| 2021-01-10T07:24:00.383776 | 2011-04-28T11:03:43 | 2011-04-28T11:03:43 | 45,171,114 | 0 | 0 | null | null | null | null |
UTF-8
|
C++
| false | false | 40,448 |
cpp
|
/*
* Copyright (C) 2007-2009 Gabest
* http://www.gabest.org
*
* This Program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* This Program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
* http://www.gnu.org/copyleft/gpl.html
*
*/
// TODO: x64 (use the extra regs to avoid spills of zs, zd, uf, vf, rb, ga and keep a few constants in the last two like aref or afix)
// TODO: for edges doing 4 pixels is wasteful (needed memory access * 4)
#include "StdAfx.h"
#include "GSDrawScanlineCodeGenerator.h"
GSDrawScanlineCodeGenerator::GSDrawScanlineCodeGenerator(GSScanlineEnvironment& env, uint64 key, void* ptr, size_t maxsize)
: CodeGenerator(maxsize, ptr)
, m_env(env)
{
#if _M_AMD64
#error TODO
#endif
m_sel.key = key;
Generate();
}
void GSDrawScanlineCodeGenerator::Generate()
{
push(ebx);
push(esi);
push(edi);
push(ebp);
const int params = 16;
Init(params);
if(!m_sel.edge)
{
align(16);
}
L("loop");
// ecx = steps
// esi = fzbr
// edi = fzbc
// xmm0 = z/zi
// xmm2 = u (tme)
// xmm3 = v (tme)
// xmm5 = rb (!tme)
// xmm6 = ga (!tme)
// xmm7 = test
bool tme = m_sel.tfx != TFX_NONE;
TestZ(tme ? xmm5 : xmm2, tme ? xmm6 : xmm3);
// ecx = steps
// esi = fzbr
// edi = fzbc
// - xmm0
// xmm2 = u (tme)
// xmm3 = v (tme)
// xmm5 = rb (!tme)
// xmm6 = ga (!tme)
// xmm7 = test
SampleTexture();
// ecx = steps
// esi = fzbr
// edi = fzbc
// ebp = za
// - xmm2
// - xmm3
// - xmm4
// xmm5 = rb
// xmm6 = ga
// xmm7 = test
AlphaTFX();
// ecx = steps
// esi = fzbr
// edi = fzbc
// ebp = za
// xmm2 = gaf (TFX_HIGHLIGHT || TFX_HIGHLIGHT2 && !tcc)
// xmm5 = rb
// xmm6 = ga
// xmm7 = test
if(m_sel.fwrite)
{
movdqa(xmm3, xmmword[&m_env.fm]);
}
if(m_sel.zwrite)
{
movdqa(xmm4, xmmword[&m_env.zm]);
}
// ecx = steps
// esi = fzbr
// edi = fzbc
// ebp = za
// xmm2 = gaf (TFX_HIGHLIGHT || TFX_HIGHLIGHT2 && !tcc)
// xmm3 = fm
// xmm4 = zm
// xmm5 = rb
// xmm6 = ga
// xmm7 = test
TestAlpha();
// ecx = steps
// esi = fzbr
// edi = fzbc
// ebp = za
// xmm2 = gaf (TFX_HIGHLIGHT || TFX_HIGHLIGHT2 && !tcc)
// xmm3 = fm
// xmm4 = zm
// xmm5 = rb
// xmm6 = ga
// xmm7 = test
ColorTFX();
// ecx = steps
// esi = fzbr
// edi = fzbc
// ebp = za
// xmm3 = fm
// xmm4 = zm
// xmm5 = rb
// xmm6 = ga
// xmm7 = test
Fog();
// ecx = steps
// esi = fzbr
// edi = fzbc
// ebp = za
// xmm3 = fm
// xmm4 = zm
// xmm5 = rb
// xmm6 = ga
// xmm7 = test
ReadFrame();
// ecx = steps
// esi = fzbr
// edi = fzbc
// ebp = za
// xmm2 = fd
// xmm3 = fm
// xmm4 = zm
// xmm5 = rb
// xmm6 = ga
// xmm7 = test
TestDestAlpha();
// fm |= test;
// zm |= test;
if(m_sel.fwrite)
{
por(xmm3, xmm7);
}
if(m_sel.zwrite)
{
por(xmm4, xmm7);
}
// int fzm = ~(fm == GSVector4i::xffffffff()).ps32(zm == GSVector4i::xffffffff()).mask();
pcmpeqd(xmm1, xmm1);
if(m_sel.fwrite && m_sel.zwrite)
{
movdqa(xmm0, xmm1);
pcmpeqd(xmm1, xmm3);
pcmpeqd(xmm0, xmm4);
packssdw(xmm1, xmm0);
}
else if(m_sel.fwrite)
{
pcmpeqd(xmm1, xmm3);
packssdw(xmm1, xmm1);
}
else if(m_sel.zwrite)
{
pcmpeqd(xmm1, xmm4);
packssdw(xmm1, xmm1);
}
pmovmskb(edx, xmm1);
not(edx);
// ebx = fa
// ecx = steps
// edx = fzm
// esi = fzbr
// edi = fzbc
// ebp = za
// xmm2 = fd
// xmm3 = fm
// xmm4 = zm
// xmm5 = rb
// xmm6 = ga
WriteZBuf();
// ebx = fa
// ecx = steps
// edx = fzm
// esi = fzbr
// edi = fzbc
// - ebp
// xmm2 = fd
// xmm3 = fm
// - xmm4
// xmm5 = rb
// xmm6 = ga
AlphaBlend();
// ebx = fa
// ecx = steps
// edx = fzm
// esi = fzbr
// edi = fzbc
// xmm2 = fd
// xmm3 = fm
// xmm5 = rb
// xmm6 = ga
WriteFrame(params);
L("step");
// if(steps <= 0) break;
if(!m_sel.edge)
{
test(ecx, ecx);
jle("exit", T_NEAR);
Step();
jmp("loop", T_NEAR);
}
L("exit");
pop(ebp);
pop(edi);
pop(esi);
pop(ebx);
ret(8);
}
void GSDrawScanlineCodeGenerator::Init(int params)
{
const int _top = params + 4;
const int _v = params + 8;
// int skip = left & 3;
mov(ebx, edx);
and(edx, 3);
// left -= skip;
sub(ebx, edx);
// int steps = right - left - 4;
sub(ecx, ebx);
sub(ecx, 4);
// GSVector4i test = m_test[skip] | m_test[7 + (steps & (steps >> 31))];
shl(edx, 4);
movdqa(xmm7, xmmword[edx + (size_t)&m_test[0]]);
mov(eax, ecx);
sar(eax, 31);
and(eax, ecx);
shl(eax, 4);
por(xmm7, xmmword[eax + (size_t)&m_test[7]]);
// GSVector2i* fza_base = &m_env.fzbr[top];
mov(esi, dword[esp + _top]);
lea(esi, ptr[esi * 8]);
add(esi, dword[&m_env.fzbr]);
// GSVector2i* fza_offset = &m_env.fzbc[left >> 2];
lea(edi, ptr[ebx * 2]);
add(edi, dword[&m_env.fzbc]);
if(!m_sel.sprite && (m_sel.fwrite && m_sel.fge || m_sel.zb) || m_sel.fb && (m_sel.edge || m_sel.tfx != TFX_NONE || m_sel.iip))
{
// edx = &m_env.d[skip]
shl(edx, 4);
lea(edx, ptr[edx + (size_t)m_env.d]);
// ebx = &v
mov(ebx, dword[esp + _v]);
}
if(!m_sel.sprite)
{
if(m_sel.fwrite && m_sel.fge || m_sel.zb)
{
movaps(xmm0, xmmword[ebx + 16]); // v.p
if(m_sel.fwrite && m_sel.fge)
{
// f = GSVector4i(vp).zzzzh().zzzz().add16(m_env.d[skip].f);
cvttps2dq(xmm1, xmm0);
pshufhw(xmm1, xmm1, _MM_SHUFFLE(2, 2, 2, 2));
pshufd(xmm1, xmm1, _MM_SHUFFLE(2, 2, 2, 2));
paddw(xmm1, xmmword[edx + 16 * 6]);
movdqa(xmmword[&m_env.temp.f], xmm1);
}
if(m_sel.zb)
{
// z = vp.zzzz() + m_env.d[skip].z;
shufps(xmm0, xmm0, _MM_SHUFFLE(2, 2, 2, 2));
addps(xmm0, xmmword[edx]);
movaps(xmmword[&m_env.temp.z], xmm0);
}
}
}
else
{
if(m_sel.ztest)
{
movdqa(xmm0, xmmword[&m_env.p.z]);
}
}
if(m_sel.fb)
{
if(m_sel.edge || m_sel.tfx != TFX_NONE)
{
movaps(xmm4, xmmword[ebx + 32]); // v.t
}
if(m_sel.edge)
{
pshufhw(xmm3, xmm4, _MM_SHUFFLE(2, 2, 2, 2));
pshufd(xmm3, xmm3, _MM_SHUFFLE(3, 3, 3, 3));
psrlw(xmm3, 9);
movdqa(xmmword[&m_env.temp.cov], xmm3);
}
if(m_sel.tfx != TFX_NONE)
{
if(m_sel.fst)
{
// GSVector4i vti(vt);
cvttps2dq(xmm4, xmm4);
// si = vti.xxxx() + m_env.d[skip].si;
// ti = vti.yyyy(); if(!sprite) ti += m_env.d[skip].ti;
pshufd(xmm2, xmm4, _MM_SHUFFLE(0, 0, 0, 0));
pshufd(xmm3, xmm4, _MM_SHUFFLE(1, 1, 1, 1));
paddd(xmm2, xmmword[edx + 16 * 7]);
if(!m_sel.sprite)
{
paddd(xmm3, xmmword[edx + 16 * 8]);
}
else
{
if(m_sel.ltf)
{
movdqa(xmm4, xmm3);
pshuflw(xmm4, xmm4, _MM_SHUFFLE(2, 2, 0, 0));
pshufhw(xmm4, xmm4, _MM_SHUFFLE(2, 2, 0, 0));
psrlw(xmm4, 1);
movdqa(xmmword[&m_env.temp.vf], xmm4);
}
}
movdqa(xmmword[&m_env.temp.s], xmm2);
movdqa(xmmword[&m_env.temp.t], xmm3);
}
else
{
// s = vt.xxxx() + m_env.d[skip].s;
// t = vt.yyyy() + m_env.d[skip].t;
// q = vt.zzzz() + m_env.d[skip].q;
movaps(xmm2, xmm4);
movaps(xmm3, xmm4);
shufps(xmm2, xmm2, _MM_SHUFFLE(0, 0, 0, 0));
shufps(xmm3, xmm3, _MM_SHUFFLE(1, 1, 1, 1));
shufps(xmm4, xmm4, _MM_SHUFFLE(2, 2, 2, 2));
addps(xmm2, xmmword[edx + 16 * 1]);
addps(xmm3, xmmword[edx + 16 * 2]);
addps(xmm4, xmmword[edx + 16 * 3]);
movaps(xmmword[&m_env.temp.s], xmm2);
movaps(xmmword[&m_env.temp.t], xmm3);
movaps(xmmword[&m_env.temp.q], xmm4);
rcpps(xmm4, xmm4);
mulps(xmm2, xmm4);
mulps(xmm3, xmm4);
}
}
if(!(m_sel.tfx == TFX_DECAL && m_sel.tcc))
{
if(m_sel.iip)
{
// GSVector4i vc = GSVector4i(v.c);
cvttps2dq(xmm6, xmmword[ebx]); // v.c
// vc = vc.upl16(vc.zwxy());
pshufd(xmm5, xmm6, _MM_SHUFFLE(1, 0, 3, 2));
punpcklwd(xmm6, xmm5);
// rb = vc.xxxx().add16(m_env.d[skip].rb);
// ga = vc.zzzz().add16(m_env.d[skip].ga);
pshufd(xmm5, xmm6, _MM_SHUFFLE(0, 0, 0, 0));
pshufd(xmm6, xmm6, _MM_SHUFFLE(2, 2, 2, 2));
paddw(xmm5, xmmword[edx + 16 * 4]);
paddw(xmm6, xmmword[edx + 16 * 5]);
movdqa(xmmword[&m_env.temp.rb], xmm5);
movdqa(xmmword[&m_env.temp.ga], xmm6);
}
else
{
if(m_sel.tfx == TFX_NONE)
{
movdqa(xmm5, xmmword[&m_env.c.rb]);
movdqa(xmm6, xmmword[&m_env.c.ga]);
}
}
}
}
}
void GSDrawScanlineCodeGenerator::Step()
{
// steps -= 4;
sub(ecx, 4);
// fza_offset++;
add(edi, 8);
if(!m_sel.sprite)
{
// z += m_env.d4.z;
if(m_sel.zb)
{
movaps(xmm0, xmmword[&m_env.temp.z]);
addps(xmm0, xmmword[&m_env.d4.z]);
movaps(xmmword[&m_env.temp.z], xmm0);
}
// f = f.add16(m_env.d4.f);
if(m_sel.fwrite && m_sel.fge)
{
movdqa(xmm1, xmmword[&m_env.temp.f]);
paddw(xmm1, xmmword[&m_env.d4.f]);
movdqa(xmmword[&m_env.temp.f], xmm1);
}
}
else
{
if(m_sel.ztest)
{
movdqa(xmm0, xmmword[&m_env.p.z]);
}
}
if(m_sel.fb)
{
if(m_sel.tfx != TFX_NONE)
{
if(m_sel.fst)
{
// GSVector4i st = m_env.d4.st;
// si += st.xxxx();
// if(!sprite) ti += st.yyyy();
movdqa(xmm4, xmmword[&m_env.d4.st]);
pshufd(xmm2, xmm4, _MM_SHUFFLE(0, 0, 0, 0));
paddd(xmm2, xmmword[&m_env.temp.s]);
movdqa(xmmword[&m_env.temp.s], xmm2);
if(!m_sel.sprite)
{
pshufd(xmm3, xmm4, _MM_SHUFFLE(1, 1, 1, 1));
paddd(xmm3, xmmword[&m_env.temp.t]);
movdqa(xmmword[&m_env.temp.t], xmm3);
}
else
{
movdqa(xmm3, xmmword[&m_env.temp.t]);
}
}
else
{
// GSVector4 stq = m_env.d4.stq;
// s += stq.xxxx();
// t += stq.yyyy();
// q += stq.zzzz();
movaps(xmm2, xmmword[&m_env.d4.stq]);
movaps(xmm3, xmm2);
movaps(xmm4, xmm2);
shufps(xmm2, xmm2, _MM_SHUFFLE(0, 0, 0, 0));
shufps(xmm3, xmm3, _MM_SHUFFLE(1, 1, 1, 1));
shufps(xmm4, xmm4, _MM_SHUFFLE(2, 2, 2, 2));
addps(xmm2, xmmword[&m_env.temp.s]);
addps(xmm3, xmmword[&m_env.temp.t]);
addps(xmm4, xmmword[&m_env.temp.q]);
movaps(xmmword[&m_env.temp.s], xmm2);
movaps(xmmword[&m_env.temp.t], xmm3);
movaps(xmmword[&m_env.temp.q], xmm4);
rcpps(xmm4, xmm4);
mulps(xmm2, xmm4);
mulps(xmm3, xmm4);
}
}
if(!(m_sel.tfx == TFX_DECAL && m_sel.tcc))
{
if(m_sel.iip)
{
// GSVector4i c = m_env.d4.c;
// rb = rb.add16(c.xxxx());
// ga = ga.add16(c.yyyy());
movdqa(xmm7, xmmword[&m_env.d4.c]);
pshufd(xmm5, xmm7, _MM_SHUFFLE(0, 0, 0, 0));
pshufd(xmm6, xmm7, _MM_SHUFFLE(1, 1, 1, 1));
paddw(xmm5, xmmword[&m_env.temp.rb]);
paddw(xmm6, xmmword[&m_env.temp.ga]);
movdqa(xmmword[&m_env.temp.rb], xmm5);
movdqa(xmmword[&m_env.temp.ga], xmm6);
}
else
{
if(m_sel.tfx == TFX_NONE)
{
movdqa(xmm5, xmmword[&m_env.c.rb]);
movdqa(xmm6, xmmword[&m_env.c.ga]);
}
}
}
}
// test = m_test[7 + (steps & (steps >> 31))];
mov(edx, ecx);
sar(edx, 31);
and(edx, ecx);
shl(edx, 4);
movdqa(xmm7, xmmword[edx + (size_t)&m_test[7]]);
}
void GSDrawScanlineCodeGenerator::TestZ(const Xmm& temp1, const Xmm& temp2)
{
if(!m_sel.zb)
{
return;
}
// int za = fza_base.y + fza_offset->y;
mov(ebp, dword[esi + 4]);
add(ebp, dword[edi + 4]);
// GSVector4i zs = zi;
if(!m_sel.sprite)
{
if(m_sel.zoverflow)
{
// zs = (GSVector4i(z * 0.5f) << 1) | (GSVector4i(z) & GSVector4i::x00000001());
static float half = 0.5f;
movss(temp1, dword[&half]);
shufps(temp1, temp1, _MM_SHUFFLE(0, 0, 0, 0));
mulps(temp1, xmm0);
cvttps2dq(temp1, temp1);
pslld(temp1, 1);
cvttps2dq(xmm0, xmm0);
pcmpeqd(temp2, temp2);
psrld(temp2, 31);
pand(xmm0, temp2);
por(xmm0, temp1);
}
else
{
// zs = GSVector4i(z);
cvttps2dq(xmm0, xmm0);
}
if(m_sel.zwrite)
{
movdqa(xmmword[&m_env.temp.zs], xmm0);
}
}
if(m_sel.ztest)
{
ReadPixel(xmm1, ebp);
if(m_sel.zwrite && m_sel.zpsm < 2)
{
movdqa(xmmword[&m_env.temp.zd], xmm1);
}
// zd &= 0xffffffff >> m_sel.zpsm * 8;
if(m_sel.zpsm)
{
pslld(xmm1, m_sel.zpsm * 8);
psrld(xmm1, m_sel.zpsm * 8);
}
if(m_sel.zoverflow || m_sel.zpsm == 0)
{
// GSVector4i o = GSVector4i::x80000000();
pcmpeqd(xmm4, xmm4);
pslld(xmm4, 31);
// GSVector4i zso = zs - o;
psubd(xmm0, xmm4);
// GSVector4i zdo = zd - o;
psubd(xmm1, xmm4);
}
switch(m_sel.ztst)
{
case ZTST_GEQUAL:
// test |= zso < zdo; // ~(zso >= zdo)
pcmpgtd(xmm1, xmm0);
por(xmm7, xmm1);
break;
case ZTST_GREATER: // TODO: tidus hair and chocobo wings only appear fully when this is tested as ZTST_GEQUAL
// test |= zso <= zdo; // ~(zso > zdo)
pcmpgtd(xmm0, xmm1);
pcmpeqd(xmm4, xmm4);
pxor(xmm0, xmm4);
por(xmm7, xmm0);
break;
}
alltrue();
}
}
void GSDrawScanlineCodeGenerator::SampleTexture()
{
if(!m_sel.fb || m_sel.tfx == TFX_NONE)
{
return;
}
mov(ebx, dword[&m_env.tex]);
// ebx = tex
if(!m_sel.fst)
{
// TODO: move these into Init/Step too?
cvttps2dq(xmm2, xmm2);
cvttps2dq(xmm3, xmm3);
if(m_sel.ltf)
{
// u -= 0x8000;
// v -= 0x8000;
mov(eax, 0x8000);
movd(xmm4, eax);
pshufd(xmm4, xmm4, _MM_SHUFFLE(0, 0, 0, 0));
psubd(xmm2, xmm4);
psubd(xmm3, xmm4);
}
}
// xmm2 = u
// xmm3 = v
if(m_sel.ltf)
{
// GSVector4i uf = u.xxzzlh().srl16(1);
movdqa(xmm0, xmm2);
pshuflw(xmm0, xmm0, _MM_SHUFFLE(2, 2, 0, 0));
pshufhw(xmm0, xmm0, _MM_SHUFFLE(2, 2, 0, 0));
psrlw(xmm0, 1);
movdqa(xmmword[&m_env.temp.uf], xmm0);
if(!m_sel.sprite)
{
// GSVector4i vf = v.xxzzlh().srl16(1);
movdqa(xmm1, xmm3);
pshuflw(xmm1, xmm1, _MM_SHUFFLE(2, 2, 0, 0));
pshufhw(xmm1, xmm1, _MM_SHUFFLE(2, 2, 0, 0));
psrlw(xmm1, 1);
movdqa(xmmword[&m_env.temp.vf], xmm1);
}
}
// GSVector4i uv0 = u.sra32(16).ps32(v.sra32(16));
psrad(xmm2, 16);
psrad(xmm3, 16);
packssdw(xmm2, xmm3);
if(m_sel.ltf)
{
// GSVector4i uv1 = uv0.add16(GSVector4i::x0001());
movdqa(xmm3, xmm2);
pcmpeqd(xmm1, xmm1);
psrlw(xmm1, 15);
paddw(xmm3, xmm1);
// uv0 = Wrap(uv0);
// uv1 = Wrap(uv1);
Wrap(xmm2, xmm3);
}
else
{
// uv0 = Wrap(uv0);
Wrap(xmm2);
}
// xmm2 = uv0
// xmm3 = uv1 (ltf)
// xmm0, xmm1, xmm4, xmm5, xmm6 = free
// xmm7 = used
// GSVector4i y0 = uv0.uph16() << tw;
// GSVector4i x0 = uv0.upl16();
pxor(xmm0, xmm0);
movd(xmm1, ptr[&m_env.tw]);
movdqa(xmm4, xmm2);
punpckhwd(xmm2, xmm0);
punpcklwd(xmm4, xmm0);
pslld(xmm2, xmm1);
// xmm0 = 0
// xmm1 = tw
// xmm2 = y0
// xmm3 = uv1 (ltf)
// xmm4 = x0
// xmm5, xmm6 = free
// xmm7 = used
if(m_sel.ltf)
{
// GSVector4i y1 = uv1.uph16() << tw;
// GSVector4i x1 = uv1.upl16();
movdqa(xmm6, xmm3);
punpckhwd(xmm3, xmm0);
punpcklwd(xmm6, xmm0);
pslld(xmm3, xmm1);
// xmm2 = y0
// xmm3 = y1
// xmm4 = x0
// xmm6 = x1
// xmm0, xmm5, xmm6 = free
// xmm7 = used
// GSVector4i addr00 = y0 + x0;
// GSVector4i addr01 = y0 + x1;
// GSVector4i addr10 = y1 + x0;
// GSVector4i addr11 = y1 + x1;
movdqa(xmm5, xmm2);
paddd(xmm5, xmm4);
paddd(xmm2, xmm6);
movdqa(xmm0, xmm3);
paddd(xmm0, xmm4);
paddd(xmm3, xmm6);
// xmm5 = addr00
// xmm2 = addr01
// xmm0 = addr10
// xmm3 = addr11
// xmm1, xmm4, xmm6 = free
// xmm7 = used
// c00 = addr00.gather32_32((const uint32/uint8*)tex[, clut]);
// c01 = addr01.gather32_32((const uint32/uint8*)tex[, clut]);
// c10 = addr10.gather32_32((const uint32/uint8*)tex[, clut]);
// c11 = addr11.gather32_32((const uint32/uint8*)tex[, clut]);
ReadTexel(xmm6, xmm5, xmm1, xmm4);
// xmm2, xmm5, xmm1 = free
ReadTexel(xmm4, xmm2, xmm5, xmm1);
// xmm0, xmm2, xmm5 = free
ReadTexel(xmm1, xmm0, xmm2, xmm5);
// xmm3, xmm0, xmm2 = free
ReadTexel(xmm5, xmm3, xmm0, xmm2);
// xmm6 = c00
// xmm4 = c01
// xmm1 = c10
// xmm5 = c11
// xmm0, xmm2, xmm3 = free
// xmm7 = used
movdqa(xmm0, xmmword[&m_env.temp.uf]);
// GSVector4i rb00 = c00 & mask;
// GSVector4i ga00 = (c00 >> 8) & mask;
movdqa(xmm2, xmm6);
psllw(xmm2, 8);
psrlw(xmm2, 8);
psrlw(xmm6, 8);
// GSVector4i rb01 = c01 & mask;
// GSVector4i ga01 = (c01 >> 8) & mask;
movdqa(xmm3, xmm4);
psllw(xmm3, 8);
psrlw(xmm3, 8);
psrlw(xmm4, 8);
// xmm0 = uf
// xmm2 = rb00
// xmm3 = rb01
// xmm6 = ga00
// xmm4 = ga01
// xmm1 = c10
// xmm5 = c11
// xmm7 = used
// rb00 = rb00.lerp16<0>(rb01, uf);
// ga00 = ga00.lerp16<0>(ga01, uf);
lerp16<0>(xmm3, xmm2, xmm0);
lerp16<0>(xmm4, xmm6, xmm0);
// xmm0 = uf
// xmm3 = rb00
// xmm4 = ga00
// xmm1 = c10
// xmm5 = c11
// xmm2, xmm6 = free
// xmm7 = used
// GSVector4i rb10 = c10 & mask;
// GSVector4i ga10 = (c10 >> 8) & mask;
movdqa(xmm2, xmm1);
psllw(xmm1, 8);
psrlw(xmm1, 8);
psrlw(xmm2, 8);
// GSVector4i rb11 = c11 & mask;
// GSVector4i ga11 = (c11 >> 8) & mask;
movdqa(xmm6, xmm5);
psllw(xmm5, 8);
psrlw(xmm5, 8);
psrlw(xmm6, 8);
// xmm0 = uf
// xmm3 = rb00
// xmm4 = ga00
// xmm1 = rb10
// xmm5 = rb11
// xmm2 = ga10
// xmm6 = ga11
// xmm7 = used
// rb10 = rb10.lerp16<0>(rb11, uf);
// ga10 = ga10.lerp16<0>(ga11, uf);
lerp16<0>(xmm5, xmm1, xmm0);
lerp16<0>(xmm6, xmm2, xmm0);
// xmm3 = rb00
// xmm4 = ga00
// xmm5 = rb10
// xmm6 = ga10
// xmm0, xmm1, xmm2 = free
// xmm7 = used
// rb00 = rb00.lerp16<0>(rb10, vf);
// ga00 = ga00.lerp16<0>(ga10, vf);
movdqa(xmm0, xmmword[&m_env.temp.vf]);
lerp16<0>(xmm5, xmm3, xmm0);
lerp16<0>(xmm6, xmm4, xmm0);
}
else
{
// GSVector4i addr00 = y0 + x0;
paddd(xmm2, xmm4);
// c00 = addr00.gather32_32((const uint32/uint8*)tex[, clut]);
ReadTexel(xmm5, xmm2, xmm0, xmm1);
// GSVector4i mask = GSVector4i::x00ff();
// c[0] = c00 & mask;
// c[1] = (c00 >> 8) & mask;
movdqa(xmm6, xmm5);
psllw(xmm5, 8);
psrlw(xmm5, 8);
psrlw(xmm6, 8);
}
}
void GSDrawScanlineCodeGenerator::Wrap(const Xmm& uv)
{
// xmm0, xmm1, xmm4, xmm5, xmm6 = free
int wms_clamp = ((m_sel.wms + 1) >> 1) & 1;
int wmt_clamp = ((m_sel.wmt + 1) >> 1) & 1;
int region = ((m_sel.wms | m_sel.wmt) >> 1) & 1;
if(wms_clamp == wmt_clamp)
{
if(wms_clamp)
{
if(region)
{
pmaxsw(uv, xmmword[&m_env.t.min]);
}
else
{
pxor(xmm0, xmm0);
pmaxsw(uv, xmm0);
}
pminsw(uv, xmmword[&m_env.t.max]);
}
else
{
pand(uv, xmmword[&m_env.t.min]);
if(region)
{
por(uv, xmmword[&m_env.t.max]);
}
}
}
else
{
movdqa(xmm1, uv);
movdqa(xmm4, xmmword[&m_env.t.min]);
movdqa(xmm5, xmmword[&m_env.t.max]);
// GSVector4i clamp = t.sat_i16(m_env.t.min, m_env.t.max);
pmaxsw(uv, xmm4);
pminsw(uv, xmm5);
// GSVector4i repeat = (t & m_env.t.min) | m_env.t.max;
pand(xmm1, xmm4);
if(region)
{
por(xmm1, xmm5);
}
// clamp.blend8(repeat, m_env.t.mask);
movdqa(xmm0, xmmword[&m_env.t.mask]);
blend8(uv, xmm1);
}
}
void GSDrawScanlineCodeGenerator::Wrap(const Xmm& uv0, const Xmm& uv1)
{
// xmm0, xmm1, xmm4, xmm5, xmm6 = free
int wms_clamp = ((m_sel.wms + 1) >> 1) & 1;
int wmt_clamp = ((m_sel.wmt + 1) >> 1) & 1;
int region = ((m_sel.wms | m_sel.wmt) >> 1) & 1;
if(wms_clamp == wmt_clamp)
{
if(wms_clamp)
{
if(region)
{
movdqa(xmm4, xmmword[&m_env.t.min]);
pmaxsw(uv0, xmm4);
pmaxsw(uv1, xmm4);
}
else
{
pxor(xmm0, xmm0);
pmaxsw(uv0, xmm0);
pmaxsw(uv1, xmm0);
}
movdqa(xmm5, xmmword[&m_env.t.max]);
pminsw(uv0, xmm5);
pminsw(uv1, xmm5);
}
else
{
movdqa(xmm4, xmmword[&m_env.t.min]);
pand(uv0, xmm4);
pand(uv1, xmm4);
if(region)
{
movdqa(xmm5, xmmword[&m_env.t.max]);
por(uv0, xmm5);
por(uv1, xmm5);
}
}
}
else
{
movdqa(xmm1, uv0);
movdqa(xmm6, uv1);
movdqa(xmm4, xmmword[&m_env.t.min]);
movdqa(xmm5, xmmword[&m_env.t.max]);
// GSVector4i clamp = t.sat_i16(m_env.t.min, m_env.t.max);
pmaxsw(uv0, xmm4);
pmaxsw(uv1, xmm4);
pminsw(uv0, xmm5);
pminsw(uv1, xmm5);
// GSVector4i repeat = (t & m_env.t.min) | m_env.t.max;
pand(xmm1, xmm4);
pand(xmm6, xmm4);
if(region)
{
por(xmm1, xmm5);
por(xmm6, xmm5);
}
// clamp.blend8(repeat, m_env.t.mask);
if(m_cpu.has(util::Cpu::tSSE41))
{
movdqa(xmm0, xmmword[&m_env.t.mask]);
pblendvb(uv0, xmm1);
pblendvb(uv1, xmm6);
}
else
{
movdqa(xmm0, xmmword[&m_env.t.invmask]);
movdqa(xmm4, xmm0);
pand(uv0, xmm0);
pandn(xmm0, xmm1);
por(uv0, xmm0);
pand(uv1, xmm4);
pandn(xmm4, xmm6);
por(uv1, xmm4);
}
}
}
void GSDrawScanlineCodeGenerator::AlphaTFX()
{
if(!m_sel.fb)
{
return;
}
switch(m_sel.tfx)
{
case TFX_MODULATE:
// GSVector4i ga = iip ? gaf : m_env.c.ga;
movdqa(xmm4, xmmword[m_sel.iip ? &m_env.temp.ga : &m_env.c.ga]);
// gat = gat.modulate16<1>(ga).clamp8();
modulate16<1>(xmm6, xmm4);
clamp16(xmm6, xmm3);
// if(!tcc) gat = gat.mix16(ga.srl16(7));
if(!m_sel.tcc)
{
psrlw(xmm4, 7);
mix16(xmm6, xmm4, xmm3);
}
break;
case TFX_DECAL:
// if(!tcc) gat = gat.mix16(ga.srl16(7));
if(!m_sel.tcc)
{
// GSVector4i ga = iip ? gaf : m_env.c.ga;
movdqa(xmm4, xmmword[m_sel.iip ? &m_env.temp.ga : &m_env.c.ga]);
psrlw(xmm4, 7);
mix16(xmm6, xmm4, xmm3);
}
break;
case TFX_HIGHLIGHT:
// GSVector4i ga = iip ? gaf : m_env.c.ga;
movdqa(xmm4, xmmword[m_sel.iip ? &m_env.temp.ga : &m_env.c.ga]);
movdqa(xmm2, xmm4);
// gat = gat.mix16(!tcc ? ga.srl16(7) : gat.addus8(ga.srl16(7)));
psrlw(xmm4, 7);
if(m_sel.tcc)
{
paddusb(xmm4, xmm6);
}
mix16(xmm6, xmm4, xmm3);
break;
case TFX_HIGHLIGHT2:
// if(!tcc) gat = gat.mix16(ga.srl16(7));
if(!m_sel.tcc)
{
// GSVector4i ga = iip ? gaf : m_env.c.ga;
movdqa(xmm4, xmmword[m_sel.iip ? &m_env.temp.ga : &m_env.c.ga]);
movdqa(xmm2, xmm4);
psrlw(xmm4, 7);
mix16(xmm6, xmm4, xmm3);
}
break;
case TFX_NONE:
// gat = iip ? ga.srl16(7) : ga;
if(m_sel.iip)
{
psrlw(xmm6, 7);
}
break;
}
if(m_sel.aa1)
{
// gs_user figure 3-2: anti-aliasing after tfx, before tests, modifies alpha
// FIXME: bios config screen cubes
if(!m_sel.abe)
{
// a = cov
if(m_sel.edge)
{
movdqa(xmm0, xmmword[&m_env.temp.cov]);
}
else
{
pcmpeqd(xmm0, xmm0);
psllw(xmm0, 15);
psrlw(xmm0, 8);
}
mix16(xmm6, xmm0, xmm1);
}
else
{
// a = a == 0x80 ? cov : a
pcmpeqd(xmm0, xmm0);
psllw(xmm0, 15);
psrlw(xmm0, 8);
if(m_sel.edge)
{
movdqa(xmm1, xmmword[&m_env.temp.cov]);
}
else
{
movdqa(xmm1, xmm0);
}
pcmpeqw(xmm0, xmm6);
psrld(xmm0, 16);
pslld(xmm0, 16);
blend8(xmm6, xmm1);
}
}
}
void GSDrawScanlineCodeGenerator::TestAlpha()
{
switch(m_sel.afail)
{
case AFAIL_FB_ONLY:
if(!m_sel.zwrite) return;
break;
case AFAIL_ZB_ONLY:
if(!m_sel.fwrite) return;
break;
case AFAIL_RGB_ONLY:
if(!m_sel.zwrite && m_sel.fpsm == 1) return;
break;
}
switch(m_sel.atst)
{
case ATST_NEVER:
// t = GSVector4i::xffffffff();
pcmpeqd(xmm1, xmm1);
break;
case ATST_ALWAYS:
return;
case ATST_LESS:
case ATST_LEQUAL:
// t = (ga >> 16) > m_env.aref;
movdqa(xmm1, xmm6);
psrld(xmm1, 16);
pcmpgtd(xmm1, xmmword[&m_env.aref]);
break;
case ATST_EQUAL:
// t = (ga >> 16) != m_env.aref;
movdqa(xmm1, xmm6);
psrld(xmm1, 16);
pcmpeqd(xmm1, xmmword[&m_env.aref]);
pcmpeqd(xmm0, xmm0);
pxor(xmm1, xmm0);
break;
case ATST_GEQUAL:
case ATST_GREATER:
// t = (ga >> 16) < m_env.aref;
movdqa(xmm0, xmm6);
psrld(xmm0, 16);
movdqa(xmm1, xmmword[&m_env.aref]);
pcmpgtd(xmm1, xmm0);
break;
case ATST_NOTEQUAL:
// t = (ga >> 16) == m_env.aref;
movdqa(xmm1, xmm6);
psrld(xmm1, 16);
pcmpeqd(xmm1, xmmword[&m_env.aref]);
break;
}
switch(m_sel.afail)
{
case AFAIL_KEEP:
// test |= t;
por(xmm7, xmm1);
alltrue();
break;
case AFAIL_FB_ONLY:
// zm |= t;
por(xmm4, xmm1);
break;
case AFAIL_ZB_ONLY:
// fm |= t;
por(xmm3, xmm1);
break;
case AFAIL_RGB_ONLY:
// zm |= t;
por(xmm4, xmm1);
// fm |= t & GSVector4i::xff000000();
psrld(xmm1, 24);
pslld(xmm1, 24);
por(xmm3, xmm1);
break;
}
}
void GSDrawScanlineCodeGenerator::ColorTFX()
{
if(!m_sel.fwrite)
{
return;
}
switch(m_sel.tfx)
{
case TFX_MODULATE:
// GSVector4i rb = iip ? rbf : m_env.c.rb;
// rbt = rbt.modulate16<1>(rb).clamp8();
modulate16<1>(xmm5, xmmword[m_sel.iip ? &m_env.temp.rb : &m_env.c.rb]);
clamp16(xmm5, xmm1);
break;
case TFX_DECAL:
break;
case TFX_HIGHLIGHT:
case TFX_HIGHLIGHT2:
if(m_sel.tfx == TFX_HIGHLIGHT2 && m_sel.tcc)
{
// GSVector4i ga = iip ? gaf : m_env.c.ga;
movdqa(xmm2, xmmword[m_sel.iip ? &m_env.temp.ga : &m_env.c.ga]);
}
// gat = gat.modulate16<1>(ga).add16(af).clamp8().mix16(gat);
movdqa(xmm1, xmm6);
modulate16<1>(xmm6, xmm2);
pshuflw(xmm2, xmm2, _MM_SHUFFLE(3, 3, 1, 1));
pshufhw(xmm2, xmm2, _MM_SHUFFLE(3, 3, 1, 1));
psrlw(xmm2, 7);
paddw(xmm6, xmm2);
clamp16(xmm6, xmm0);
mix16(xmm6, xmm1, xmm0);
// GSVector4i rb = iip ? rbf : m_env.c.rb;
// rbt = rbt.modulate16<1>(rb).add16(af).clamp8();
modulate16<1>(xmm5, xmmword[m_sel.iip ? &m_env.temp.rb : &m_env.c.rb]);
paddw(xmm5, xmm2);
clamp16(xmm5, xmm0);
break;
case TFX_NONE:
// rbt = iip ? rb.srl16(7) : rb;
if(m_sel.iip)
{
psrlw(xmm5, 7);
}
break;
}
}
void GSDrawScanlineCodeGenerator::Fog()
{
if(!m_sel.fwrite || !m_sel.fge)
{
return;
}
// rb = m_env.frb.lerp16<0>(rb, f);
// ga = m_env.fga.lerp16<0>(ga, f).mix16(ga);
movdqa(xmm0, xmmword[!m_sel.sprite ? &m_env.temp.f : &m_env.p.f]);
movdqa(xmm1, xmm6);
movdqa(xmm2, xmmword[&m_env.frb]);
lerp16<0>(xmm5, xmm2, xmm0);
movdqa(xmm2, xmmword[&m_env.fga]);
lerp16<0>(xmm6, xmm2, xmm0);
mix16(xmm6, xmm1, xmm0);
}
void GSDrawScanlineCodeGenerator::ReadFrame()
{
if(!m_sel.fb)
{
return;
}
// int fa = fza_base.x + fza_offset->x;
mov(ebx, dword[esi]);
add(ebx, dword[edi]);
if(!m_sel.rfb)
{
return;
}
ReadPixel(xmm2, ebx);
}
void GSDrawScanlineCodeGenerator::TestDestAlpha()
{
if(!m_sel.date || m_sel.fpsm != 0 && m_sel.fpsm != 2)
{
return;
}
// test |= ((fd [<< 16]) ^ m_env.datm).sra32(31);
movdqa(xmm1, xmm2);
if(m_sel.datm)
{
if(m_sel.fpsm == 2)
{
pxor(xmm0, xmm0);
psrld(xmm1, 15);
pcmpeqd(xmm1, xmm0);
}
else
{
pcmpeqd(xmm0, xmm0);
pxor(xmm1, xmm0);
psrad(xmm1, 31);
}
}
else
{
if(m_sel.fpsm == 2)
{
pslld(xmm1, 16);
}
psrad(xmm1, 31);
}
por(xmm7, xmm1);
alltrue();
}
void GSDrawScanlineCodeGenerator::WriteZBuf()
{
if(!m_sel.zwrite)
{
return;
}
movdqa(xmm1, xmmword[!m_sel.sprite ? &m_env.temp.zs : &m_env.p.z]);
bool fast = false;
if(m_sel.ztest && m_sel.zpsm < 2)
{
// zs = zs.blend8(zd, zm);
movdqa(xmm0, xmm4);
movdqa(xmm7, xmmword[&m_env.temp.zd]);
blend8(xmm1, xmm7);
fast = true;
}
WritePixel(xmm1, xmm0, ebp, dh, fast, m_sel.zpsm);
}
void GSDrawScanlineCodeGenerator::AlphaBlend()
{
if(!m_sel.fwrite)
{
return;
}
if(m_sel.abe == 0 && m_sel.aa1 == 0)
{
return;
}
if((m_sel.aba != m_sel.abb) && (m_sel.aba == 1 || m_sel.abb == 1 || m_sel.abc == 1) || m_sel.abd == 1)
{
switch(m_sel.fpsm)
{
case 0:
case 1:
// c[2] = fd & mask;
// c[3] = (fd >> 8) & mask;
movdqa(xmm0, xmm2);
movdqa(xmm1, xmm2);
psllw(xmm0, 8);
psrlw(xmm0, 8);
psrlw(xmm1, 8);
break;
case 2:
// c[2] = ((fd & 0x7c00) << 9) | ((fd & 0x001f) << 3);
// c[3] = ((fd & 0x8000) << 8) | ((fd & 0x03e0) >> 2);
movdqa(xmm0, xmm2);
movdqa(xmm1, xmm2);
movdqa(xmm4, xmm2);
pcmpeqd(xmm7, xmm7);
psrld(xmm7, 27); // 0x0000001f
pand(xmm0, xmm7);
pslld(xmm0, 3);
pslld(xmm7, 10); // 0x00007c00
pand(xmm4, xmm7);
pslld(xmm4, 9);
por(xmm0, xmm4);
movdqa(xmm4, xmm1);
psrld(xmm7, 5); // 0x000003e0
pand(xmm1, xmm7);
psrld(xmm1, 2);
psllw(xmm7, 10); // 0x00008000
pand(xmm4, xmm7);
pslld(xmm4, 8);
por(xmm1, xmm4);
break;
}
}
// xmm5, xmm6 = src rb, ga
// xmm0, xmm1 = dst rb, ga
// xmm2, xmm3 = used
// xmm4, xmm7 = free
if(m_sel.pabe || (m_sel.aba != m_sel.abb) && (m_sel.abb == 0 || m_sel.abd == 0))
{
movdqa(xmm4, xmm5);
}
if(m_sel.aba != m_sel.abb)
{
// rb = c[aba * 2 + 0];
switch(m_sel.aba)
{
case 0: break;
case 1: movdqa(xmm5, xmm0); break;
case 2: pxor(xmm5, xmm5); break;
}
// rb = rb.sub16(c[abb * 2 + 0]);
switch(m_sel.abb)
{
case 0: psubw(xmm5, xmm4); break;
case 1: psubw(xmm5, xmm0); break;
case 2: break;
}
if(!(m_sel.fpsm == 1 && m_sel.abc == 1))
{
// GSVector4i a = abc < 2 ? c[abc * 2 + 1].yywwlh().sll16(7) : m_env.afix;
switch(m_sel.abc)
{
case 0:
case 1:
movdqa(xmm7, m_sel.abc ? xmm1 : xmm6);
pshuflw(xmm7, xmm7, _MM_SHUFFLE(3, 3, 1, 1));
pshufhw(xmm7, xmm7, _MM_SHUFFLE(3, 3, 1, 1));
psllw(xmm7, 7);
break;
case 2:
movdqa(xmm7, xmmword[&m_env.afix]);
break;
}
// rb = rb.modulate16<1>(a);
modulate16<1>(xmm5, xmm7);
}
// rb = rb.add16(c[abd * 2 + 0]);
switch(m_sel.abd)
{
case 0: paddw(xmm5, xmm4); break;
case 1: paddw(xmm5, xmm0); break;
case 2: break;
}
}
else
{
// rb = c[abd * 2 + 0];
switch(m_sel.abd)
{
case 0: break;
case 1: movdqa(xmm5, xmm0); break;
case 2: pxor(xmm5, xmm5); break;
}
}
if(m_sel.pabe)
{
// mask = (c[1] << 8).sra32(31);
movdqa(xmm0, xmm6);
pslld(xmm0, 8);
psrad(xmm0, 31);
// rb = c[0].blend8(rb, mask);
blend8r(xmm5, xmm4);
}
// xmm6 = src ga
// xmm1 = dst ga
// xmm5 = rb
// xmm7 = a
// xmm2, xmm3 = used
// xmm0, xmm4 = free
movdqa(xmm4, xmm6);
if(m_sel.aba != m_sel.abb)
{
// ga = c[aba * 2 + 1];
switch(m_sel.aba)
{
case 0: break;
case 1: movdqa(xmm6, xmm1); break;
case 2: pxor(xmm6, xmm6); break;
}
// ga = ga.sub16(c[abeb * 2 + 1]);
switch(m_sel.abb)
{
case 0: psubw(xmm6, xmm4); break;
case 1: psubw(xmm6, xmm1); break;
case 2: break;
}
if(!(m_sel.fpsm == 1 && m_sel.abc == 1))
{
// ga = ga.modulate16<1>(a);
modulate16<1>(xmm6, xmm7);
}
// ga = ga.add16(c[abd * 2 + 1]);
switch(m_sel.abd)
{
case 0: paddw(xmm6, xmm4); break;
case 1: paddw(xmm6, xmm1); break;
case 2: break;
}
}
else
{
// ga = c[abd * 2 + 1];
switch(m_sel.abd)
{
case 0: break;
case 1: movdqa(xmm6, xmm1); break;
case 2: pxor(xmm6, xmm6); break;
}
}
// xmm4 = src ga
// xmm5 = rb
// xmm6 = ga
// xmm2, xmm3 = used
// xmm0, xmm1, xmm7 = free
if(m_sel.pabe)
{
if(!m_cpu.has(util::Cpu::tSSE41))
{
// doh, previous blend8r overwrote xmm0 (sse41 uses pblendvb)
movdqa(xmm0, xmm4);
pslld(xmm0, 8);
psrad(xmm0, 31);
}
psrld(xmm0, 16); // zero out high words to select the source alpha in blend (so it also does mix16)
// ga = c[1].blend8(ga, mask).mix16(c[1]);
blend8r(xmm6, xmm4);
}
else
{
if(m_sel.fpsm != 1) // TODO: fm == 0xffxxxxxx
{
mix16(xmm6, xmm4, xmm7);
}
}
}
void GSDrawScanlineCodeGenerator::WriteFrame(int params)
{
const int _top = params + 4;
if(!m_sel.fwrite)
{
return;
}
if(m_sel.colclamp == 0)
{
// c[0] &= 0x000000ff;
// c[1] &= 0x000000ff;
pcmpeqd(xmm7, xmm7);
psrlw(xmm7, 8);
pand(xmm5, xmm7);
pand(xmm6, xmm7);
}
if(m_sel.fpsm == 2 && m_sel.dthe)
{
mov(eax, dword[esp + _top]);
and(eax, 3);
shl(eax, 5);
paddw(xmm5, xmmword[eax + (size_t)&m_env.dimx[0]]);
paddw(xmm6, xmmword[eax + (size_t)&m_env.dimx[1]]);
}
// GSVector4i fs = c[0].upl16(c[1]).pu16(c[0].uph16(c[1]));
movdqa(xmm7, xmm5);
punpcklwd(xmm5, xmm6);
punpckhwd(xmm7, xmm6);
packuswb(xmm5, xmm7);
if(m_sel.fba && m_sel.fpsm != 1)
{
// fs |= 0x80000000;
pcmpeqd(xmm7, xmm7);
pslld(xmm7, 31);
por(xmm5, xmm7);
}
if(m_sel.fpsm == 2)
{
// GSVector4i rb = fs & 0x00f800f8;
// GSVector4i ga = fs & 0x8000f800;
mov(eax, 0x00f800f8);
movd(xmm6, eax);
pshufd(xmm6, xmm6, _MM_SHUFFLE(0, 0, 0, 0));
mov(eax, 0x8000f800);
movd(xmm7, eax);
pshufd(xmm7, xmm7, _MM_SHUFFLE(0, 0, 0, 0));
movdqa(xmm4, xmm5);
pand(xmm4, xmm6);
pand(xmm5, xmm7);
// fs = (ga >> 16) | (rb >> 9) | (ga >> 6) | (rb >> 3);
movdqa(xmm6, xmm4);
movdqa(xmm7, xmm5);
psrld(xmm4, 3);
psrld(xmm6, 9);
psrld(xmm5, 6);
psrld(xmm7, 16);
por(xmm5, xmm4);
por(xmm7, xmm6);
por(xmm5, xmm7);
}
if(m_sel.rfb)
{
// fs = fs.blend(fd, fm);
blend(xmm5, xmm2, xmm3); // TODO: could be skipped in certain cases, depending on fpsm and fm
}
bool fast = m_sel.rfb && m_sel.fpsm < 2;
WritePixel(xmm5, xmm0, ebx, dl, fast, m_sel.fpsm);
}
void GSDrawScanlineCodeGenerator::ReadPixel(const Xmm& dst, const Reg32& addr)
{
movq(dst, qword[addr * 2 + (size_t)m_env.vm]);
movhps(dst, qword[addr * 2 + (size_t)m_env.vm + 8 * 2]);
}
void GSDrawScanlineCodeGenerator::WritePixel(const Xmm& src, const Xmm& temp, const Reg32& addr, const Reg8& mask, bool fast, int psm)
{
if(fast)
{
// if(fzm & 0x0f) GSVector4i::storel(&vm16[addr + 0], fs);
// if(fzm & 0xf0) GSVector4i::storeh(&vm16[addr + 8], fs);
test(mask, 0x0f);
je("@f");
movq(qword[addr * 2 + (size_t)m_env.vm], src);
L("@@");
test(mask, 0xf0);
je("@f");
movhps(qword[addr * 2 + (size_t)m_env.vm + 8 * 2], src);
L("@@");
}
else
{
// if(fzm & 0x03) WritePixel(fpsm, &vm16[addr + 0], fs.extract32<0>());
// if(fzm & 0x0c) WritePixel(fpsm, &vm16[addr + 2], fs.extract32<1>());
// if(fzm & 0x30) WritePixel(fpsm, &vm16[addr + 8], fs.extract32<2>());
// if(fzm & 0xc0) WritePixel(fpsm, &vm16[addr + 10], fs.extract32<3>());
test(mask, 0x03);
je("@f");
WritePixel(src, temp, addr, 0, psm);
L("@@");
test(mask, 0x0c);
je("@f");
WritePixel(src, temp, addr, 1, psm);
L("@@");
test(mask, 0x30);
je("@f");
WritePixel(src, temp, addr, 2, psm);
L("@@");
test(mask, 0xc0);
je("@f");
WritePixel(src, temp, addr, 3, psm);
L("@@");
}
}
void GSDrawScanlineCodeGenerator::WritePixel(const Xmm& src, const Xmm& temp, const Reg32& addr, uint8 i, int psm)
{
static const int offsets[4] = {0, 2, 8, 10};
Address dst = ptr[addr * 2 + (size_t)m_env.vm + offsets[i] * 2];
if(m_cpu.has(util::Cpu::tSSE41))
{
switch(psm)
{
case 0:
if(i == 0) movd(dst, src);
else pextrd(dst, src, i);
break;
case 1:
if(i == 0) movd(eax, src);
else pextrd(eax, src, i);
xor(eax, dst);
and(eax, 0xffffff);
xor(dst, eax);
break;
case 2:
pextrw(eax, src, i * 2);
mov(dst, ax);
break;
}
}
else
{
switch(psm)
{
case 0:
if(i == 0) movd(dst, src);
else {pshufd(temp, src, _MM_SHUFFLE(i, i, i, i)); movd(dst, temp);}
break;
case 1:
if(i == 0) movd(eax, src);
else {pshufd(temp, src, _MM_SHUFFLE(i, i, i, i)); movd(eax, temp);}
xor(eax, dst);
and(eax, 0xffffff);
xor(dst, eax);
break;
case 2:
pextrw(eax, src, i * 2);
mov(dst, ax);
break;
}
}
}
void GSDrawScanlineCodeGenerator::ReadTexel(const Xmm& dst, const Xmm& addr, const Xmm& temp1, const Xmm& temp2)
{
if(m_cpu.has(util::Cpu::tSSE41))
{
ReadTexel(dst, addr, 0);
ReadTexel(dst, addr, 1);
ReadTexel(dst, addr, 2);
ReadTexel(dst, addr, 3);
}
else
{
ReadTexel(dst, addr, 0);
psrldq(addr, 4); // shuffle instead? (1 2 3 0 ~ rotation)
ReadTexel(temp1, addr, 0);
psrldq(addr, 4);
punpckldq(dst, temp1);
ReadTexel(temp1, addr, 0);
psrldq(addr, 4);
ReadTexel(temp2, addr, 0);
// psrldq(addr, 4);
punpckldq(temp1, temp2);
punpcklqdq(dst, temp1);
}
}
void GSDrawScanlineCodeGenerator::ReadTexel(const Xmm& dst, const Xmm& addr, uint8 i)
{
if(!m_cpu.has(util::Cpu::tSSE41) && i > 0)
{
ASSERT(0);
}
if(i == 0) movd(eax, addr);
else pextrd(eax, addr, i);
if(m_sel.tlu) movzx(eax, byte[ebx + eax]);
const Address& src = m_sel.tlu ? ptr[eax * 4 + (size_t)m_env.clut] : ptr[ebx + eax * 4];
if(i == 0) movd(dst, src);
else pinsrd(dst, src, i);
}
template<int shift>
void GSDrawScanlineCodeGenerator::modulate16(const Xmm& a, const Operand& f)
{
if(shift == 0 && m_cpu.has(util::Cpu::tSSSE3))
{
pmulhrsw(a, f);
}
else
{
psllw(a, shift + 1);
pmulhw(a, f);
}
}
template<int shift>
void GSDrawScanlineCodeGenerator::lerp16(const Xmm& a, const Xmm& b, const Xmm& f)
{
psubw(a, b);
modulate16<shift>(a, f);
paddw(a, b);
}
void GSDrawScanlineCodeGenerator::mix16(const Xmm& a, const Xmm& b, const Xmm& temp)
{
if(m_cpu.has(util::Cpu::tSSE41))
{
pblendw(a, b, 0xaa);
}
else
{
pcmpeqd(temp, temp);
psrld(temp, 16);
pand(a, temp);
pandn(temp, b);
por(a, temp);
}
}
void GSDrawScanlineCodeGenerator::clamp16(const Xmm& a, const Xmm& temp)
{
packuswb(a, a);
if(m_cpu.has(util::Cpu::tSSE41))
{
pmovzxbw(a, a);
}
else
{
pxor(temp, temp);
punpcklbw(a, temp);
}
}
void GSDrawScanlineCodeGenerator::alltrue()
{
pmovmskb(eax, xmm7);
cmp(eax, 0xffff);
je("step", T_NEAR);
}
void GSDrawScanlineCodeGenerator::blend8(const Xmm& a, const Xmm& b)
{
if(m_cpu.has(util::Cpu::tSSE41))
{
pblendvb(a, b);
}
else
{
blend(a, b, xmm0);
}
}
void GSDrawScanlineCodeGenerator::blend(const Xmm& a, const Xmm& b, const Xmm& mask)
{
pand(b, mask);
pandn(mask, a);
por(b, mask);
movdqa(a, b);
}
void GSDrawScanlineCodeGenerator::blend8r(const Xmm& b, const Xmm& a)
{
if(m_cpu.has(util::Cpu::tSSE41))
{
pblendvb(a, b);
movdqa(b, a);
}
else
{
blendr(b, a, xmm0);
}
}
void GSDrawScanlineCodeGenerator::blendr(const Xmm& b, const Xmm& a, const Xmm& mask)
{
pand(b, mask);
pandn(mask, a);
por(b, mask);
}
const GSVector4i GSDrawScanlineCodeGenerator::m_test[8] =
{
GSVector4i::zero(),
GSVector4i(0xffffffff, 0x00000000, 0x00000000, 0x00000000),
GSVector4i(0xffffffff, 0xffffffff, 0x00000000, 0x00000000),
GSVector4i(0xffffffff, 0xffffffff, 0xffffffff, 0x00000000),
GSVector4i(0x00000000, 0xffffffff, 0xffffffff, 0xffffffff),
GSVector4i(0x00000000, 0x00000000, 0xffffffff, 0xffffffff),
GSVector4i(0x00000000, 0x00000000, 0x00000000, 0xffffffff),
GSVector4i::zero(),
};
|
[
"koeiprogenitor@bfa1b011-20a7-a6e3-c617-88e5d26e11c5"
] |
[
[
[
1,
2181
]
]
] |
19ab079efd51a3a289b4a77e8220cd1cd488e0b8
|
495afd01e6c5c99164438b6cfb88cce95e2d428d
|
/KinectWinLibTester/KinectWinLibTester.cpp
|
5596b51be7b7787df577f66091c5587cc7480cbb
|
[] |
no_license
|
swatkat/kinectwinlib
|
d4f86d9c5343058cfa633ec2d30bcec101fb31d5
|
c8a738c0039ba89f19eaffa98048908e5ea3e46d
|
refs/heads/master
| 2021-01-10T21:36:24.149422 | 2011-07-09T19:31:32 | 2011-07-09T19:31:32 | 32,264,174 | 0 | 0 | null | null | null | null |
UTF-8
|
C++
| false | false | 316 |
cpp
|
#include "KinectWinLibTester.h"
#include <conio.h>
int main( int argc, char* argv[] )
{
KinectWinMgr kinectMgr;
if( kinectMgr.NuiInit() )
{
printf( "\n\n************** PRESS ANY KEY TO EXIT *****************\n\n" );
_getch();
}
kinectMgr.NuiUnInit();
return 0;
}
|
[
"[email protected]@52b94231-4c76-c7fc-5287-54c55503817d"
] |
[
[
[
1,
14
]
]
] |
d09f592b7179c9eb2e25da707d04eb5f26ad919a
|
b14d5833a79518a40d302e5eb40ed5da193cf1b2
|
/cpp/extern/xercesc++/2.6.0/tests/UtilTests/CoreTests.hpp
|
198566a52a8d2dd652c63a12c302d1ff769a0b69
|
[
"Apache-2.0"
] |
permissive
|
andyburke/bitflood
|
dcb3fb62dad7fa5e20cf9f1d58aaa94be30e82bf
|
fca6c0b635d07da4e6c7fbfa032921c827a981d6
|
refs/heads/master
| 2016-09-10T02:14:35.564530 | 2011-11-17T09:51:49 | 2011-11-17T09:51:49 | 2,794,411 | 1 | 0 | null | null | null | null |
UTF-8
|
C++
| false | false | 2,004 |
hpp
|
/*
* Copyright 1999-2000,2004 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*
* $Log: CoreTests.hpp,v $
* Revision 1.9 2004/09/08 13:57:05 peiyongz
* Apache License Version 2.0
*
* Revision 1.8 2003/05/30 13:08:26 gareth
* move over to macros for std:: and iostream/iostream.h issues.
*
* Revision 1.7 2003/01/29 20:14:49 gareth
* updated for DOMTypeInfo tests.
*
* Revision 1.6 2002/11/05 21:47:36 tng
* Explicit code using namespace in application.
*
* Revision 1.5 2002/02/01 22:46:28 peiyongz
* sane_include
*
* Revision 1.4 2000/03/02 19:55:47 roddey
* This checkin includes many changes done while waiting for the
* 1.1.0 code to be finished. I can't list them all here, but a list is
* available elsewhere.
*
* Revision 1.3 2000/02/06 07:48:38 rahulj
* Year 2K copyright swat.
*
* Revision 1.2 2000/01/19 00:59:06 roddey
* Get rid of dependence on old utils output streams.
*
* Revision 1.1.1.1 1999/11/09 01:01:43 twl
* Initial checkin
*
* Revision 1.2 1999/11/08 20:42:26 rahul
* Swat for adding in Product name and CVS comment log variable.
*
*/
#include <xercesc/util/XMLException.hpp>
#include <xercesc/util/XMLString.hpp>
#include <xercesc/util/XMLUni.hpp>
#include <xercesc/util/PlatformUtils.hpp>
#if defined(XERCES_NEW_IOSTREAMS)
#include <iostream>
#else
#include <iostream.h>
#endif
XERCES_CPP_NAMESPACE_USE
|
[
"[email protected]"
] |
[
[
[
1,
65
]
]
] |
bf89f4f84d2f9e614610fdcae8b5f95c3c0ecc4d
|
84f06293f8d797a6be92a5cbdf81e6992717cc9d
|
/touch_tracker/tbeta/app/nuigroup/Configapp/src/Calibration/calibrationB.h
|
61180e07a1df25af93f8b8b4105f9fd82f530850
|
[] |
no_license
|
emailtoan/touchapi
|
bd7b8fa140741051670137d1b93cae61e1c7234a
|
54e41d3f1a05593e943129ef5b2c63968ff448b9
|
refs/heads/master
| 2016-09-07T18:43:51.754299 | 2008-10-17T06:18:43 | 2008-10-17T06:18:43 | 40,374,104 | 0 | 0 | null | null | null | null |
UTF-8
|
C++
| false | false | 2,263 |
h
|
#ifndef _CALIBRATION
#define _CALIBRATION
#define OF_ADDON_USING_OFXXMLSETTINGS // LOAD CONFIG.XML
#include "ofAddons.h"
//Used other calibration
#include "rect2d.h"
#include "vector2d.h"
class calibrationB
{
public:
calibrationB(); //constructor
//~calibrationB(); //destructor
void loadXMLSettings(); // Load Settings
void saveCalibration(); // Save Settings
//Calibration Methods
void setScreenScale(float s);
void setScreenBBox(rect2df & bbox);
void setGrid(int x, int y);
void setCamRes(int camWidth, int camHeight);
void initTriangles();
virtual vector2df *getScreenPoints() { return screenPoints; };
virtual vector2df *getCameraPoints() { return cameraPoints; };
float getScreenScale();
rect2df getScreenBBox() { return screenBB; };
void computeCameraToScreenMap();
void cameraToScreenPosition(float &x, float &y);
void cameraToScreenSpace(float &x, float &y);
void transformDimension(float &width, float &height);
void initScreenPoints();
void initCameraPoints(int camWidth, int camHeight);
// returns -1 if none found..
int findTriangleWithin(vector2df pt);
bool isPointInTriangle(vector2df p, vector2df a, vector2df b, vector2df c);
//! starts calibration
virtual void beginCalibration();
//! goes to the next step
virtual void nextCalibrationStep();
//! return to the last step
virtual void revertCalibrationStep();
void calculateBox();
bool bCalibrating;
int calibrationStep;
vector2df* screenPoints; // GRID_X * GRID_Y
vector2df* cameraPoints; // GRID_X * GRID_Y
rect2df screenBB;
int GRID_POINTS;
int GRID_X;
int GRID_Y;
float maxBoxX;
float minBoxX;
float maxBoxY;
float minBoxY;
private:
//---------------------------------------Calibration
//set Calibration Points
int GRID_INDICES;
int* triangles; // GRID_X * GRID_Y * 2t * 3i indices for the points
vector2df* cameraToScreenMap;
int _camWidth;
int _camHeight;
bool bscreenPoints;
bool bcameraPoints;
ofxXmlSettings calibrationXML;
string xmlStructure;
string message;
};
#endif
|
[
"cerupcat@5e10ba55-a837-0410-a92f-dfacd3436b42"
] |
[
[
[
1,
99
]
]
] |
42854a54d1e2d4a26bef8cfb440bfb7b681f8183
|
3182b05c41f13237825f1ee59d7a0eba09632cd5
|
/T3D/moveManager.h
|
81d962983f047952e662b4b2bd35729a51b40f1f
|
[] |
no_license
|
adhistac/ee-client-2-0
|
856e8e6ce84bfba32ddd8b790115956a763eec96
|
d225fc835fa13cb51c3e0655cb025eba24a8cdac
|
refs/heads/master
| 2021-01-17T17:13:48.618988 | 2010-01-04T17:35:12 | 2010-01-04T17:35:12 | null | 0 | 0 | null | null | null | null |
UTF-8
|
C++
| false | false | 1,991 |
h
|
//-----------------------------------------------------------------------------
// Torque 3D
// Copyright (C) GarageGames.com, Inc.
//-----------------------------------------------------------------------------
#ifndef _MOVEMANAGER_H_
#define _MOVEMANAGER_H_
#ifndef _PLATFORM_H_
#include "platform/platform.h"
#endif
enum MoveConstants {
MaxTriggerKeys = 6,
MaxMoveQueueSize = 45,
};
class BitStream;
struct Move
{
enum { ChecksumBits = 16, ChecksumMask = ((1<<ChecksumBits)-1), ChecksumMismatch = U32(-1) };
// packed storage rep, set in clamp
S32 px, py, pz;
U32 pyaw, ppitch, proll;
F32 x, y, z; // float -1 to 1
F32 yaw, pitch, roll; // 0-2PI
U32 id; // sync'd between server & client - debugging tool.
U32 sendCount;
U32 checksum;
bool deviceIsKeyboardMouse;
bool freeLook;
bool trigger[MaxTriggerKeys];
void pack(BitStream *stream, const Move * move = NULL);
void unpack(BitStream *stream, const Move * move = NULL);
void clamp();
void unclamp();
};
extern const Move NullMove;
class MoveManager
{
public:
static bool mDeviceIsKeyboardMouse;
static F32 mForwardAction;
static F32 mBackwardAction;
static F32 mUpAction;
static F32 mDownAction;
static F32 mLeftAction;
static F32 mRightAction;
static bool mFreeLook;
static F32 mPitch;
static F32 mYaw;
static F32 mRoll;
static F32 mPitchUpSpeed;
static F32 mPitchDownSpeed;
static F32 mYawLeftSpeed;
static F32 mYawRightSpeed;
static F32 mRollLeftSpeed;
static F32 mRollRightSpeed;
static F32 mXAxis_L;
static F32 mYAxis_L;
static F32 mXAxis_R;
static F32 mYAxis_R;
static U32 mTriggerCount[MaxTriggerKeys];
static U32 mPrevTriggerCount[MaxTriggerKeys];
static F32 mPitchCam;
static F32 mYawCam;
static F32 mDistanceCam;
static F32 mKeyYawCam;
static void init();
};
#endif
|
[
"[email protected]"
] |
[
[
[
1,
83
]
]
] |
3686aac279f379b206826e83beca8021c4877187
|
7707c79fe6a5b216a62bb175133249663a0fa12b
|
/trunk/DisplayList.cpp
|
b7b1ad185ca7d779de06b1dd43e9f17aeb32f38f
|
[] |
no_license
|
BackupTheBerlios/freepcb-svn
|
51be4b266e80f336045e2242b3388928c0b731f1
|
0ae28845832421c80bbdb10eae514a6e13d01034
|
refs/heads/master
| 2021-01-20T12:42:11.484059 | 2010-06-03T04:43:44 | 2010-06-03T04:43:44 | 40,441,767 | 0 | 0 | null | null | null | null |
UTF-8
|
C++
| false | false | 75,900 |
cpp
|
// DisplayList.cpp : implementation of class CDisplayList
//
// this is a linked-list of display elements
// each element is a primitive graphics object such as a line-segment,
// circle, annulus, etc.
//
#include "stdafx.h"
#include <math.h>
// dimensions passed to DisplayList from the application are in PCBU (i.e. nm)
// since the Win95/98 GDI uses 16-bit arithmetic, PCBU must be scaled to DU (i.e. mils)
//
//#define PCBU_PER_DU PCBU_PER_WU
//#define MIL_PER_DU NM_PER_MIL/PCBU_PER_DU // conversion from mils to display units
//#define DU_PER_MIL PCBU_PER_DU/NM_PER_MIL // conversion from display units to mils
#define DL_MAX_LAYERS 32
#define HILITE_POINT_W 10 // size/2 of selection box for points (mils)
// constructor
//
CDisplayList::CDisplayList( int pcbu_per_wu )
{
m_pcbu_per_wu = pcbu_per_wu;
// create lists for all layers
for( int layer=0; layer<MAX_LAYERS; layer++ )
{
// linked list for layer
m_start[layer].prev = 0; // first element
m_start[layer].next = &m_end[layer];
m_start[layer].magic = 0;
m_end[layer].next = 0; // last element
m_end[layer].prev = &m_start[layer];
m_end[layer].magic = 0;
// default colors, these should be overwritten with actual colors
m_rgb[layer][0] = layer*63; // R
m_rgb[layer][1] = (layer/4)*127; // G
m_rgb[layer][2] = (layer/8)*63; // B
// default order
m_layer_in_order[layer] = layer; // will be drawn from highest to lowest
m_order_for_layer[layer] = layer;
}
// miscellaneous
m_drag_flag = 0;
m_drag_num_lines = 0;
m_drag_line_pt = 0;
m_drag_num_ratlines = 0;
m_drag_ratline_start_pt = 0;
m_drag_ratline_end_pt = 0;
m_drag_ratline_width = 0;
m_cross_hairs = 0;
m_visual_grid_on = 0;
m_visual_grid_spacing = 0;
m_inflection_mode = IM_NONE;
}
// destructor
//
CDisplayList::~CDisplayList()
{
RemoveAll();
}
void CDisplayList::RemoveAllFromLayer( int layer )
{
// traverse list for layer, removing all elements
while( m_end[layer].prev != &m_start[layer] )
Remove( m_end[layer].prev );
}
void CDisplayList::RemoveAll()
{
// traverse lists for all layers, removing all elements
for( int layer=0; layer<MAX_LAYERS; layer++ )
{
RemoveAllFromLayer( layer );
}
if( m_drag_line_pt )
{
free( m_drag_line_pt );
m_drag_line_pt = 0;
}
if( m_drag_ratline_start_pt )
{
free( m_drag_ratline_start_pt );
m_drag_ratline_start_pt = 0;
}
if( m_drag_ratline_end_pt )
{
free( m_drag_ratline_end_pt );
m_drag_ratline_end_pt = 0;
}
}
// Set conversion parameters between world coords (used by elements in
// display list) and window coords (pixels)
//
// enter with:
// client_r = window client rectangle (pixels)
// screen_r = window client rectangle in screen coords (pixels)
// pane_org_x = starting x-coord of PCB drawing area in client rect (pixels)
// pane_bottom_h = height of bottom pane (pixels)
// pcb units per pixel = nm per pixel
// org_x = x-coord of left edge of drawing area (pcb units)
// org_y = y-coord of bottom edge of drawing area (pcb units)
//
// note that the actual scale factor is set by the arguments to
// SetWindowExt and SetViewportExt, and may be slightly different for x and y
//
void CDisplayList::SetMapping( CRect *client_r, CRect *screen_r, int pane_org_x, int pane_bottom_h,
double pcbu_per_pixel, int org_x, int org_y )
{
m_client_r = client_r; // pixels
m_screen_r = screen_r; // pixels
m_pane_org_x = pane_org_x; // pixels
m_bottom_pane_h = pane_bottom_h; // pixels
m_pane_org_y = client_r->bottom - pane_bottom_h; // pixels
m_scale = pcbu_per_pixel/m_pcbu_per_wu; // world units per pixel
m_org_x = org_x/m_pcbu_per_wu; // world units
m_org_y = org_y/m_pcbu_per_wu; // world units
//now set extents
double rw = m_client_r.Width(); // width of client area (pixels)
double rh = m_client_r.Height(); // height of client area (pixels)
double ext_x = rw*pcbu_per_pixel/m_pcbu_per_wu; // width in WU
double ext_y = rh*pcbu_per_pixel/m_pcbu_per_wu; // height in WU
int div = 1, mult = 1;
if( m_pcbu_per_wu >=25400 )
{
// this is necessary for Win95/98 (16-bit GDI)
int ext_max = max( ext_x, ext_y );
if( ext_max > 30000 )
div = ext_max/15000;
}
else
mult = m_pcbu_per_wu;
if( ext_x*mult/div > INT_MAX )
ASSERT(0);
if( ext_y*mult/div > INT_MAX )
ASSERT(0);
w_ext_x = ext_x*mult/div;
v_ext_x = rw*mult/div;
w_ext_y = ext_y*mult/div;
v_ext_y = -rh*mult/div;
m_wu_per_pixel_x = (double)w_ext_x/v_ext_x; // actual ratios
m_wu_per_pixel_y = (double)w_ext_y/v_ext_y;
m_pcbu_per_pixel_x = m_wu_per_pixel_x * m_pcbu_per_wu;
m_pcbu_per_pixel_y = m_wu_per_pixel_y * m_pcbu_per_wu;
m_max_x = m_org_x + m_wu_per_pixel_x*(client_r->right-pane_org_x) + 2; // world units
m_max_y = m_org_y - m_wu_per_pixel_y*client_r->bottom + 2; // world units
}
// add graphics element used for selection
//
dl_element * CDisplayList::AddSelector( id id, void * ptr, int layer, int gtype, int visible,
int w, int holew, int x, int y, int xf, int yf, int xo, int yo,
int radius )
{
dl_element * test = Add( id, ptr, LAY_SELECTION, gtype, visible,
w, holew, x, y, xf, yf, xo, yo, radius, layer );
test->layer = layer;
return test;
}
// Add entry to end of list, returns pointer to element created.
//
// Dimensional units for input parameters are PCBU
//
dl_element * CDisplayList::Add( id id, void * ptr, int layer, int gtype, int visible,
int w, int holew, int x, int y, int xf, int yf, int xo, int yo,
int radius, int orig_layer )
{
// create new element and link into list
dl_element * new_element = new dl_element;
new_element->prev = m_end[layer].prev;
new_element->next = &m_end[layer];
new_element->prev->next = new_element;
new_element->next->prev = new_element;
// now copy data from entry into element
new_element->magic = DL_MAGIC;
new_element->id = id;
new_element->ptr = ptr;
new_element->gtype = gtype;
new_element->visible = visible;
new_element->w = w/m_pcbu_per_wu;
new_element->holew = holew/m_pcbu_per_wu;
new_element->x = x/m_pcbu_per_wu;
new_element->xf = xf/m_pcbu_per_wu;
new_element->y = y/m_pcbu_per_wu;
new_element->yf = yf/m_pcbu_per_wu;
new_element->x_org = xo/m_pcbu_per_wu;
new_element->y_org = yo/m_pcbu_per_wu;
new_element->radius = radius/m_pcbu_per_wu;
new_element->sel_vert = 0;
new_element->layer = layer;
new_element->orig_layer = orig_layer;
new_element->dlist = this;
return new_element;
}
// set element parameters in PCBU
//
void CDisplayList::Set_gtype( dl_element * el, int gtype )
{
if( el)
el->gtype = gtype;
}
void CDisplayList::Set_visible( dl_element * el, int visible )
{
if( el)
el->visible = visible;
}
void CDisplayList::Set_sel_vert( dl_element * el, int sel_vert )
{
if( el)
el->sel_vert = sel_vert;
}
void CDisplayList::Set_w( dl_element * el, int w )
{
if( el)
el->w = w/m_pcbu_per_wu;
}
void CDisplayList::Set_holew( dl_element * el, int holew )
{
if( el)
el->holew = holew/m_pcbu_per_wu;
}
void CDisplayList::Set_x_org( dl_element * el, int x_org )
{
if( el)
el->x_org = x_org/m_pcbu_per_wu;
}
void CDisplayList::Set_y_org( dl_element * el, int y_org )
{
if( el)
el->y_org = y_org/m_pcbu_per_wu;
}
void CDisplayList::Set_x( dl_element * el, int x )
{
if( el)
el->x = x/m_pcbu_per_wu;
}
void CDisplayList::Set_y( dl_element * el, int y )
{
if( el)
el->y = y/m_pcbu_per_wu;
}
void CDisplayList::Set_xf( dl_element * el, int xf )
{
if( el)
el->xf = xf/m_pcbu_per_wu;
}
void CDisplayList::Set_yf( dl_element * el, int yf )
{
if( el)
el->yf = yf/m_pcbu_per_wu;
}
void CDisplayList::Set_layer( dl_element * el, int layer )
{
if( el)
el->layer = layer;
}
void CDisplayList::Set_radius( dl_element * el, int radius )
{
if( el)
el->radius = radius/m_pcbu_per_wu;
}
void CDisplayList::Set_id( dl_element * el, id * id )
{
if( el)
el->id = *id;
}
void CDisplayList::Move( dl_element * el, int dx, int dy )
{
el->x += dx;
el->y += dy;
el->x_org += dx;
el->y_org += dy;
el->xf += dx;
el->yf += dy;
}
// get element parameters in PCBU
//
void * CDisplayList::Get_ptr( dl_element * el ) { return el->ptr; }
int CDisplayList::Get_gtype( dl_element * el ) { return el->gtype; }
int CDisplayList::Get_visible( dl_element * el ) { return el->visible; }
int CDisplayList::Get_sel_vert( dl_element * el ) { return el->sel_vert; }
int CDisplayList::Get_w( dl_element * el ) { return el->w*m_pcbu_per_wu; }
int CDisplayList::Get_holew( dl_element * el ) { return el->holew*m_pcbu_per_wu; }
int CDisplayList::Get_x_org( dl_element * el ) { return el->x_org*m_pcbu_per_wu; }
int CDisplayList::Get_y_org( dl_element * el ) { return el->y_org*m_pcbu_per_wu; }
int CDisplayList::Get_x( dl_element * el ) { return el->x*m_pcbu_per_wu; }
int CDisplayList::Get_y( dl_element * el ) { return el->y*m_pcbu_per_wu; }
int CDisplayList::Get_xf( dl_element * el ) { return el->xf*m_pcbu_per_wu; }
int CDisplayList::Get_yf( dl_element * el ) { return el->yf*m_pcbu_per_wu; }
int CDisplayList::Get_radius( dl_element * el ) { return el->radius*m_pcbu_per_wu; }
int CDisplayList::Get_layer( dl_element * el ) { return el->layer; }
id CDisplayList::Get_id( dl_element * el ) { return el->id; }
void CDisplayList::Get_Endpoints(CPoint *cpi, CPoint *cpf)
{
cpi->x = m_drag_xi*m_pcbu_per_wu; cpi->y = m_drag_yi*m_pcbu_per_wu;
cpf->x = m_drag_xf*m_pcbu_per_wu; cpf->y = m_drag_yf*m_pcbu_per_wu;
}
// Remove element from list, return id
//
id CDisplayList::Remove( dl_element * element )
{
if( !element )
{
id no_id;
return no_id;
}
if( element->magic != DL_MAGIC )
{
ASSERT(0);
id no_id;
return no_id;
}
// remove links to this element
element->next->prev = element->prev;
element->prev->next = element->next;
// destroy element
id el_id = element->id;
delete( element );
return el_id;
}
// Draw the display list using device DC or memory DC
//
void CDisplayList::Draw( CDC * dDC )
{
CDC * pDC;
if( memDC )
pDC = memDC;
else
pDC = dDC;
pDC->SetBkColor( RGB(0, 0, 0) );
// create pens and brushes
CPen * old_pen;
CPen black_pen( PS_SOLID, 1, RGB( 0, 0, 0 ) );
CPen white_pen( PS_SOLID, 1, RGB( 255, 255, 255 ) );
CPen grid_pen( PS_SOLID, 1,
RGB( m_rgb[LAY_VISIBLE_GRID][0],
m_rgb[LAY_VISIBLE_GRID][1],
m_rgb[LAY_VISIBLE_GRID][2] ) );
CPen backgnd_pen( PS_SOLID, 1,
RGB( m_rgb[LAY_BACKGND][0],
m_rgb[LAY_BACKGND][1],
m_rgb[LAY_BACKGND][2] ) );
CPen board_pen( PS_SOLID, 1,
RGB( m_rgb[LAY_BOARD_OUTLINE][0],
m_rgb[LAY_BOARD_OUTLINE][1],
m_rgb[LAY_BOARD_OUTLINE][2] ) );
CBrush * old_brush;
CBrush black_brush( RGB( 0, 0, 0 ) );
CBrush backgnd_brush( RGB( m_rgb[LAY_BACKGND][0],
m_rgb[LAY_BACKGND][1],
m_rgb[LAY_BACKGND][2] ) );
// paint it background color
old_brush = pDC->SelectObject( &backgnd_brush );
old_pen = pDC->SelectObject( &black_pen );
CRect client_rect;
client_rect.left = m_org_x;
client_rect.right = m_max_x;
client_rect.bottom = m_org_y;
client_rect.top = m_max_y;
pDC->Rectangle( &client_rect );
// visual grid
if( m_visual_grid_on && (m_visual_grid_spacing/m_scale)>5 && m_vis[LAY_VISIBLE_GRID] )
{
int startix = m_org_x/m_visual_grid_spacing;
int startiy = m_org_y/m_visual_grid_spacing;
double start_grid_x = startix*m_visual_grid_spacing;
double start_grid_y = startiy*m_visual_grid_spacing;
for( double ix=start_grid_x; ix<m_max_x; ix+=m_visual_grid_spacing )
{
for( double iy=start_grid_y; iy<m_max_y; iy+=m_visual_grid_spacing )
{
pDC->SetPixel( ix, iy,
RGB( m_rgb[LAY_VISIBLE_GRID][0],
m_rgb[LAY_VISIBLE_GRID][1],
m_rgb[LAY_VISIBLE_GRID][2] ) );
}
}
}
// now traverse the lists, starting with the layer in the last element
// of the m_order[] array
int nlines = 0;
int size_of_2_pixels = 2*m_scale;
for( int order=(MAX_LAYERS-1); order>=0; order-- )
{
int layer = m_layer_in_order[order];
if( !m_vis[layer] || layer == LAY_SELECTION )
continue;
CPen line_pen( PS_SOLID, 1, RGB( m_rgb[layer][0], m_rgb[layer][1], m_rgb[layer][2] ) );
CBrush fill_brush( RGB( m_rgb[layer][0], m_rgb[layer][1], m_rgb[layer][2] ) );
pDC->SelectObject( &line_pen );
pDC->SelectObject( &fill_brush );
dl_element * el = &m_start[layer];
while( el->next->next )
{
el = el->next;
if( el->visible && m_vis[el->orig_layer] )
{
int xi = el->x;
int xf = el->xf;
int yi = el->y;
int yf = el->yf;
int w = el->w;
if( el->gtype == DL_CIRC || el->gtype == DL_HOLLOW_CIRC )
{
if( xi-w/2 < m_max_x && xi+w/2 > m_org_x
&& yi-w/2 < m_max_y && yi+w/2 > m_org_y )
{
if( el->gtype == DL_HOLLOW_CIRC )
pDC->SelectObject( GetStockObject( HOLLOW_BRUSH ) );
pDC->Ellipse( xi - w/2, yi - w/2, xi + w/2, yi + w/2 );
if( el->gtype == DL_HOLLOW_CIRC )
pDC->SelectObject( fill_brush );
}
}
if( el->gtype == DL_HOLE )
{
if( xi-w/2 < m_max_x && xi+w/2 > m_org_x
&& yi-w/2 < m_max_y && yi+w/2 > m_org_y )
{
if( w>size_of_2_pixels )
pDC->Ellipse( xi - w/2, yi - w/2, xi + w/2, yi + w/2 );
}
}
else if( el->gtype == DL_CENTROID )
{
// x,y are center coords; w = width;
// xf,yf define arrow end-point for P&P orientation
if( xi-w/2 < m_max_x && xi+w/2 > m_org_x
&& yi-w/2 < m_max_y && yi+w/2 > m_org_y )
{
pDC->SelectObject( GetStockObject( HOLLOW_BRUSH ) );
pDC->Ellipse( xi - w/4, yi - w/4, xi + w/4, yi + w/4 );
pDC->SelectObject( fill_brush );
xi = el->x - el->w/2;
xf = el->x + el->w/2;
yi = el->y - el->w/2;
yf = el->y + el->w/2;
pDC->MoveTo( xi, yi );
pDC->LineTo( xf, yf );
pDC->MoveTo( xf, yi );
pDC->LineTo( xi, yf );
pDC->MoveTo( el->x, el->y ); // p&p arrow
pDC->LineTo( el->xf, el->yf ); //
if( el->y == el->yf )
{
// horizontal arrow
pDC->LineTo( el->xf - (el->xf - el->x)/4,
el->yf + w/4 );
pDC->LineTo( el->xf - (el->xf - el->x)/4,
el->yf - w/4 );
pDC->LineTo( el->xf, el->yf );
}
else if( el->x == el->xf )
{
// vertical arrow
pDC->LineTo( el->xf + w/4, el->yf - (el->yf - el->y)/4 );
pDC->LineTo( el->xf - w/4, el->yf - (el->yf - el->y)/4 );
pDC->LineTo( el->xf, el->yf );
}
else
ASSERT(0);
int w_pp = el->w/10;
nlines += 2;
}
}
else if( el->gtype == DL_DONUT )
{
if( xi-w/2 < m_max_x && xi+w/2 > m_org_x
&& yi-w/2 < m_max_y && yi+w/2 > m_org_y )
{
int thick = (w - el->holew)/2;
int ww = w - thick;
int holew = el->holew;
int size_of_2_pixels = m_scale;
if( thick < size_of_2_pixels )
{
holew = w - 2*size_of_2_pixels;
if( holew < 0 )
holew = 0;
thick = (w - holew)/2;
ww = w - thick;
}
if( w-el->holew > 0 )
{
CPen pen( PS_SOLID, thick, RGB( m_rgb[layer][0], m_rgb[layer][1], m_rgb[layer][2] ) );
pDC->SelectObject( &pen );
pDC->SelectObject( &backgnd_brush );
pDC->Ellipse( xi - ww/2, yi - ww/2, xi + ww/2, yi + ww/2 );
pDC->SelectObject( line_pen );
pDC->SelectObject( fill_brush );
}
else
{
CPen backgnd_pen( PS_SOLID, 1,
RGB( m_rgb[LAY_BACKGND][0],
m_rgb[LAY_BACKGND][1],
m_rgb[LAY_BACKGND][2] ) );
pDC->SelectObject( &backgnd_pen );
pDC->SelectObject( &backgnd_brush );
pDC->Ellipse( xi - holew/2, yi - holew/2, xi + holew/2, yi + holew/2 );
pDC->SelectObject( line_pen );
pDC->SelectObject( fill_brush );
}
}
}
else if( el->gtype == DL_SQUARE )
{
if( xi-w/2 < m_max_x && xi+w/2 > m_org_x
&& yi-w/2 < m_max_y && yi+w/2 > m_org_y )
{
int holew = el->holew;
pDC->Rectangle( xi - w/2, yi - w/2, xi + w/2, yi + w/2 );
if( holew )
{
pDC->SelectObject( &backgnd_brush );
pDC->SelectObject( &backgnd_pen );
pDC->Ellipse( xi - holew/2, yi - holew/2,
xi + holew/2, yi + holew/2 );
pDC->SelectObject( fill_brush );
pDC->SelectObject( line_pen );
}
}
}
else if( el->gtype == DL_OCTAGON || el->gtype == DL_HOLLOW_OCTAGON )
{
if( xi-w/2 < m_max_x && xi+w/2 > m_org_x
&& yi-w/2 < m_max_y && yi+w/2 > m_org_y )
{
const double pi = 3.14159265359;
POINT pt[8];
double angle = pi/8.0;
for( int iv=0; iv<8; iv++ )
{
pt[iv].x = el->x + 0.5 * el->w * cos(angle);
pt[iv].y = el->y + 0.5 * el->w * sin(angle);
angle += pi/4.0;
}
int holew = el->holew;
if( el->gtype == DL_HOLLOW_OCTAGON )
pDC->SelectObject( GetStockObject( HOLLOW_BRUSH ) );
pDC->Polygon( pt, 8 );
if( el->gtype == DL_HOLLOW_OCTAGON )
pDC->SelectObject( fill_brush );
if( holew )
{
pDC->SelectObject( &backgnd_brush );
pDC->SelectObject( &backgnd_pen );
pDC->Ellipse( xi - holew/2, yi - holew/2,
xi + holew/2, yi + holew/2 );
pDC->SelectObject( fill_brush );
pDC->SelectObject( line_pen );
}
}
}
else if( el->gtype == DL_RECT )
{
if( xf < xi )
{
xf = xi;
xi = el->xf;
}
if( yf < yi )
{
yf = yi;
yi = el->yf;
}
if( xi < m_max_x && xf > m_org_x && yi < m_max_y && yf > m_org_y )
{
int holew = el->holew;
pDC->Rectangle( xi, yi, xf, yf );
if( holew )
{
pDC->SelectObject( &black_brush );
pDC->SelectObject( &black_pen );
pDC->Ellipse( el->x_org - holew/2, el->y_org - holew/2,
el->x_org + holew/2, el->y_org + holew/2 );
pDC->SelectObject( fill_brush );
pDC->SelectObject( line_pen );
}
}
}
else if( el->gtype == DL_HOLLOW_RECT )
{
if( xf < xi )
{
xf = xi;
xi = el->xf;
}
if( yf < yi )
{
yf = yi;
yi = el->yf;
}
if( xi < m_max_x && xf > m_org_x
&& yi < m_max_y && yf > m_org_y )
{
pDC->MoveTo( xi, yi );
pDC->LineTo( xf, yi );
pDC->LineTo( xf, yf );
pDC->LineTo( xi, yf );
pDC->LineTo( xi, yi );
nlines += 4;
}
}
else if( el->gtype == DL_OVAL || el->gtype == DL_HOLLOW_OVAL )
{
if( xf < xi )
{
xf = xi;
xi = el->xf;
}
if( yf < yi )
{
yf = yi;
yi = el->yf;
}
if( xi < m_max_x && xf > m_org_x && yi < m_max_y && yf > m_org_y )
{
int h = abs(xf-xi);
int v = abs(yf-yi);
int r = min(h,v);
if( el->gtype == DL_HOLLOW_OVAL )
pDC->SelectObject( GetStockObject( HOLLOW_BRUSH ) );
pDC->RoundRect( xi, yi, xf, yf, r, r );
if( el->gtype == DL_HOLLOW_OVAL )
pDC->SelectObject( fill_brush );
int holew = el->holew;
if( el->holew )
{
pDC->SelectObject( &black_brush );
pDC->SelectObject( &black_pen );
pDC->Ellipse( el->x_org - holew/2, el->y_org - holew/2,
el->x_org + holew/2, el->y_org + holew/2 );
pDC->SelectObject( fill_brush );
pDC->SelectObject( line_pen );
}
}
}
else if( el->gtype == DL_RRECT || el->gtype == DL_HOLLOW_RRECT )
{
if( xf < xi )
{
xf = xi;
xi = el->xf;
}
if( yf < yi )
{
yf = yi;
yi = el->yf;
}
if( xi < m_max_x && xf > m_org_x && yi < m_max_y && yf > m_org_y )
{
int holew = el->holew;
if( el->gtype == DL_HOLLOW_RRECT )
pDC->SelectObject( GetStockObject( HOLLOW_BRUSH ) );
pDC->RoundRect( xi, yi, xf, yf, 2*el->radius, 2*el->radius );
if( el->gtype == DL_HOLLOW_RRECT )
pDC->SelectObject( fill_brush );
if( holew )
{
pDC->SelectObject( &black_brush );
pDC->SelectObject( &black_pen );
pDC->Ellipse( el->x_org - holew/2, el->y_org - holew/2,
el->x_org + holew/2, el->y_org + holew/2 );
pDC->SelectObject( fill_brush );
pDC->SelectObject( line_pen );
}
}
}
else if( el->gtype == DL_RECT_X )
{
if( xf < xi )
{
xf = xi;
xi = el->xf;
}
if( yf < yi )
{
yf = yi;
yi = el->yf;
}
if( xi < m_max_x && xf > m_org_x
&& yi < m_max_y && yf > m_org_y )
{
pDC->MoveTo( el->x, el->y );
pDC->LineTo( el->xf, el->y );
pDC->LineTo( el->xf, el->yf );
pDC->LineTo( el->x, el->yf );
pDC->LineTo( el->x, el->y );
pDC->MoveTo( el->x, el->y );
pDC->LineTo( el->xf, el->yf );
pDC->MoveTo( el->x, el->yf );
pDC->LineTo( el->xf, el->y );
nlines += 4;
}
}
else if( el->gtype == DL_ARC_CW )
{
if( ( (el->xf >= el->x && el->x < m_max_x && el->xf > m_org_x)
|| (el->xf < el->x && el->xf < m_max_x && el->x > m_org_x) )
&& ( (el->yf >= el->y && el->y < m_max_y && el->yf > m_org_y)
|| (el->yf < el->y && el->yf < m_max_y && el->y > m_org_y) ) )
{
CPen pen( PS_SOLID, el->w, RGB( m_rgb[layer][0], m_rgb[layer][1], m_rgb[layer][2] ) );
pDC->SelectObject( &pen );
DrawArc( pDC, DL_ARC_CW, el->x, el->y, el->xf, el->yf );
pDC->SelectObject( line_pen );
}
}
else if( el->gtype == DL_ARC_CCW )
{
if( ( (el->xf >= el->x && el->x < m_max_x && el->xf > m_org_x)
|| (el->xf < el->x && el->xf < m_max_x && el->x > m_org_x) )
&& ( (el->yf >= el->y && el->y < m_max_y && el->yf > m_org_y)
|| (el->yf < el->y && el->yf < m_max_y && el->y > m_org_y) ) )
{
CPen pen( PS_SOLID, el->w, RGB( m_rgb[layer][0], m_rgb[layer][1], m_rgb[layer][2] ) );
pDC->SelectObject( &pen );
DrawArc( pDC, DL_ARC_CCW, el->x, el->y, el->xf, el->yf );
pDC->SelectObject( line_pen );
}
}
else if( el->gtype == DL_X )
{
xi = el->x - el->w/2;
xf = el->x + el->w/2;
yi = el->y - el->w/2;
yf = el->y + el->w/2;
if( xi < m_max_x && xf > m_org_x
&& yi < m_max_y && yf > m_org_y )
{
pDC->MoveTo( xi, yi );
pDC->LineTo( xf, yf );
pDC->MoveTo( xf, yi );
pDC->LineTo( xi, yf );
nlines += 2;
}
}
else if( el->gtype == DL_LINE )
{
// only draw line segments which are in viewport
// viewport bounds, enlarged to account for line thickness
int Yb = m_org_y - w/2; // y-coord of viewport top
int Yt = m_max_y + w/2; // y-coord of bottom
int Xl = m_org_x - w/2; // x-coord of left edge
int Xr = m_max_x - w/2; // x-coord of right edge
// line segment from (xi,yi) to (xf,yf)
int draw_flag = 0;
// now test for all conditions where drawing is necessary
if( xi==xf )
{
// vertical line
if( yi<yf )
{
// upward
if( yi<=Yt && yf>=Yb && xi<=Xr && xi>=Xl )
draw_flag = 1;
}
else
{
// downward
if( yf<=Yt && yi>=Yb && xi<=Xr && xi>=Xl )
draw_flag = 1;
}
}
else if( yi==yf )
{
// horizontal line
if( xi<xf )
{
// rightward
if( xi<=Xr && xf>=Xl && yi<=Yt && yi>=Yb )
draw_flag = 1;
}
else
{
// leftward
if( xf<=Xr && xi>=Xl && yi<=Yt && yi>=Yb )
draw_flag = 1;
}
}
else if( !((xi<Xl&&xf<Xl)||(xi>Xr&&xf>Xr)||(yi<Yb&&yf<Yb)||(yi>Yt&&yf>Yt)) )
{
// oblique line
// not entirely above or below or right or left of viewport
// get slope b and intercept a so that y=a+bx
double b = (double)(yf-yi)/(xf-xi);
int a = yi - int(b*xi);
// now test for line in viewport
if( abs((yf-yi)*(Xr-Xl)) > abs((xf-xi)*(Yt-Yb)) )
{
// line is more vertical than window diagonal
int x1 = int((Yb-a)/b);
if( x1>=Xl && x1<=Xr)
draw_flag = 1; // intercepts bottom of screen
else
{
int x2 = int((Yt-a)/b);
if( x2>=Xl && x2<=Xr )
draw_flag = 1; // intercepts top of screen
}
}
else
{
// line is more horizontal than window diagonal
int y1 = int(a + b*Xl);
if( y1>=Yb && y1<=Yt )
draw_flag = 1; // intercepts left edge of screen
else
{
int y2 = a + int(b*Xr);
if( y2>=Yb && y2<=Yt )
draw_flag = 1; // intercepts right edge of screen
}
}
}
// now draw the line segment if not clipped
if( draw_flag )
{
CPen pen( PS_SOLID, w, RGB( m_rgb[layer][0], m_rgb[layer][1], m_rgb[layer][2] ) );
pDC->SelectObject( &pen );
pDC->MoveTo( xi, yi );
pDC->LineTo( xf, yf );
pDC->SelectObject( line_pen );
nlines++;
}
}
}
}
// restore original objects
pDC->SelectObject( old_pen );
pDC->SelectObject( old_brush );
}
// origin
CRect r;
r.top = 25*NM_PER_MIL/m_pcbu_per_wu;
r.left = -25*NM_PER_MIL/m_pcbu_per_wu;
r.right = 25*NM_PER_MIL/m_pcbu_per_wu;
r.bottom = -25*NM_PER_MIL/m_pcbu_per_wu;
pDC->SelectObject( &grid_pen );
pDC->SelectObject( GetStockObject( HOLLOW_BRUSH ) );
pDC->MoveTo( -100*NM_PER_MIL/m_pcbu_per_wu, 0 );
pDC->LineTo( -25*NM_PER_MIL/m_pcbu_per_wu, 0 );
pDC->MoveTo( 100*NM_PER_MIL/m_pcbu_per_wu, 0 );
pDC->LineTo( 25*NM_PER_MIL/m_pcbu_per_wu, 0 );
pDC->MoveTo( 0, -100*NM_PER_MIL/m_pcbu_per_wu );
pDC->LineTo( 0, -25*NM_PER_MIL/m_pcbu_per_wu );
pDC->MoveTo( 0, 100*NM_PER_MIL/m_pcbu_per_wu );
pDC->LineTo( 0, 25*NM_PER_MIL/m_pcbu_per_wu );
pDC->Ellipse( r );
pDC->SelectObject( old_pen );
pDC->SelectObject( old_brush );
// if dragging, draw drag lines or shape
int old_ROP2 = pDC->GetROP2();
pDC->SetROP2( R2_XORPEN );
if( m_drag_num_lines )
{
// draw line array
CPen drag_pen( PS_SOLID, 1, RGB( m_rgb[m_drag_layer][0],
m_rgb[m_drag_layer][1], m_rgb[m_drag_layer][2] ) );
CPen * old_pen = pDC->SelectObject( &drag_pen );
for( int il=0; il<m_drag_num_lines; il++ )
{
pDC->MoveTo( m_drag_x+m_drag_line_pt[2*il].x, m_drag_y+m_drag_line_pt[2*il].y );
pDC->LineTo( m_drag_x+m_drag_line_pt[2*il+1].x, m_drag_y+m_drag_line_pt[2*il+1].y );
}
pDC->SelectObject( old_pen );
}
if( m_drag_num_ratlines )
{
// draw ratline array
CPen drag_pen( PS_SOLID, m_drag_ratline_width, RGB( m_rgb[m_drag_layer][0],
m_rgb[m_drag_layer][1], m_rgb[m_drag_layer][2] ) );
CPen * old_pen = pDC->SelectObject( &drag_pen );
for( int il=0; il<m_drag_num_ratlines; il++ )
{
pDC->MoveTo( m_drag_ratline_start_pt[il].x, m_drag_ratline_start_pt[il].y );
pDC->LineTo( m_drag_x+m_drag_ratline_end_pt[il].x, m_drag_y+m_drag_ratline_end_pt[il].y );
}
pDC->SelectObject( old_pen );
}
if( m_drag_flag )
{
// 4. Redraw the three segments:
if(m_drag_shape == DS_SEGMENT)
{
pDC->MoveTo( m_drag_xb, m_drag_yb );
// draw first segment
CPen pen0( PS_SOLID, m_drag_w0, RGB( m_rgb[m_drag_layer_0][0],
m_rgb[m_drag_layer_0][1], m_rgb[m_drag_layer_0][2] ) );
CPen * old_pen = pDC->SelectObject( &pen0 );
pDC->LineTo( m_drag_xi, m_drag_yi );
// draw second segment
CPen pen1( PS_SOLID, m_drag_w1, RGB( m_rgb[m_drag_layer_1][0],
m_rgb[m_drag_layer_1][1], m_rgb[m_drag_layer_1][2] ) );
pDC->SelectObject( &pen1 );
pDC->LineTo( m_drag_xf, m_drag_yf );
// draw third segment
if(m_drag_style2 != DSS_NONE)
{
CPen pen2( PS_SOLID, m_drag_w2, RGB( m_rgb[m_drag_layer_2][0],
m_rgb[m_drag_layer_2][1], m_rgb[m_drag_layer_2][2] ) );
pDC->SelectObject( &pen2 );
pDC->LineTo( m_drag_xe, m_drag_ye );
}
pDC->SelectObject( old_pen );
}
// draw drag shape, if used
if( m_drag_shape == DS_LINE_VERTEX || m_drag_shape == DS_LINE )
{
CPen pen_w( PS_SOLID, m_drag_w1, RGB( m_rgb[m_drag_layer_1][0],
m_rgb[m_drag_layer_1][1], m_rgb[m_drag_layer_1][2] ) );
// draw dragged shape
pDC->SelectObject( &pen_w );
if( m_drag_style1 == DSS_STRAIGHT )
{
if( m_inflection_mode == IM_NONE )
{
pDC->MoveTo( m_drag_xi, m_drag_yi );
pDC->LineTo( m_drag_x, m_drag_y );
}
else
{
CPoint pi( m_drag_xi, m_drag_yi );
CPoint pf( m_drag_x, m_drag_y );
CPoint p = GetInflectionPoint( pi, pf, m_inflection_mode );
pDC->MoveTo( m_drag_xi, m_drag_yi );
if( p != pi )
pDC->LineTo( p.x, p.y );
pDC->LineTo( m_drag_x, m_drag_y );
}
m_last_inflection_mode = m_inflection_mode;
}
else if( m_drag_style1 == DSS_ARC_CW )
DrawArc( pDC, DL_ARC_CW, m_drag_xi, m_drag_yi, m_drag_x, m_drag_y );
else if( m_drag_style1 == DSS_ARC_CCW )
DrawArc( pDC, DL_ARC_CCW, m_drag_xi, m_drag_yi, m_drag_x, m_drag_y );
else
ASSERT(0);
if( m_drag_shape == DS_LINE_VERTEX )
{
CPen pen( PS_SOLID, m_drag_w2, RGB( m_rgb[m_drag_layer_2][0],
m_rgb[m_drag_layer_2][1], m_rgb[m_drag_layer_2][2] ) );
pDC->SelectObject( &pen );
if( m_drag_style2 == DSS_STRAIGHT )
pDC->LineTo( m_drag_xf, m_drag_yf );
else if( m_drag_style2 == DSS_ARC_CW )
DrawArc( pDC, DL_ARC_CW, m_drag_x, m_drag_y, m_drag_xf, m_drag_yf );
else if( m_drag_style2 == DSS_ARC_CCW )
DrawArc( pDC, DL_ARC_CCW, m_drag_x, m_drag_y, m_drag_xf, m_drag_yf );
else
ASSERT(0);
pDC->SelectObject( old_pen );
}
pDC->SelectObject( old_pen );
// see if leading via needs to be drawn
if( m_drag_via_drawn )
{
// draw or undraw via
int thick = (m_drag_via_w - m_drag_via_holew)/2;
int w = m_drag_via_w - thick;
int holew = m_drag_via_holew;
// CPen pen( PS_SOLID, thick, RGB( m_rgb[LAY_PAD_THRU][0], m_rgb[LAY_PAD_THRU][1], m_rgb[LAY_PAD_THRU][2] ) );
CPen pen( PS_SOLID, thick, RGB( m_rgb[m_drag_layer_1][0], m_rgb[m_drag_layer_1][1], m_rgb[m_drag_layer_1][2] ) );
CPen * old_pen = pDC->SelectObject( &pen );
CBrush black_brush( RGB( 0, 0, 0 ) );
CBrush * old_brush = pDC->SelectObject( &black_brush );
pDC->Ellipse( m_drag_xi - w/2, m_drag_yi - w/2, m_drag_xi + w/2, m_drag_yi + w/2 );
pDC->SelectObject( old_brush );
pDC->SelectObject( old_pen );
}
}
else if( m_drag_shape == DS_ARC_STRAIGHT || m_drag_shape == DS_ARC_CW || m_drag_shape == DS_ARC_CCW )
{
CPen pen_w( PS_SOLID, m_drag_w1, RGB( m_rgb[m_drag_layer_1][0],
m_rgb[m_drag_layer_1][1], m_rgb[m_drag_layer_1][2] ) );
// redraw dragged shape
pDC->SelectObject( &pen_w );
if( m_drag_shape == DS_ARC_STRAIGHT )
DrawArc( pDC, DL_LINE, m_drag_x, m_drag_y, m_drag_xi, m_drag_yi );
else if( m_drag_shape == DS_ARC_CW )
DrawArc( pDC, DL_ARC_CW, m_drag_xi, m_drag_yi, m_drag_x, m_drag_y );
else if( m_drag_shape == DS_ARC_CCW )
DrawArc( pDC, DL_ARC_CCW, m_drag_xi, m_drag_yi, m_drag_x, m_drag_y );
pDC->SelectObject( old_pen );
m_last_drag_shape = m_drag_shape;
}
}
// if cross hairs, draw them
if( m_cross_hairs )
{
// draw cross-hairs
COLORREF bk = pDC->SetBkColor( RGB(0,0,0) );
CPen pen( PS_DOT, 0, RGB( 128, 128, 128 ) );
pDC->SelectObject( &pen );
int x = m_cross_bottom.x;
int y = m_cross_left.y;
m_cross_left.x = m_org_x;
m_cross_right.x = m_max_x;
m_cross_bottom.y = m_org_y;
m_cross_top.y = m_max_y;
if( x-m_org_x > y-m_org_y )
{
// bottom-left cursor line intersects m_org_y
m_cross_botleft.x = x - (y - m_org_y);
m_cross_botleft.y = m_org_y;
}
else
{
// bottom-left cursor line intersects m_org_x
m_cross_botleft.x = m_org_x;
m_cross_botleft.y = y - (x - m_org_x);
}
if( m_max_x-x > y-m_org_y )
{
// bottom-right cursor line intersects m_org_y
m_cross_botright.x = x + (y - m_org_y);
m_cross_botright.y = m_org_y;
}
else
{
// bottom-right cursor line intersects m_max_x
m_cross_botright.x = m_max_x;
m_cross_botright.y = y - (m_max_x - x);
}
if( x-m_org_x > m_max_y-y )
{
// top-left cursor line intersects m_max_y
m_cross_topleft.x = x - (m_max_y - y);
m_cross_topleft.y = m_max_y;
}
else
{
// top-left cursor line intersects m_org_x
m_cross_topleft.x = m_org_x;
m_cross_topleft.y = y + (x - m_org_x);
}
if( m_max_x-x > m_max_y-y )
{
// top-right cursor line intersects m_max_y
m_cross_topright.x = x + (m_max_y - y);
m_cross_topright.y = m_max_y;
}
else
{
// top-right cursor line intersects m_max_x
m_cross_topright.x = m_max_x;
m_cross_topright.y = y + (m_max_x - x);
}
pDC->MoveTo( m_cross_left );
pDC->LineTo( m_cross_right );
pDC->MoveTo( m_cross_bottom );
pDC->LineTo( m_cross_top );
if( m_cross_hairs == 2 )
{
pDC->MoveTo( m_cross_topleft );
pDC->LineTo( m_cross_botright );
pDC->MoveTo( m_cross_botleft );
pDC->LineTo( m_cross_topright );
}
pDC->SelectObject( old_pen );
pDC->SetBkColor( bk );
}
pDC->SetROP2( old_ROP2 );
// restore original objects
pDC->SelectObject( old_pen );
pDC->SelectObject( old_brush );
// double-buffer to screen
if( memDC )
{
dDC->BitBlt( m_org_x, m_org_y, m_max_x-m_org_x, m_max_y-m_org_y,
pDC, m_org_x, m_org_y, SRCCOPY );
}
}
// set the display color for a layer
//
void CDisplayList::SetLayerRGB( int layer, int r, int g, int b )
{
m_rgb[layer][0] = r;
m_rgb[layer][1] = g;
m_rgb[layer][2] = b;
}
void CDisplayList::SetLayerVisible( int layer, BOOL vis )
{
m_vis[layer] = vis;
}
// test x,y for a hit on an item in the selection layer
// creates arrays with layer and id of each hit item
// assigns priority based on layer and id
// then returns pointer to item with highest priority
// If exclude_id != NULL, excludes item with
// id == exclude_id and ptr == exclude_ptr
// If include_id != NULL, only include items that match include_id[]
// where n_include_ids is size of array, and
// where 0's in include_id[] fields are treated as wildcards
//
void * CDisplayList::TestSelect( int x, int y, id * sel_id, int * sel_layer,
id * exclude_id, void * exclude_ptr,
id * include_id, int n_include_ids )
{
enum {
MAX_HITS = 10000
};
int nhits = 0;
int hit_layer[MAX_HITS];
id hit_id[MAX_HITS];
void * hit_ptr[MAX_HITS];
int hit_priority[MAX_HITS];
int xx = x/m_pcbu_per_wu;
int yy = y/m_pcbu_per_wu;
// traverse the list, looking for selection shapes
dl_element * el = &m_start[LAY_SELECTION];
while( el->next != &m_end[LAY_SELECTION] )
{
el = el->next;
// don't select anything on an invisible layer
if( !m_vis[el->layer] )
continue;
// don't select anything invisible
if( el->visible == 0 )
continue;
if( el->gtype == DL_HOLLOW_RECT || el->gtype == DL_RECT_X )
{
// found selection rectangle, test for hit
if( ( (xx>el->x && xx<el->xf) || (xx<el->x && xx>el->xf) )
&& ( (yy>el->y && yy<el->yf) || (yy<el->y && yy>el->yf) ) )
{
// OK, hit
hit_layer[nhits] = el->layer;
hit_id[nhits] = el->id;
hit_ptr[nhits] = el->ptr;
nhits++;
if( nhits >= MAX_HITS )
ASSERT(0);
}
}
else if( el->gtype == DL_LINE )
{
// found selection line, test for hit (within 4 pixels or line width+3 mils )
//** int w = max( el->w/2+3*DU_PER_MIL, int(4.0*m_scale) );
int w = max( el->w/2, int(4.0*m_scale) );
int test = TestLineHit( el->x, el->y, el->xf, el->yf, xx, yy, w );
if( test )
{
// OK, hit
hit_layer[nhits] = el->layer;
hit_id[nhits] = el->id;
hit_ptr[nhits] = el->ptr;
nhits++;
if( nhits >= MAX_HITS )
ASSERT(0);
}
}
else if( el->gtype == DL_HOLLOW_CIRC )
{
// found hollow circle, test for hit (within 3 mils or 4 pixels)
//** int dr = max( 3*DU_PER_MIL, int(4.0*m_scale) );
int dr = 4.0*m_scale;
int w = el->w/2;
int x = el->x;
int y = el->y;
int d = Distance( x, y, xx, yy );
if( abs(w-d) < dr )
{
// OK, hit
hit_layer[nhits] = el->layer;
hit_id[nhits] = el->id;
hit_ptr[nhits] = el->ptr;
nhits++;
if( nhits >= MAX_HITS )
ASSERT(0);
}
}
else if( el->gtype == DL_ARC_CW || el->gtype == DL_ARC_CCW )
{
// found selection rectangle, test for hit
if( ( (xx>el->x && xx<el->xf) || (xx<el->x && xx>el->xf) )
&& ( (yy>el->y && yy<el->yf) || (yy<el->y && yy>el->yf) ) )
{
// OK, hit
hit_layer[nhits] = el->layer;
hit_id[nhits] = el->id;
hit_ptr[nhits] = el->ptr;
nhits++;
if( nhits >= MAX_HITS )
ASSERT(0);
}
}
else
ASSERT(0); // bad element
}
// now return highest priority hit
if( nhits == 0 )
{
// no hit
id no_id;
*sel_id = no_id;
*sel_layer = 0;
return NULL;
}
else
{
// assign priority to each hit, track maximum, exclude exclude_id item
int best_hit = -1;
int best_hit_priority = 0;
for( int i=0; i<nhits; i++ )
{
BOOL excluded_hit = FALSE;
BOOL included_hit = TRUE;
if( exclude_id )
{
if( hit_id[i] == *exclude_id && hit_ptr[i] == exclude_ptr )
excluded_hit = TRUE;
}
if( include_id )
{
included_hit = FALSE;
for( int inc=0; inc<n_include_ids; inc++ )
{
id * inc_id = &include_id[inc];
if( inc_id->type == hit_id[i].type
&& ( inc_id->st == 0 || inc_id->st == hit_id[i].st )
&& ( inc_id->i == 0 || inc_id->i == hit_id[i].i )
&& ( inc_id->sst == 0 || inc_id->sst == hit_id[i].sst )
&& ( inc_id->ii == 0 || inc_id->ii == hit_id[i].ii ) )
{
included_hit = TRUE;
break;
}
}
}
if( !excluded_hit && included_hit )
{
// OK, valid hit, now assign priority
// start with reversed layer drawing order * 10
// i.e. last drawn = highest priority
int priority = (MAX_LAYERS - m_order_for_layer[hit_layer[i]])*10;
// bump priority for small items which may be overlapped by larger items on same layer
if( hit_id[i].type == ID_PART && hit_id[i].st == ID_SEL_REF_TXT )
priority++;
else if( hit_id[i].type == ID_PART && hit_id[i].st == ID_SEL_VALUE_TXT )
priority++;
else if( hit_id[i].type == ID_BOARD && hit_id[i].st == ID_BOARD_OUTLINE && hit_id[i].sst == ID_SEL_CORNER )
priority++;
else if( hit_id[i].type == ID_NET && hit_id[i].st == ID_AREA && hit_id[i].sst == ID_SEL_CORNER )
priority++;
hit_priority[i] = priority;
if( priority >= best_hit_priority )
{
best_hit_priority = priority;
best_hit = i;
}
}
}
if( best_hit == -1 )
{
id no_id;
*sel_id = no_id;
*sel_layer = 0;
return NULL;
}
*sel_id = hit_id[best_hit];
*sel_layer = hit_layer[best_hit];
return hit_ptr[best_hit];
}
}
// Start dragging arrays of drag lines and ratlines
// Assumes that arrays have already been set up using MakeLineArray, etc.
// If no arrays, just drags point
//
int CDisplayList::StartDraggingArray( CDC * pDC, int xx, int yy, int vert, int layer, int crosshair )
{
// convert to display units
int x = xx/m_pcbu_per_wu;
int y = yy/m_pcbu_per_wu;
// cancel dragging non-array shape
m_drag_flag = 0;
m_drag_shape = 0;
// set up for dragging array
m_drag_x = x; // "grab point"
m_drag_y = y;
m_drag_vert = vert; // set axis for flipping item to opposite side of PCB
m_drag_layer = layer;
m_drag_angle = 0;
m_drag_side = 0;
SetUpCrosshairs( crosshair, x, y );
// done
return 0;
}
// Start dragging rectangle
//
int CDisplayList::StartDraggingRectangle( CDC * pDC, int x, int y, int xi, int yi,
int xf, int yf, int vert, int layer )
{
// create drag lines
CPoint p1(xi,yi);
CPoint p2(xf,yi);
CPoint p3(xf,yf);
CPoint p4(xi,yf);
MakeDragLineArray( 4 );
AddDragLine( p1, p2 );
AddDragLine( p2, p3 );
AddDragLine( p3, p4 );
AddDragLine( p4, p1 );
StartDraggingArray( pDC, x, y, vert, layer );
// done
return 0;
}
// Start dragging line
//
int CDisplayList::StartDraggingRatLine( CDC * pDC, int x, int y, int xi, int yi,
int layer, int w, int crosshair )
{
// create drag line
CPoint p1(xi,yi);
CPoint p2(x,y);
MakeDragRatlineArray( 1, w );
AddDragRatline( p1, p2 );
StartDraggingArray( pDC, xi, yi, 0, layer, crosshair );
// done
return 0;
}
// set style of arc being dragged, using CPolyLine styles
//
void CDisplayList::SetDragArcStyle( int style )
{
if( style == CPolyLine::STRAIGHT )
m_drag_shape = DS_ARC_STRAIGHT;
else if( style == CPolyLine::ARC_CW )
m_drag_shape = DS_ARC_CW;
else if( style == CPolyLine::ARC_CCW )
m_drag_shape = DS_ARC_CCW;
}
// Start dragging arc endpoint, using style from CPolyLine
// Use the layer color and width w
//
int CDisplayList::StartDraggingArc( CDC * pDC, int style, int xx, int yy, int xi, int yi,
int layer, int w, int crosshair )
{
int x = xx/m_pcbu_per_wu;
int y = yy/m_pcbu_per_wu;
// set up for dragging
m_drag_flag = 1;
if( style == CPolyLine::STRAIGHT )
m_drag_shape = DS_ARC_STRAIGHT;
else if( style == CPolyLine::ARC_CW )
m_drag_shape = DS_ARC_CW;
else if( style == CPolyLine::ARC_CCW )
m_drag_shape = DS_ARC_CCW;
m_drag_x = x; // position of endpoint (at cursor)
m_drag_y = y;
m_drag_xi = xi/m_pcbu_per_wu; // start point
m_drag_yi = yi/m_pcbu_per_wu;
m_drag_side = 0;
m_drag_layer_1 = layer;
m_drag_w1 = w/m_pcbu_per_wu;
// set up cross hairs
SetUpCrosshairs( crosshair, x, y );
//Redraw
// Draw( pDC );
// done
return 0;
}
// Start dragging the selected line endpoint
// Use the layer1 color and width w
//
int CDisplayList::StartDraggingLine( CDC * pDC, int x, int y, int xi, int yi, int layer1, int w,
int layer_no_via, int via_w, int via_holew,
int crosshair, int style, int inflection_mode )
{
// set up for dragging
m_drag_flag = 1;
m_drag_shape = DS_LINE;
m_drag_x = x/m_pcbu_per_wu; // position of endpoint (at cursor)
m_drag_y = y/m_pcbu_per_wu;
m_drag_xi = xi/m_pcbu_per_wu; // initial vertex
m_drag_yi = yi/m_pcbu_per_wu;
m_drag_side = 0;
m_drag_layer_1 = layer1;
m_drag_w1 = w/m_pcbu_per_wu;
m_drag_style1 = style;
m_drag_layer_no_via = layer_no_via;
m_drag_via_w = via_w/m_pcbu_per_wu;
m_drag_via_holew = via_holew/m_pcbu_per_wu;
m_drag_via_drawn = 0;
m_inflection_mode = inflection_mode;
m_last_inflection_mode = IM_NONE;
// set up cross hairs
SetUpCrosshairs( crosshair, x, y );
//Redraw
// Draw( pDC );
// done
return 0;
}
// Start dragging line vertex (i.e. vertex between 2 line segments)
// Use the layer1 color and width w1 for the first segment from (xi,yi) to the vertex,
// Use the layer2 color and width w2 for the second segment from the vertex to (xf,yf)
// While dragging, insert via at start point of first segment if layer1 != layer_no_via
// using via parameters via_w and via_holew
// Note that layer1 may be changed while dragging by ChangeRouting Layer()
// If dir = 1, swap start and end points
//
int CDisplayList::StartDraggingLineVertex( CDC * pDC, int x, int y,
int xi, int yi, int xf, int yf,
int layer1, int layer2, int w1, int w2, int style1, int style2,
int layer_no_via, int via_w, int via_holew, int dir,
int crosshair )
{
// set up for dragging
m_drag_flag = 1;
m_drag_shape = DS_LINE_VERTEX;
m_drag_x = x/m_pcbu_per_wu; // position of central vertex (at cursor)
m_drag_y = y/m_pcbu_per_wu;
if( dir == 0 )
{
// routing forward
m_drag_xi = xi/m_pcbu_per_wu; // initial vertex
m_drag_yi = yi/m_pcbu_per_wu;
m_drag_xf = xf/m_pcbu_per_wu; // final vertex
m_drag_yf = yf/m_pcbu_per_wu;
}
else
{
// routing backward
m_drag_xi = xf/m_pcbu_per_wu; // initial vertex
m_drag_yi = yf/m_pcbu_per_wu;
m_drag_xf = xi/m_pcbu_per_wu; // final vertex
m_drag_yf = yi/m_pcbu_per_wu;
}
m_drag_side = 0;
m_drag_layer_1 = layer1;
m_drag_layer_2 = layer2;
m_drag_w1 = w1/m_pcbu_per_wu;
m_drag_w2 = w2/m_pcbu_per_wu;
m_drag_style1 = style1;
m_drag_style2 = style2;
m_drag_layer_no_via = layer_no_via;
m_drag_via_w = via_w/m_pcbu_per_wu;
m_drag_via_holew = via_holew/m_pcbu_per_wu;
m_drag_via_drawn = 0;
// set up cross hairs
SetUpCrosshairs( crosshair, x, y );
//Redraw
Draw( pDC );
// done
return 0;
}
// Start dragging line segment (i.e. line segment between 2 vertices)
// Use the layer0 color and width w0 for the "before" segment from (xb,yb) to (xi, yi),
// Use the layer1 color and width w1 for the moving segment from (xi,yi) to (xf, yf),
// Use the layer2 color and width w2 for the ending segment from (xf, yf) to (xe,ye)
// While dragging, insert via at (xi, yi) if layer1 != layer_no_via1, insert via
// at (xf, yf) if layer2 != layer_no_via.
// using via parameters via_w and via_holew
// Note that layer1 may be changed while dragging by ChangeRouting Layer()
// If dir = 1, swap start and end points
//
int CDisplayList::StartDraggingLineSegment( CDC * pDC, int x, int y,
int xb, int yb,
int xi, int yi,
int xf, int yf,
int xe, int ye,
int layer0, int layer1, int layer2,
int w0, int w1, int w2,
int style0, int style1, int style2,
int layer_no_via, int via_w, int via_holew,
int crosshair )
{
// set up for dragging
m_drag_flag = 1;
m_drag_shape = DS_SEGMENT;
m_drag_x = x/m_pcbu_per_wu; // position of reference point (at cursor)
m_drag_y = y/m_pcbu_per_wu;
m_drag_xb = xb/m_pcbu_per_wu; // vertex before
m_drag_yb = yb/m_pcbu_per_wu;
m_drag_xi = xi/m_pcbu_per_wu; // initial vertex
m_drag_yi = yi/m_pcbu_per_wu;
m_drag_xf = xf/m_pcbu_per_wu; // final vertex
m_drag_yf = yf/m_pcbu_per_wu;
m_drag_xe = xe/m_pcbu_per_wu; // End vertex
m_drag_ye = ye/m_pcbu_per_wu;
m_drag_side = 0;
m_drag_layer_0 = layer0;
m_drag_layer_1 = layer1;
m_drag_layer_2 = layer2;
m_drag_w0 = w0/m_pcbu_per_wu;
m_drag_w1 = w1/m_pcbu_per_wu;
m_drag_w2 = w2/m_pcbu_per_wu;
m_drag_style0 = style0;
m_drag_style1 = style1;
m_drag_style2 = style2;
m_drag_layer_no_via = layer_no_via;
m_drag_via_w = via_w/m_pcbu_per_wu;
m_drag_via_holew = via_holew/m_pcbu_per_wu;
m_drag_via_drawn = 0;
// set up cross hairs
SetUpCrosshairs( crosshair, x, y );
//Redraw
Draw( pDC );
// done
return 0;
}
// Drag graphics with cursor
//
void CDisplayList::Drag( CDC * pDC, int x, int y )
{
// convert from PCB to display coords
int xx = x/m_pcbu_per_wu;
int yy = y/m_pcbu_per_wu;
// set XOR pen mode for dragging
int old_ROP2 = pDC->SetROP2( R2_XORPEN );
//**** there are three dragging modes, which may be used simultaneously ****//
// drag array of lines, used to make complex graphics like a part
if( m_drag_num_lines )
{
CPen drag_pen( PS_SOLID, 1, RGB( m_rgb[m_drag_layer][0],
m_rgb[m_drag_layer][1], m_rgb[m_drag_layer][2] ) );
CPen * old_pen = pDC->SelectObject( &drag_pen );
for( int il=0; il<m_drag_num_lines; il++ )
{
// undraw
pDC->MoveTo( m_drag_x+m_drag_line_pt[2*il].x, m_drag_y+m_drag_line_pt[2*il].y );
pDC->LineTo( m_drag_x+m_drag_line_pt[2*il+1].x, m_drag_y+m_drag_line_pt[2*il+1].y );
// redraw
pDC->MoveTo( xx+m_drag_line_pt[2*il].x, yy+m_drag_line_pt[2*il].y );
pDC->LineTo( xx+m_drag_line_pt[2*il+1].x, yy+m_drag_line_pt[2*il+1].y );
}
pDC->SelectObject( old_pen );
}
// drag array of rubberband lines, used for ratlines to dragged part
if( m_drag_num_ratlines )
{
CPen drag_pen( PS_SOLID, 1, RGB( m_rgb[m_drag_layer][0],
m_rgb[m_drag_layer][1], m_rgb[m_drag_layer][2] ) );
CPen * old_pen = pDC->SelectObject( &drag_pen );
for( int il=0; il<m_drag_num_ratlines; il++ )
{
// undraw
pDC->MoveTo( m_drag_ratline_start_pt[il].x, m_drag_ratline_start_pt[il].y );
pDC->LineTo( m_drag_x+m_drag_ratline_end_pt[il].x, m_drag_y+m_drag_ratline_end_pt[il].y );
// draw
pDC->MoveTo( m_drag_ratline_start_pt[il].x, m_drag_ratline_start_pt[il].y );
pDC->LineTo( xx+m_drag_ratline_end_pt[il].x, yy+m_drag_ratline_end_pt[il].y );
}
pDC->SelectObject( old_pen );
}
// draw special shapes, used for polyline sides and trace segments
if( m_drag_flag && ( m_drag_shape == DS_LINE_VERTEX || m_drag_shape == DS_LINE ) )
{
// drag rubberband trace segment, or vertex between two rubberband segments
// used for routing traces
CPen pen_w( PS_SOLID, m_drag_w1, RGB( m_rgb[m_drag_layer_1][0],
m_rgb[m_drag_layer_1][1], m_rgb[m_drag_layer_1][2] ) );
// undraw first segment
CPen * old_pen = pDC->SelectObject( &pen_w );
{
if( m_drag_style1 == DSS_STRAIGHT )
{
if( m_last_inflection_mode == IM_NONE )
{
pDC->MoveTo( m_drag_xi, m_drag_yi );
pDC->LineTo( m_drag_x, m_drag_y );
}
else
{
CPoint pi( m_drag_xi, m_drag_yi );
CPoint pf( m_drag_x, m_drag_y );
CPoint p = GetInflectionPoint( pi, pf, m_last_inflection_mode );
pDC->MoveTo( m_drag_xi, m_drag_yi );
if( p != pi )
pDC->LineTo( p.x, p.y );
pDC->LineTo( m_drag_x, m_drag_y );
}
}
else if( m_drag_style1 == DSS_ARC_CW )
DrawArc( pDC, DL_ARC_CW, m_drag_xi, m_drag_yi, m_drag_x, m_drag_y );
else if( m_drag_style1 == DSS_ARC_CCW )
DrawArc( pDC, DL_ARC_CCW, m_drag_xi, m_drag_yi, m_drag_x, m_drag_y );
else
ASSERT(0);
if( m_drag_shape == DS_LINE_VERTEX )
{
// undraw second segment
CPen pen( PS_SOLID, m_drag_w2, RGB( m_rgb[m_drag_layer_2][0],
m_rgb[m_drag_layer_2][1], m_rgb[m_drag_layer_2][2] ) );
CPen * old_pen = pDC->SelectObject( &pen );
if( m_drag_style2 == DSS_STRAIGHT )
pDC->LineTo( m_drag_xf, m_drag_yf );
else if( m_drag_style2 == DSS_ARC_CW )
DrawArc( pDC, DL_ARC_CW, m_drag_x, m_drag_y, m_drag_xf, m_drag_yf );
else if( m_drag_style2 == DSS_ARC_CCW )
DrawArc( pDC, DL_ARC_CCW, m_drag_x, m_drag_y, m_drag_xf, m_drag_yf );
else
ASSERT(0);
pDC->SelectObject( old_pen );
}
// draw first segment
if( m_drag_style1 == DSS_STRAIGHT )
{
if( m_inflection_mode == IM_NONE )
{
pDC->MoveTo( m_drag_xi, m_drag_yi );
pDC->LineTo( xx, yy );
}
else
{
CPoint pi( m_drag_xi, m_drag_yi );
CPoint pf( xx, yy );
CPoint p = GetInflectionPoint( pi, pf, m_inflection_mode );
pDC->MoveTo( m_drag_xi, m_drag_yi );
if( p != pi )
pDC->LineTo( p.x, p.y );
pDC->LineTo( xx, yy );
}
m_last_inflection_mode = m_inflection_mode;
}
else if( m_drag_style1 == DSS_ARC_CW )
DrawArc( pDC, DL_ARC_CW, m_drag_xi, m_drag_yi, xx, yy );
else if( m_drag_style1 == DSS_ARC_CCW )
DrawArc( pDC, DL_ARC_CCW, m_drag_xi, m_drag_yi, xx, yy );
else
ASSERT(0);
if( m_drag_shape == DS_LINE_VERTEX )
{
// draw second segment
CPen pen( PS_SOLID, m_drag_w2, RGB( m_rgb[m_drag_layer_2][0],
m_rgb[m_drag_layer_2][1], m_rgb[m_drag_layer_2][2] ) );
CPen * old_pen = pDC->SelectObject( &pen );
if( m_drag_style2 == DSS_STRAIGHT )
pDC->LineTo( m_drag_xf, m_drag_yf );
else if( m_drag_style2 == DSS_ARC_CW )
DrawArc( pDC, DL_ARC_CW, xx, yy, m_drag_xf, m_drag_yf );
else if( m_drag_style2 == DSS_ARC_CCW )
DrawArc( pDC, DL_ARC_CCW, xx, yy, m_drag_xf, m_drag_yf );
else
ASSERT(0);
pDC->SelectObject( old_pen );
}
// see if leading via needs to be changed
if( ( (m_drag_layer_no_via != 0 && m_drag_layer_1 != m_drag_layer_no_via) && !m_drag_via_drawn )
|| (!(m_drag_layer_no_via != 0 && m_drag_layer_1 != m_drag_layer_no_via) && m_drag_via_drawn ) )
{
// draw or undraw via
int thick = (m_drag_via_w - m_drag_via_holew)/2;
int w = m_drag_via_w - thick;
int holew = m_drag_via_holew;
// CPen pen( PS_SOLID, thick, RGB( m_rgb[LAY_PAD_THRU][0], m_rgb[LAY_PAD_THRU][1], m_rgb[LAY_PAD_THRU][2] ) );
CPen pen( PS_SOLID, thick, RGB( m_rgb[m_drag_layer_1][0], m_rgb[m_drag_layer_1][1], m_rgb[m_drag_layer_1][2] ) );
CPen * old_pen = pDC->SelectObject( &pen );
{
CBrush black_brush( RGB( 0, 0, 0 ) );
CBrush * old_brush = pDC->SelectObject( &black_brush );
pDC->Ellipse( m_drag_xi - w/2, m_drag_yi - w/2, m_drag_xi + w/2, m_drag_yi + w/2 );
pDC->SelectObject( old_brush );
}
pDC->SelectObject( old_pen );
m_drag_via_drawn = 1 - m_drag_via_drawn;
}
}
pDC->SelectObject( old_pen );
}
// move a trace segment
else if( m_drag_flag && m_drag_shape == DS_SEGMENT )
{
{
ASSERT(m_drag_style0 == DSS_STRAIGHT);
pDC->MoveTo( m_drag_xb, m_drag_yb );
// undraw first segment
CPen pen0( PS_SOLID, m_drag_w0, RGB( m_rgb[m_drag_layer_0][0],
m_rgb[m_drag_layer_0][1], m_rgb[m_drag_layer_0][2] ) );
CPen * old_pen = pDC->SelectObject( &pen0 );
pDC->LineTo( m_drag_xi, m_drag_yi );
// undraw second segment
ASSERT(m_drag_style1 == DSS_STRAIGHT);
CPen pen1( PS_SOLID, m_drag_w1, RGB( m_rgb[m_drag_layer_1][0],
m_rgb[m_drag_layer_1][1], m_rgb[m_drag_layer_1][2] ) );
pDC->SelectObject( &pen1 );
pDC->LineTo( m_drag_xf, m_drag_yf );
// undraw third segment
if(m_drag_style2 == DSS_STRAIGHT) // Could also be DSS_NONE (this segment only)
{
CPen pen2( PS_SOLID, m_drag_w2, RGB( m_rgb[m_drag_layer_2][0],
m_rgb[m_drag_layer_2][1], m_rgb[m_drag_layer_2][2] ) );
pDC->SelectObject( &pen2 );
pDC->LineTo( m_drag_xe, m_drag_ye );
}
pDC->SelectObject( old_pen );
}
// Adjust the two vertices, (xi, yi) and (xf, yf) based on the movement of xx and yy
// relative to m_drag_x and m_drag_y:
// 1. Move the endpoints of (xi, yi), (xf, yf) of the line by the mouse movement. This
// is just temporary, since the final ending position is determined by the intercept
// points with the leading and trailing segments:
int new_xi = m_drag_xi + xx - m_drag_x; // Check sign here.
int new_yi = m_drag_yi + yy - m_drag_y;
int new_xf = m_drag_xf + xx - m_drag_x;
int new_yf = m_drag_yf + yy - m_drag_y;
int old_xb_dir = sign(m_drag_xi - m_drag_xb);
int old_yb_dir = sign(m_drag_yi - m_drag_yb);
int old_xi_dir = sign(m_drag_xf - m_drag_xi);
int old_yi_dir = sign(m_drag_yf - m_drag_yi);
int old_xe_dir = sign(m_drag_xe - m_drag_xf);
int old_ye_dir = sign(m_drag_ye - m_drag_yf);
// 2. Find the intercept between the extended segment in motion and the leading segment.
double d_new_xi;
double d_new_yi;
FindLineIntersection(m_drag_xb, m_drag_yb, m_drag_xi, m_drag_yi,
new_xi, new_yi, new_xf, new_yf,
&d_new_xi, &d_new_yi);
int i_drag_xi = floor(d_new_xi + .5);
int i_drag_yi = floor(d_new_yi + .5);
// 3. Find the intercept between the extended segment in motion and the trailing segment:
int i_drag_xf, i_drag_yf;
if(m_drag_style2 == DSS_STRAIGHT)
{
double d_new_xf;
double d_new_yf;
FindLineIntersection(new_xi, new_yi, new_xf, new_yf,
m_drag_xf, m_drag_yf, m_drag_xe, m_drag_ye,
&d_new_xf, &d_new_yf);
i_drag_xf = floor(d_new_xf + .5);
i_drag_yf = floor(d_new_yf + .5);
} else {
i_drag_xf = new_xf;
i_drag_yf = new_yf;
}
// If we drag too far, the line segment can reverse itself causing a little triangle to form.
// That's a bad thing.
if(sign(i_drag_xf - i_drag_xi) == old_xi_dir && sign(i_drag_yf - i_drag_yi) == old_yi_dir &&
sign(i_drag_xi - m_drag_xb) == old_xb_dir && sign(i_drag_yi - m_drag_yb) == old_yb_dir &&
sign(m_drag_xe - i_drag_xf) == old_xe_dir && sign(m_drag_ye - i_drag_yf) == old_ye_dir )
{
m_drag_xi = i_drag_xi;
m_drag_yi = i_drag_yi;
m_drag_xf = i_drag_xf;
m_drag_yf = i_drag_yf;
}
else
{
xx = m_drag_x;
yy = m_drag_y;
}
// 4. Redraw the three segments:
{
pDC->MoveTo( m_drag_xb, m_drag_yb );
// draw first segment
CPen pen0( PS_SOLID, m_drag_w0, RGB( m_rgb[m_drag_layer_0][0],
m_rgb[m_drag_layer_0][1], m_rgb[m_drag_layer_0][2] ) );
CPen * old_pen = pDC->SelectObject( &pen0 );
pDC->LineTo( m_drag_xi, m_drag_yi );
// draw second segment
CPen pen1( PS_SOLID, m_drag_w1, RGB( m_rgb[m_drag_layer_1][0],
m_rgb[m_drag_layer_1][1], m_rgb[m_drag_layer_1][2] ) );
pDC->SelectObject( &pen1 );
pDC->LineTo( m_drag_xf, m_drag_yf );
if(m_drag_style2 == DSS_STRAIGHT)
{
// draw third segment
CPen pen2( PS_SOLID, m_drag_w2, RGB( m_rgb[m_drag_layer_2][0],
m_rgb[m_drag_layer_2][1], m_rgb[m_drag_layer_2][2] ) );
pDC->SelectObject( &pen2 );
pDC->LineTo( m_drag_xe, m_drag_ye );
}
pDC->SelectObject( old_pen );
}
}
else if( m_drag_flag && (m_drag_shape == DS_ARC_STRAIGHT || m_drag_shape == DS_ARC_CW || m_drag_shape == DS_ARC_CCW) )
{
CPen pen_w( PS_SOLID, m_drag_w1, RGB( m_rgb[m_drag_layer_1][0],
m_rgb[m_drag_layer_1][1], m_rgb[m_drag_layer_1][2] ) );
// undraw old arc
CPen * old_pen = pDC->SelectObject( &pen_w );
{
if( m_last_drag_shape == DS_ARC_STRAIGHT )
DrawArc( pDC, DL_LINE, m_drag_x, m_drag_y, m_drag_xi, m_drag_yi );
else if( m_last_drag_shape == DS_ARC_CW )
DrawArc( pDC, DL_ARC_CW, m_drag_xi, m_drag_yi, m_drag_x, m_drag_y );
else if( m_last_drag_shape == DS_ARC_CCW )
DrawArc( pDC, DL_ARC_CCW, m_drag_xi, m_drag_yi, m_drag_x, m_drag_y );
// draw new arc
if( m_drag_shape == DS_ARC_STRAIGHT )
DrawArc( pDC, DL_LINE, xx, yy, m_drag_xi, m_drag_yi );
else if( m_drag_shape == DS_ARC_CW )
DrawArc( pDC, DL_ARC_CW, m_drag_xi, m_drag_yi, xx, yy );
else if( m_drag_shape == DS_ARC_CCW )
DrawArc( pDC, DL_ARC_CCW, m_drag_xi, m_drag_yi, xx, yy );
m_last_drag_shape = m_drag_shape; // used only for polylines
}
pDC->SelectObject( old_pen );
}
// remember shape data
m_drag_x = xx;
m_drag_y = yy;
// now undraw and redraw cross-hairs, if necessary
if( m_cross_hairs )
{
int x = xx;
int y = yy;
COLORREF bk = pDC->SetBkColor( RGB(0,0,0) );
CPen cross_pen( PS_DOT, 0, RGB( 128, 128, 128 ) );
CPen * old_pen = pDC->SelectObject( &cross_pen );
{
pDC->MoveTo( m_cross_left );
pDC->LineTo( m_cross_right );
pDC->MoveTo( m_cross_bottom );
pDC->LineTo( m_cross_top );
if( m_cross_hairs == 2 )
{
pDC->MoveTo( m_cross_topleft );
pDC->LineTo( m_cross_botright );
pDC->MoveTo( m_cross_botleft );
pDC->LineTo( m_cross_topright );
}
m_cross_left.x = m_org_x;
m_cross_left.y = y;
m_cross_right.x = m_max_x;
m_cross_right.y = y;
m_cross_bottom.x = x;
m_cross_bottom.y = m_org_y;
m_cross_top.x = x;
m_cross_top.y = m_max_y;
if( x-m_org_x > y-m_org_y )
{
// bottom-left cursor line intersects m_org_y
m_cross_botleft.x = x - (y - m_org_y);
m_cross_botleft.y = m_org_y;
}
else
{
// bottom-left cursor line intersects m_org_x
m_cross_botleft.x = m_org_x;
m_cross_botleft.y = y - (x - m_org_x);
}
if( m_max_x-x > y-m_org_y )
{
// bottom-right cursor line intersects m_org_y
m_cross_botright.x = x + (y - m_org_y);
m_cross_botright.y = m_org_y;
}
else
{
// bottom-right cursor line intersects m_max_x
m_cross_botright.x = m_max_x;
m_cross_botright.y = y - (m_max_x - x);
}
if( x-m_org_x > m_max_y-y )
{
// top-left cursor line intersects m_max_y
m_cross_topleft.x = x - (m_max_y - y);
m_cross_topleft.y = m_max_y;
}
else
{
// top-left cursor line intersects m_org_x
m_cross_topleft.x = m_org_x;
m_cross_topleft.y = y + (x - m_org_x);
}
if( m_max_x-x > m_max_y-y )
{
// top-right cursor line intersects m_max_y
m_cross_topright.x = x + (m_max_y - y);
m_cross_topright.y = m_max_y;
}
else
{
// top-right cursor line intersects m_max_x
m_cross_topright.x = m_max_x;
m_cross_topright.y = y + (m_max_x - x);
}
pDC->MoveTo( m_cross_left );
pDC->LineTo( m_cross_right );
pDC->MoveTo( m_cross_bottom );
pDC->LineTo( m_cross_top );
if( m_cross_hairs == 2 )
{
pDC->MoveTo( m_cross_topleft );
pDC->LineTo( m_cross_botright );
pDC->MoveTo( m_cross_botleft );
pDC->LineTo( m_cross_topright );
}
}
pDC->SelectObject( old_pen );
pDC->SetBkColor( bk );
}
// restore drawing mode
pDC->SetROP2( old_ROP2 );
return;
}
// Stop dragging
//
int CDisplayList::StopDragging()
{
m_drag_flag = 0;
m_drag_num_lines = 0;
m_drag_num_ratlines = 0;
m_cross_hairs = 0;
m_last_drag_shape = DS_NONE;
return 0;
}
// Change the drag layer and/or width for DS_LINE_VERTEX
// if ww = 0, don't change width
//
void CDisplayList::ChangeRoutingLayer( CDC * pDC, int layer1, int layer2, int ww )
{
int w = ww;
if( !w )
w = m_drag_w1*m_pcbu_per_wu;
int old_ROP2 = pDC->GetROP2();
pDC->SetROP2( R2_XORPEN );
if( m_drag_shape == DS_LINE_VERTEX )
{
CPen pen_old( PS_SOLID, 1, RGB( m_rgb[m_drag_layer_2][0],
m_rgb[m_drag_layer_2][1], m_rgb[m_drag_layer_2][2] ) );
CPen pen_old_w( PS_SOLID, m_drag_w1, RGB( m_rgb[m_drag_layer_1][0],
m_rgb[m_drag_layer_1][1], m_rgb[m_drag_layer_1][2] ) );
CPen pen( PS_SOLID, 1, RGB( m_rgb[layer2][0],
m_rgb[layer2][1], m_rgb[layer2][2] ) );
CPen pen_w( PS_SOLID, w/m_pcbu_per_wu, RGB( m_rgb[layer1][0],
m_rgb[layer1][1], m_rgb[layer1][2] ) );
// undraw segments
CPen * old_pen = pDC->SelectObject( &pen_old_w );
pDC->MoveTo( m_drag_xi, m_drag_yi );
pDC->LineTo( m_drag_x, m_drag_y );
pDC->SelectObject( &pen_old );
pDC->LineTo( m_drag_xf, m_drag_yf );
// redraw segments
pDC->SelectObject( &pen_w );
pDC->MoveTo( m_drag_xi, m_drag_yi );
pDC->LineTo( m_drag_x, m_drag_y );
pDC->SelectObject( &pen );
pDC->LineTo( m_drag_xf, m_drag_yf );
// update variables
m_drag_layer_1 = layer1;
m_drag_layer_2 = layer2;
m_drag_w1 = w/m_pcbu_per_wu;
// see if leading via needs to be changed
if( ( (m_drag_layer_no_via != 0 && m_drag_layer_1 != m_drag_layer_no_via) && !m_drag_via_drawn )
|| (!(m_drag_layer_no_via != 0 && m_drag_layer_1 != m_drag_layer_no_via) && m_drag_via_drawn ) )
{
// draw or undraw via
int thick = (m_drag_via_w - m_drag_via_holew)/2;
int w = m_drag_via_w - thick;
int holew = m_drag_via_holew;
// CPen pen( PS_SOLID, thick, RGB( m_rgb[LAY_PAD_THRU][0], m_rgb[LAY_PAD_THRU][1], m_rgb[LAY_PAD_THRU][2] ) );
CPen pen( PS_SOLID, thick, RGB( m_rgb[m_drag_layer_1][0], m_rgb[m_drag_layer_1][1], m_rgb[m_drag_layer_1][2] ) );
CPen * old_pen = pDC->SelectObject( &pen );
CBrush black_brush( RGB( 0, 0, 0 ) );
CBrush * old_brush = pDC->SelectObject( &black_brush );
pDC->Ellipse( m_drag_xi - w/2, m_drag_yi - w/2, m_drag_xi + w/2, m_drag_yi + w/2 );
pDC->SelectObject( old_brush );
pDC->SelectObject( old_pen );
m_drag_via_drawn = 1 - m_drag_via_drawn;
}
}
else if( m_drag_shape == DS_LINE )
{
CPen pen_old_w( PS_SOLID, m_drag_w1, RGB( m_rgb[m_drag_layer_1][0],
m_rgb[m_drag_layer_1][1], m_rgb[m_drag_layer_1][2] ) );
CPen pen( PS_SOLID, 1, RGB( m_rgb[layer2][0],
m_rgb[layer2][1], m_rgb[layer2][2] ) );
CPen pen_w( PS_SOLID, w/m_pcbu_per_wu, RGB( m_rgb[layer1][0],
m_rgb[layer1][1], m_rgb[layer1][2] ) );
// undraw segments
CPen * old_pen = pDC->SelectObject( &pen_old_w );
pDC->MoveTo( m_drag_xi, m_drag_yi );
pDC->LineTo( m_drag_x, m_drag_y );
// redraw segments
pDC->SelectObject( &pen_w );
pDC->MoveTo( m_drag_xi, m_drag_yi );
pDC->LineTo( m_drag_x, m_drag_y );
// update variables
m_drag_layer_1 = layer1;
m_drag_w1 = w/m_pcbu_per_wu;
// see if leading via needs to be changed
if( ( (m_drag_layer_no_via != 0 && m_drag_layer_1 != m_drag_layer_no_via) && !m_drag_via_drawn )
|| (!(m_drag_layer_no_via != 0 && m_drag_layer_1 != m_drag_layer_no_via) && m_drag_via_drawn ) )
{
// draw or undraw via
int thick = (m_drag_via_w - m_drag_via_holew)/2;
int w = m_drag_via_w - thick;
int holew = m_drag_via_holew;
// CPen pen( PS_SOLID, thick, RGB( m_rgb[LAY_PAD_THRU][0], m_rgb[LAY_PAD_THRU][1], m_rgb[LAY_PAD_THRU][2] ) );
CPen pen( PS_SOLID, thick, RGB( m_rgb[m_drag_layer_1][0], m_rgb[m_drag_layer_1][1], m_rgb[m_drag_layer_1][2] ) );
CPen * old_pen = pDC->SelectObject( &pen );
CBrush black_brush( RGB( 0, 0, 0 ) );
CBrush * old_brush = pDC->SelectObject( &black_brush );
pDC->Ellipse( m_drag_xi - w/2, m_drag_yi - w/2, m_drag_xi + w/2, m_drag_yi + w/2 );
pDC->SelectObject( old_brush );
pDC->SelectObject( old_pen );
m_drag_via_drawn = 1 - m_drag_via_drawn;
}
pDC->SelectObject( old_pen );
}
// restore drawing mode
pDC->SetROP2( old_ROP2 );
return;
}
// change angle by adding 90 degrees clockwise
//
void CDisplayList::IncrementDragAngle( CDC * pDC )
{
m_drag_angle = (m_drag_angle + 90) % 360;
CPoint zero(0,0);
CPen drag_pen( PS_SOLID, 1, RGB( m_rgb[m_drag_layer][0],
m_rgb[m_drag_layer][1], m_rgb[m_drag_layer][2] ) );
CPen *old_pen = pDC->SelectObject( &drag_pen );
int old_ROP2 = pDC->GetROP2();
pDC->SetROP2( R2_XORPEN );
// erase lines
for( int il=0; il<m_drag_num_lines; il++ )
{
pDC->MoveTo( m_drag_x+m_drag_line_pt[2*il].x, m_drag_y+m_drag_line_pt[2*il].y );
pDC->LineTo( m_drag_x+m_drag_line_pt[2*il+1].x, m_drag_y+m_drag_line_pt[2*il+1].y );
}
for( int il=0; il<m_drag_num_ratlines; il++ )
{
pDC->MoveTo( m_drag_ratline_start_pt[il].x, m_drag_ratline_start_pt[il].y );
pDC->LineTo( m_drag_x+m_drag_ratline_end_pt[il].x, m_drag_y+m_drag_ratline_end_pt[il].y );
}
// rotate points, redraw lines
for( int il=0; il<m_drag_num_lines; il++ )
{
RotatePoint( &m_drag_line_pt[2*il], 90, zero );
RotatePoint( &m_drag_line_pt[2*il+1], 90, zero );
pDC->MoveTo( m_drag_x+m_drag_line_pt[2*il].x, m_drag_y+m_drag_line_pt[2*il].y );
pDC->LineTo( m_drag_x+m_drag_line_pt[2*il+1].x, m_drag_y+m_drag_line_pt[2*il+1].y );
}
for( int il=0; il<m_drag_num_ratlines; il++ )
{
RotatePoint( &m_drag_ratline_end_pt[il], 90, zero );
pDC->MoveTo( m_drag_ratline_start_pt[il].x, m_drag_ratline_start_pt[il].y );
pDC->LineTo( m_drag_x+m_drag_ratline_end_pt[il].x, m_drag_y+m_drag_ratline_end_pt[il].y );
}
pDC->SelectObject( old_pen );
pDC->SetROP2( old_ROP2 );
m_drag_vert = 1 - m_drag_vert;
}
// flip to opposite side of board
//
void CDisplayList::FlipDragSide( CDC * pDC )
{
m_drag_side = 1 - m_drag_side;
CPen drag_pen( PS_SOLID, 1, RGB( m_rgb[m_drag_layer][0],
m_rgb[m_drag_layer][1], m_rgb[m_drag_layer][2] ) );
CPen *old_pen = pDC->SelectObject( &drag_pen );
int old_ROP2 = pDC->GetROP2();
pDC->SetROP2( R2_XORPEN );
// erase lines
for( int il=0; il<m_drag_num_lines; il++ )
{
pDC->MoveTo( m_drag_x+m_drag_line_pt[2*il].x, m_drag_y+m_drag_line_pt[2*il].y );
pDC->LineTo( m_drag_x+m_drag_line_pt[2*il+1].x, m_drag_y+m_drag_line_pt[2*il+1].y );
}
for( int il=0; il<m_drag_num_ratlines; il++ )
{
pDC->MoveTo( m_drag_ratline_start_pt[il].x, m_drag_ratline_start_pt[il].y );
pDC->LineTo( m_drag_x+m_drag_ratline_end_pt[il].x, m_drag_y+m_drag_ratline_end_pt[il].y );
}
// modify drag lines
for( int il=0; il<m_drag_num_lines; il++ )
{
if( m_drag_vert == 0 )
{
m_drag_line_pt[2*il].x = -m_drag_line_pt[2*il].x;
m_drag_line_pt[2*il+1].x = -m_drag_line_pt[2*il+1].x;
}
else
{
m_drag_line_pt[2*il].y = -m_drag_line_pt[2*il].y;
m_drag_line_pt[2*il+1].y = -m_drag_line_pt[2*il+1].y;
}
}
for( int il=0; il<m_drag_num_ratlines; il++ )
{
if( m_drag_vert == 0 )
{
m_drag_ratline_end_pt[il].x = -m_drag_ratline_end_pt[il].x;
}
else
{
m_drag_ratline_end_pt[il].y = -m_drag_ratline_end_pt[il].y;
}
}
// redraw lines
for( int il=0; il<m_drag_num_lines; il++ )
{
pDC->MoveTo( m_drag_x+m_drag_line_pt[2*il].x, m_drag_y+m_drag_line_pt[2*il].y );
pDC->LineTo( m_drag_x+m_drag_line_pt[2*il+1].x, m_drag_y+m_drag_line_pt[2*il+1].y );
}
for( int il=0; il<m_drag_num_ratlines; il++ )
{
pDC->MoveTo( m_drag_ratline_start_pt[il].x, m_drag_ratline_start_pt[il].y );
pDC->LineTo( m_drag_x+m_drag_ratline_end_pt[il].x, m_drag_y+m_drag_ratline_end_pt[il].y );
}
pDC->SelectObject( old_pen );
pDC->SetROP2( old_ROP2 );
// if part was vertical, rotate 180 degrees
if( m_drag_vert )
{
IncrementDragAngle( pDC );
IncrementDragAngle( pDC );
}
}
// get any changes in side which occurred while dragging
//
int CDisplayList::GetDragSide()
{
return m_drag_side;
}
// get any changes in angle which occurred while dragging
//
int CDisplayList::GetDragAngle()
{
return m_drag_angle;
}
int CDisplayList::MakeDragLineArray( int num_lines )
{
if( m_drag_line_pt )
free( m_drag_line_pt );
m_drag_line_pt = (CPoint*)calloc( 2*num_lines, sizeof(CPoint) );
if( !m_drag_line_pt )
return 1;
m_drag_max_lines = num_lines;
m_drag_num_lines = 0;
return 0;
}
int CDisplayList::MakeDragRatlineArray( int num_ratlines, int width )
{
if( m_drag_ratline_start_pt )
free(m_drag_ratline_start_pt );
m_drag_ratline_start_pt = (CPoint*)calloc( num_ratlines, sizeof(CPoint) );
if( !m_drag_ratline_start_pt )
return 1;
if( m_drag_ratline_end_pt )
free(m_drag_ratline_end_pt );
m_drag_ratline_end_pt = (CPoint*)calloc( num_ratlines, sizeof(CPoint) );
if( !m_drag_ratline_end_pt )
return 1;
m_drag_ratline_width = width;
m_drag_max_ratlines = num_ratlines;
m_drag_num_ratlines = 0;
return 0;
}
int CDisplayList::AddDragLine( CPoint pi, CPoint pf )
{
if( m_drag_num_lines >= m_drag_max_lines )
return 1;
m_drag_line_pt[2*m_drag_num_lines].x = pi.x/m_pcbu_per_wu;
m_drag_line_pt[2*m_drag_num_lines].y = pi.y/m_pcbu_per_wu;
m_drag_line_pt[2*m_drag_num_lines+1].x = pf.x/m_pcbu_per_wu;
m_drag_line_pt[2*m_drag_num_lines+1].y = pf.y/m_pcbu_per_wu;
m_drag_num_lines++;
return 0;
}
int CDisplayList::AddDragRatline( CPoint pi, CPoint pf )
{
if( m_drag_num_ratlines == m_drag_max_ratlines )
return 1;
m_drag_ratline_start_pt[m_drag_num_ratlines].x = pi.x/m_pcbu_per_wu;
m_drag_ratline_start_pt[m_drag_num_ratlines].y = pi.y/m_pcbu_per_wu;
m_drag_ratline_end_pt[m_drag_num_ratlines].x = pf.x/m_pcbu_per_wu;
m_drag_ratline_end_pt[m_drag_num_ratlines].y = pf.y/m_pcbu_per_wu;
m_drag_num_ratlines++;
return 0;
}
// add element to highlight layer (if the orig_layer is visible)
//
int CDisplayList::HighLight( int gtype, int x, int y, int xf, int yf, int w, int orig_layer )
{
id h_id;
Add( h_id, NULL, LAY_HILITE, gtype, 1, w, 0, x, y, xf, yf, x, y, 0, orig_layer );
return 0;
}
int CDisplayList::CancelHighLight()
{
RemoveAllFromLayer( LAY_HILITE );
return 0;
}
// Set the device context and memory context to world coords
//
void CDisplayList::SetDCToWorldCoords( CDC * pDC, CDC * mDC,
int pcbu_org_x, int pcbu_org_y )
{
memDC = NULL;
if( pDC )
{
// set window scale (WU per pixel) and origin (WU)
pDC->SetMapMode( MM_ANISOTROPIC );
pDC->SetWindowExt( w_ext_x, w_ext_y );
pDC->SetWindowOrg( pcbu_org_x/m_pcbu_per_wu, pcbu_org_y/m_pcbu_per_wu );
// set viewport to client rect with origin in lower left
// leave room for m_left_pane to the left of the PCB drawing area
pDC->SetViewportExt( v_ext_x, v_ext_y );
pDC->SetViewportOrg( m_pane_org_x, m_pane_org_y );
}
if( mDC->m_hDC )
{
// set window scale (units per pixel) and origin (units)
mDC->SetMapMode( MM_ANISOTROPIC );
mDC->SetWindowExt( w_ext_x, w_ext_y );
mDC->SetWindowOrg( pcbu_org_x/m_pcbu_per_wu, pcbu_org_y/m_pcbu_per_wu );
// set viewport to client rect with origin in lower left
// leave room for m_left_pane to the left of the PCB drawing area
mDC->SetViewportExt( v_ext_x, v_ext_y );
mDC->SetViewportOrg( m_pane_org_x, m_pane_org_y );
// update pointer
memDC = mDC;
}
}
void CDisplayList::SetVisibleGrid( BOOL on, double grid )
{
m_visual_grid_on = on;
m_visual_grid_spacing = grid/m_pcbu_per_wu;
}
void CDisplayList::SetUpCrosshairs( int type, int x, int y )
{
// set up cross hairs
m_cross_hairs = type;
m_cross_left.x = m_org_x;
m_cross_left.y = y;
m_cross_right.x = m_max_x;
m_cross_right.y = y;
m_cross_bottom.x = x;
m_cross_bottom.y = m_org_y;
m_cross_top.x = x;
m_cross_top.y = m_max_y;
if( x-m_org_x > y-m_org_y )
{
// bottom-left cursor line intersects m_org_y
m_cross_botleft.x = x - (y - m_org_y);
m_cross_botleft.y = m_org_y;
}
else
{
// bottom-left cursor line intersects m_org_x
m_cross_botleft.x = m_org_x;
m_cross_botleft.y = y - (x - m_org_x);
}
if( m_max_x-x > y-m_org_y )
{
// bottom-right cursor line intersects m_org_y
m_cross_botright.x = x + (y - m_org_y);
m_cross_botright.y = m_org_y;
}
else
{
// bottom-right cursor line intersects m_max_x
m_cross_botright.x = m_max_x;
m_cross_botright.y = y - (m_max_x - x);
}
if( x-m_org_x > m_max_y-y )
{
// top-left cursor line intersects m_max_y
m_cross_topleft.x = x - (m_max_y - y);
m_cross_topleft.y = m_max_y;
}
else
{
// top-left cursor line intersects m_org_x
m_cross_topleft.x = m_org_x;
m_cross_topleft.y = y - (x - m_org_x);
}
if( m_max_x-x > m_max_y-y )
{
// top-right cursor line intersects m_max_y
m_cross_topright.x = x + (m_max_y - y);
m_cross_topright.y = m_max_y;
}
else
{
// top-right cursor line intersects m_max_x
m_cross_topright.x = m_max_x;
m_cross_topright.y = y + (m_max_x - x);
}
}
// Convert point in window coords to PCB units (i.e. nanometers)
//
CPoint CDisplayList::WindowToPCB( CPoint point )
{
CPoint p;
double test = ((point.x-m_pane_org_x)*m_wu_per_pixel_x + m_org_x)*m_pcbu_per_wu;
p.x = test;
test = ((point.y-m_pane_org_y)*m_wu_per_pixel_y + m_org_y)*m_pcbu_per_wu;
p.y = test;
return p;
}
// Convert point in screen coords to PCB units
//
CPoint CDisplayList::ScreenToPCB( CPoint point )
{
CPoint p;
p.x = point.x - m_screen_r.left;
p.y = point.y - m_screen_r.top;
p = WindowToPCB( p );
return p;
}
// Convert point in PCB units to screen coords
//
CPoint CDisplayList::PCBToScreen( CPoint point )
{
CPoint p;
p.x = (point.x - m_org_x*m_pcbu_per_wu)/m_pcbu_per_pixel_x+m_pane_org_x+m_screen_r.left;
p.y = (point.y - m_org_y*m_pcbu_per_wu)/m_pcbu_per_pixel_y-m_bottom_pane_h+m_screen_r.bottom;
return p;
}
|
[
"allanwright@21cd2c34-3bff-0310-83e0-c30e317e0b48"
] |
[
[
[
1,
2476
]
]
] |
a4ec006507dfafea1a57404a1fcc668262fb127d
|
119ba245bea18df8d27b84ee06e152b35c707da1
|
/unreal/branches/typeRefactor-newAge/qrgui/models/logicalModelAssistApi.h
|
271268cedb9ce0a1f0e111ecccafc889a0203150
|
[] |
no_license
|
nfrey/qreal
|
05cd4f9b9d3193531eb68ff238d8a447babcb3d2
|
71641e6c5f8dc87eef9ec3a01cabfb9dd7b0e164
|
refs/heads/master
| 2020-04-06T06:43:41.910531 | 2011-05-30T19:30:09 | 2011-05-30T19:30:09 | 1,634,768 | 0 | 0 | null | null | null | null |
UTF-8
|
C++
| false | false | 1,992 |
h
|
#pragma once
#include "../kernel/ids.h"
#include "details/logicalModel.h"
#include "details/modelsAssistApi.h"
namespace qReal {
class EditorManager;
namespace models {
namespace details {
class LogicalModel;
}
class LogicalModelAssistApi : public details::ModelsAssistApi
{
public:
LogicalModelAssistApi(details::LogicalModel &logicalModel, EditorManager const &editorManager);
qrRepo::LogicalRepoApi const &logicalRepoApi() const;
virtual Id createElement(Id const &parent, NewType const &type);
virtual Id createElement(Id const &parent, Id const &id, NewType const &type, bool isFromLogicalModel, QString const &name, QPointF const &position);
virtual IdList children(Id const &element) const;
virtual void changeParent(Id const &element, Id const &parent, QPointF const &position = QPointF());
NewType type(Id const &id) const;
void connect(Id const &source, Id const &destination);
void disconnect(Id const &source, Id const &destination);
void addUsage(Id const &source, Id const &destination);
void deleteUsage(Id const &source, Id const &destination);
void createConnected(Id const &sourceElement, NewType const &elementType);
void createUsed(Id const &sourceElement, NewType const &elementType);
Id createConnectedElement(Id const &source, NewType const &elementType);
TypeList diagramsAbleToBeConnectedTo(NewType const &element) const;
TypeList diagramsAbleToBeUsedIn(NewType const &element) const;
void setPropertyByRoleName(Id const &elem, QVariant const &newValue, QString const &roleName);
QVariant propertyByRoleName(Id const &elem, QString const &roleName) const;
bool isLogicalId(Id const &id) const;
private:
details::LogicalModel &mLogicalModel;
LogicalModelAssistApi(LogicalModelAssistApi const &); // Copying is forbidden
LogicalModelAssistApi& operator =(LogicalModelAssistApi const &); // Assignment is forbidden also
TypeList diagramsFromList(TypeList const &list) const;
};
}
}
|
[
"[email protected]"
] |
[
[
[
1,
52
]
]
] |
fa2511bf25bc7ecf36ec484ff9e5e15363538e1d
|
33f59b1ba6b12c2dd3080b24830331c37bba9fe2
|
/Depend/Foundation/Distance/Wm4DistVector2Ray2.cpp
|
9fe30fce93a0f2a455bb405d5c41dbc4c1e28d9e
|
[] |
no_license
|
daleaddink/flagship3d
|
4835c223fe1b6429c12e325770c14679c42ae3c6
|
6cce5b1ff7e7a2d5d0df7aa0594a70d795c7979a
|
refs/heads/master
| 2021-01-15T16:29:12.196094 | 2009-11-01T10:18:11 | 2009-11-01T10:18:11 | 37,734,654 | 1 | 0 | null | null | null | null |
UTF-8
|
C++
| false | false | 3,319 |
cpp
|
// Geometric Tools, Inc.
// http://www.geometrictools.com
// Copyright (c) 1998-2006. All Rights Reserved
//
// The Wild Magic Version 4 Foundation Library source code is supplied
// under the terms of the license agreement
// http://www.geometrictools.com/License/Wm4FoundationLicense.pdf
// and may not be copied or disclosed except in accordance with the terms
// of that agreement.
#include "Wm4FoundationPCH.h"
#include "Wm4DistVector2Ray2.h"
namespace Wm4
{
//----------------------------------------------------------------------------
template <class Real>
DistVector2Ray2<Real>::DistVector2Ray2 (const Vector2<Real>& rkVector,
const Ray2<Real>& rkRay)
:
m_rkVector(rkVector),
m_rkRay(rkRay)
{
}
//----------------------------------------------------------------------------
template <class Real>
const Vector2<Real>& DistVector2Ray2<Real>::GetVector () const
{
return m_rkVector;
}
//----------------------------------------------------------------------------
template <class Real>
const Ray2<Real>& DistVector2Ray2<Real>::GetRay () const
{
return m_rkRay;
}
//----------------------------------------------------------------------------
template <class Real>
Real DistVector2Ray2<Real>::Get ()
{
Real fSqrDist = GetSquared();
return Math<Real>::Sqrt(fSqrDist);
}
//----------------------------------------------------------------------------
template <class Real>
Real DistVector2Ray2<Real>::GetSquared ()
{
Vector2<Real> kDiff = m_rkVector - m_rkRay.Origin;
Real fParam = m_rkRay.Direction.Dot(kDiff);
if (fParam > (Real)0.0)
{
m_kClosestPoint1 = m_rkRay.Origin + fParam*m_rkRay.Direction;
}
else
{
m_kClosestPoint1 = m_rkRay.Origin;
}
m_kClosestPoint0 = m_rkVector;
kDiff = m_kClosestPoint1 - m_kClosestPoint0;
return kDiff.SquaredLength();
}
//----------------------------------------------------------------------------
template <class Real>
Real DistVector2Ray2<Real>::Get (Real fT, const Vector2<Real>& rkVelocity0,
const Vector2<Real>& rkVelocity1)
{
Vector2<Real> kMVector = m_rkVector + fT*rkVelocity0;
Vector2<Real> kMOrigin = m_rkRay.Origin + fT*rkVelocity1;
Ray2<Real> kMRay(kMOrigin,m_rkRay.Direction);
return DistVector2Ray2<Real>(kMVector,kMRay).Get();
}
//----------------------------------------------------------------------------
template <class Real>
Real DistVector2Ray2<Real>::GetSquared (Real fT,
const Vector2<Real>& rkVelocity0, const Vector2<Real>& rkVelocity1)
{
Vector2<Real> kMVector = m_rkVector + fT*rkVelocity0;
Vector2<Real> kMOrigin = m_rkRay.Origin + fT*rkVelocity1;
Ray2<Real> kMRay(kMOrigin,m_rkRay.Direction);
return DistVector2Ray2<Real>(kMVector,kMRay).GetSquared();
}
//----------------------------------------------------------------------------
//----------------------------------------------------------------------------
// explicit instantiation
//----------------------------------------------------------------------------
template WM4_FOUNDATION_ITEM
class DistVector2Ray2<float>;
template WM4_FOUNDATION_ITEM
class DistVector2Ray2<double>;
//----------------------------------------------------------------------------
}
|
[
"yf.flagship@e79fdf7c-a9d8-11de-b950-3d5b5f4ea0aa"
] |
[
[
[
1,
94
]
]
] |
6ea53aa26b05281cd8eac5a9b78edb2a07a563bf
|
395391c1b84e984e16d5d60fe02eee00fbd5c10a
|
/src/engine/EDeclarations.hpp
|
88432c513a8d1c878774a11ecb086fbc44bfe282
|
[] |
no_license
|
bronzean/open-rock-raiders-c
|
70104449a6d9d9ee689f0f6c34a62f2218f6ff67
|
aac1a653738b12bc1743c6898867fad06716f007
|
refs/heads/master
| 2021-01-19T14:12:52.531935 | 2011-08-31T06:18:38 | 2011-08-31T06:18:38 | null | 0 | 0 | null | null | null | null |
UTF-8
|
C++
| false | false | 6,536 |
hpp
|
/* Copyright the ORR-C Dev Team */
//Has all the declatations of classes, variables, etc...
#pragma once
#include "../Engine.hpp"
//Here some colors are defined.
#define C_BLACK {0, 0, 0}
#define C_WHITE {255, 255, 255}
#define C_RED {255, 0, 0}
#define C_GREEN {0, 255, 0}
#define C_BLUE {0, 0, 255}
extern TTF_Font *font1;
extern TTF_Font *font2;
extern SDL_Color c_black;
extern SDL_Color c_white;
extern SDL_Color c_red;
extern SDL_Color c_green;
extern SDL_Color c_blue;
extern SDL_Surface *pause_text_spr; //The paused message's surface
//Screen width, height, and bit mode
extern int SCREEN_WIDTH; // 800
extern int SCREEN_HEIGHT; // 600
extern int SCREEN_BPP; // 32
//Run in full screen?
extern bool FULLSCREEN;
//The Frame Rate
extern int FPS;
extern int GFPS; //The graphic updates fps.
extern bool allow_draw; //Is it a drawing update frame?
//The gamestate manager
enum gameState
{
Title,
Loading,
LevelSelect,
Level,
MultiLoad, //Multiplayer loading stuff.
MultiLevel //Multiplayer in-game.
};
extern bool paused;
//The game state
extern gameState GameState;
//This is the screen's surface
extern SDL_Surface *screen;
//This is the sprite for the teleport button used throughout the game.
extern SDL_Surface *teleport_button_spr;
extern SDL_Surface *no_teleport_button_spr;
extern std::string teleport_button_path;
extern std::string no_teleport_button_path;
//is the game over or not
extern bool gameover;
//fps regulator
extern Timer fps;
//the event structure
extern SDL_Event event_struct;
//the keystates
extern Uint8 *keystates;
//the camera
extern camera Camera;
extern camera *PCamera;
extern int camera_move_speed;
//camera *PCamera = &Camera();
//These 2 have to do with teleporting objects.
extern std::vector<std::string> g_teleport_que;
class construction; //Forward declaration so that variables work properly.
extern construction* def_teleporter; //This tells the game what building in the building list is the default teleporter. -1 means none. Remember to allow the map creator to define the default teleporter, and also remember to make the first teleporter in the list the default if it is unhidden.
extern int num_tiles; //This tells the game how many tiles there are.
extern int num_layers; //This tells the game how many layers the map has.
//TODO: Make the following unhardcoded
extern SDL_Surface *tile_1;
extern SDL_Surface *tile_2;
//extern std::string* unit_type_list;
//extern int unit_type_list_num;
extern int num_col_objects;
extern int num_row_objects;
int GetTile(int x, int y);
extern int rightclick_tile_id; //The index of the tile that a right click just happened on in the map array. A value of -1 indicates it's a nonexistant tile.
extern int fps_counter;
extern std::string screen_caption;
extern std::FILE *GameLog; //The game log file stream.
extern std::stringstream out_string; //Holds what to write to the file.
extern SDL_Surface* title_screen; //The title screen's sprite.
extern std::string title_screen_path; //Path to the title screen's image.
extern SDL_Surface *current_layer_sprite; //Contains a message stating the camera's current layer.
extern std::stringstream current_layer_string; //Contains a message stating the camera's current layer.
extern int leftclick_tile_id; //The index of the tile that a left click just happened on in the map array. A value of -1 indicates it's a nonexistant tile.
extern int update_graphics_every_x_frames; //After how many frames should the graphics be updated?
extern std::string map_folder_path; //The path to the map...
extern bool move_issued; //Used in controlling player movement.
extern bool recheck_importance; //Is it time for the tiles to recheck importance?
extern int num_worker_threads; //How many threads the game creates to help it do all the work that needs to be done.
extern std::vector<pthread_t> threads; //The worker threads themselves.
extern int game_mode; //0 = classic. 1 = arcade.
static pthread_mutex_t screen_lock;
static pthread_mutex_t udp_send_lock;
extern bool screen_needs_updating; //Is it time for stuff to be drawn?
extern SDL_Surface *title_screen_text1_spr; //Let the player know they have to press enter to enter the game.
extern SDL_Surface *title_screen_text2_spr; //Nifty little saying on the title screen.
extern bool allow_unit_selection; //Only if no buttons were clicked and whatnot can units be selected/deselected.
//-----------MUSIC STUFF--------------
static int audio_open = 0;
static Mix_Music *music = NULL;
static int next_track = 0;
static SDL_RWops *rwfp;
static int audio_rate = 22050;
static Uint16 audio_format = AUDIO_S16;
static int audio_channels = 2;
static int audio_buffers = 4096;
static int audio_volume = MIX_MAX_VOLUME;
static int looping = -1;
static int rwops = 0;
static std::string music_filepath = "music.ogg";
//------------------------------------
extern bool threed_gfx; //Will the game be using 3D graphics?
static int port_number = 2097; //The port the server's gonna run on.
static int client_update_interval = 1000; //The rate at which the client should ask the server for updates, in milliseconds.
//static TCPsocket sd, csd; //Socket descriptor, Client socket descriptor
//static TCPsocket sd; //Socket descriptor
//static IPaddress ip, *remoteIP;
extern bool server; //Is the game running in server or client mode?
static int max_clients = 255; //The maximum ammount of clients that can connect to the server.
static TCPsocket serverSocket;
static IPaddress serverIP;
extern int receivedByteCount; //Variable keeping track of the size of incoming data.
extern bool active_popup_menu; //Is a popup menu active?
extern bool unit_selected; //Is a unit currently selected?
class bClassUnit; //Forward declaration so that the selected_unit variable works properly.
extern bClassUnit* selected_unit; //Pointer to the selected unit.
extern bool tile_selected; //Is a tile currently selected?
class tile; //Forward declaration so that the selected_tile variable works properly.
extern tile* selected_tile; //Pointer to the selected tile.
extern bool construction_selected; //Is a construction currently selected?
extern construction* selected_construction; //Pointer to the selected construction.
extern std::vector<construction*> constructions_on_map; //Vector of all the constructions on the map.
|
[
"CiliesJ@43b2f215-69ce-7cdb-bcbe-f39a4413677e",
"ciliesj@43b2f215-69ce-7cdb-bcbe-f39a4413677e"
] |
[
[
[
1,
39
],
[
43,
132
],
[
134,
159
],
[
179,
193
]
],
[
[
40,
42
],
[
133,
133
],
[
160,
178
]
]
] |
80621c79dcd57ebb71b2c5a09b36380daff78a12
|
9176b0fd29516d34cfd0b143e1c5c0f9e665c0ed
|
/CS_153_Data_Structures/assignment7/bt.h
|
e5a95faf71263e47a13fc68b337dfc1fb93f168b
|
[] |
no_license
|
Mr-Anderson/james_mst_hw
|
70dbde80838e299f9fa9c5fcc16f4a41eec8263a
|
83db5f100c56e5bb72fe34d994c83a669218c962
|
refs/heads/master
| 2020-05-04T13:15:25.694979 | 2011-11-30T20:10:15 | 2011-11-30T20:10:15 | 2,639,602 | 2 | 0 | null | null | null | null |
UTF-8
|
C++
| false | false | 5,353 |
h
|
#ifndef BT_H
#define BT_H
//////////////////////////////////////////////////////////////////////
/// @file bt.h
/// @author James Anderson CS 153 Section A
/// @brief Heder file for double linked class for assignment 7
//////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////
/// @class Bt
/// @brief Bt is used to create and edit a double linked bt and
/// includes funtions to add remove and iterate the bt.
//////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////
/// @fn Bt<generic>::Bt ()
/// @brief creates a new double linked bt
/// @pre needs the type of variable to be sored in the Bt
/// @post creates a new empty bt
/// @param generic holds the type of variable the bt will hold
//////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////
/// @fn Bt<generic>::Bt (Bt & x)
/// @brief creates a new bt and copys existing bt into it
/// @pre needs the type of variable to be sored in the bt and and
/// exsiting bt of the same type
/// @post creates a new bt inhariting the variables of existing bt
/// @param Bt & x holds the bt to be copied
//////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////
/// @fn Bt<generic>:: operator= (const Bt & x)
/// @brief alows you to assign one bt to another
/// @pre the two bt must be of the same type
/// @post copys one bt into the other
/// @param const Bt & x holds the bt to be copied
/// @return returns the curent bt
//////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////
/// @fn Bt<generic>::clear ()
/// @brief clears all of the values in the Bt
/// @post decreses the size to 0 and sets the root to null
//////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////
/// @fn Bt<generic>::empty ()
/// @brief tells whether or not the bt is empty
/// @return returns a bool with 1 for empty and 0 for not
//////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////
/// @fn Bt<generic>::size () const
/// @brief feeds back the size of the bt
/// @return returns the size of the bt
//////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////
/// @fn PreOrder<generic>::pre_begin () const
/// @brief returns an Iterator to the first node on the bt
/// @return returns a pointer to the first node
//////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////
/// @fn PreOrder<generic>::pre_end () const
/// @brief returns an Iterator to the last node on the bt
/// @return returns a pointer to the last node
//////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////
/// @fn InOrder<generic>::in_begin () const
/// @brief returns an Iterator to the first node on the bt
/// @return returns a pointer to the first node
//////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////
/// @fn InOrder<generic>::in_end () const
/// @brief returns an Iterator to the last node on the bt
/// @return returns a pointer to the last node
//////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////
/// @fn PostOrder<generic>::post_begin () const
/// @brief returns an Iterator to the first node on the bt
/// @return returns a pointer to the first node
//////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////
/// @fn PostOrder<generic>::post_end () const
/// @brief returns an Iterator to the last node on the bt
/// @return returns a pointer to the last node
//////////////////////////////////////////////////////////////////////
#include "btn.h"
#include "exception.h"
#include "btpreorderiterator.h"
#include "btinorderiterator.h"
#include "btpostorderiterator.h"
template <class generic>
class BT
{
public:
BT();
~BT();
BT(BT &);
BT & operator= (const BT &);
void clear ();
bool empty () const;
unsigned int size () const;
typedef BTPreorderIterator<generic> PreOrder;
typedef BTInorderIterator<generic> InOrder;
typedef BTPostorderIterator<generic> PostOrder;
PreOrder pre_begin () const;
PreOrder pre_end () const;
InOrder in_begin () const;
InOrder in_end () const;
PostOrder post_begin () const;
PostOrder post_end () const;
protected:
Btn<generic> * m_root;
unsigned int m_size;
void swap (Btn<generic> *, Btn<generic> *);
void i_give_up_insert (generic,short) ;
};
#include "bt.hpp"
#endif
|
[
"[email protected]"
] |
[
[
[
1,
118
]
]
] |
3a38a21e81b5a4143f5d8d3c37c028e74508ce85
|
bef7d0477a5cac485b4b3921a718394d5c2cf700
|
/dingus/dingus/resource/SoundBundle.cpp
|
54e63b05793ee954af193ffd997a60309dad0ca0
|
[
"MIT"
] |
permissive
|
TomLeeLive/aras-p-dingus
|
ed91127790a604e0813cd4704acba742d3485400
|
22ef90c2bf01afd53c0b5b045f4dd0b59fe83009
|
refs/heads/master
| 2023-04-19T20:45:14.410448 | 2011-10-04T10:51:13 | 2011-10-04T10:51:13 | null | 0 | 0 | null | null | null | null |
UTF-8
|
C++
| false | false | 1,293 |
cpp
|
// --------------------------------------------------------------------------
// Dingus project - a collection of subsystems for game/graphics applications
// --------------------------------------------------------------------------
#include "stdafx.h"
#include "SoundBundle.h"
#include "../utils/Errors.h"
#include "../audio/AudioContext.h"
using namespace dingus;
bool CSoundBundle::loadSound( const CSoundDesc& d, CSoundResource& sound ) const
{
assert( !mDirectory.empty() );
if( !G_AUDIOCTX->isOpen() ) {
CONSOLE.write( "sound unavailable, skipping loading of '" + d.getID().getUniqueName() + "'" );
return true;
}
bool ok = sound.createResource( mDirectory + d.getID().getUniqueName() + ".wav", d.getTrackCount(), d.isAmbient(), d.isStreaming() );
if( !ok ) {
std::string msg = "failed to load sound '" + d.getID().getUniqueName() + "'";
CConsole::CON_ERROR.write(msg);
THROW_ERROR( msg );
}
CONSOLE.write( "sound loaded '" + d.getID().getUniqueName() + "'" );
return true;
}
CSoundResource* CSoundBundle::loadResourceById( const CSoundDesc& id )
{
assert( G_AUDIOCTX );
CSoundResource* sound = new CSoundResource();
bool ok = loadSound( id, *sound );
if( !ok ) {
delete sound;
return NULL;
}
return sound;
}
|
[
"[email protected]"
] |
[
[
[
1,
42
]
]
] |
b3516fa53a0f87074259ddad3c7ea69869cd8973
|
01c236af2890d74ca5b7c25cec5e7b1686283c48
|
/Src/GameOverForm.cpp
|
cb89e62f5591ee46fc26f0a0117112c4e5ed7510
|
[
"MIT"
] |
permissive
|
muffinista/palm-pitch
|
80c5900d4f623204d3b837172eefa09c4efbe5e3
|
aa09c857b1ccc14672b3eb038a419bd13abc0925
|
refs/heads/master
| 2021-01-19T05:43:04.740676 | 2010-07-08T14:42:18 | 2010-07-08T14:42:18 | 763,958 | 1 | 0 | null | null | null | null |
UTF-8
|
C++
| false | false | 1,401 |
cpp
|
#include "Common.h"
#include "GameOverForm.h"
#include "PitchApp.h"
#include "GameManager.h"
extern GameManager *gManager;
// Form open handler
Boolean CGameOverForm::OnOpen(EventPtr pEvent, Boolean& bHandled) {
gManager->Status(GameOver);
m_winners.Attach(this, GameResultsField);
// figure out who won and what the score was
CString winners;
if ( gManager->CutThroat() == true ) {
winners.Format("%s wins, %d to %d to %d!",
(const char *)gManager->GetWinner()->getName(),
gManager->scores[0], gManager->scores[1], gManager->scores[2] );
}
else {
winners.Format("%s and %s win, %d to %d!",
(const char *)gManager->GetWinner()->getName(),
(const char *)gManager->GetWinner()->partner->getName(),
gManager->scores[0], gManager->scores[1] );
}
m_winners.Replace(winners);
bHandled = false;
return true;
}
Boolean CGameOverForm::OnNewGame(EventPtr pEvent, Boolean& bHandled) {
CChooseGameTypeDialog frmGT;
if ( frmGT.DoModal() ) {
if ( frmGT.CutThroat() ) {
gManager->CutThroat(true);
CForm::GotoForm(NewCTGameForm);
}
else {
gManager->CutThroat(false);
CForm::GotoForm(NewGameForm);
}
}
return true;
}
Boolean CGameOverForm::OnExit(EventPtr pEvent, Boolean& bHandled) {
m_winners.Detach();
gManager->Reset();
CForm::GotoForm(MainForm);
return true;
}
|
[
"[email protected]"
] |
[
[
[
1,
67
]
]
] |
41598d17814a834ceceb8884b0c346da271f861b
|
478570cde911b8e8e39046de62d3b5966b850384
|
/apicompatanamdw/bcdrivers/mw/web/favourites_api/src/FavouritesNotifierTestCases.cpp
|
f6cd9c09171f9257ae7512bbe7216159022446ff
|
[] |
no_license
|
SymbianSource/oss.FCL.sftools.ana.compatanamdw
|
a6a8abf9ef7ad71021d43b7f2b2076b504d4445e
|
1169475bbf82ebb763de36686d144336fcf9d93b
|
refs/heads/master
| 2020-12-24T12:29:44.646072 | 2010-11-11T14:03:20 | 2010-11-11T14:03:20 | 72,994,432 | 0 | 0 | null | null | null | null |
UTF-8
|
C++
| false | false | 7,594 |
cpp
|
/*
* Copyright (c) 2002 Nokia Corporation and/or its subsidiary(-ies).
* All rights reserved.
* This component and the accompanying materials are made available
* under the terms of "Eclipse Public License v1.0"
* which accompanies this distribution, and is available
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
*
* Initial Contributors:
* Nokia Corporation - initial contribution.
*
* Contributors:
*
* Description:
*
*
*/
// INCLUDE FILES
#include <e32math.h>
#include "FavouritesBCTest.h"
#include "FavouritesDbTestObserver.h"
// EXTERNAL DATA STRUCTURES
// None
// EXTERNAL FUNCTION PROTOTYPES
// None
// CONSTANTS
// None
// MACROS
// None
// LOCAL CONSTANTS AND MACROS
// None
// MODULE DATA STRUCTURES
// None
// LOCAL FUNCTION PROTOTYPES
// None
// FORWARD DECLARATIONS
// None
// ==================== LOCAL FUNCTIONS =======================================
// ============================ MEMBER FUNCTIONS ===============================
/*
-------------------------------------------------------------------------------
Class: CFavouritesBCTest
Method: NotifierConstructorTestL
Description: Test the CActiveFavouritesDbNotifier constructor method.
Parameters: TTestResult& aErrorDescription: out:
Test result and on error case a short description of error
Return Values: TInt: Always KErrNone to indicate that test was valid
Errors/Exceptions: None
Status: Approved
-------------------------------------------------------------------------------
*/
TInt CFavouritesBCTest::NotifierConstructorTestL( TTestResult& aResult )
{
/* Simple server connect */
_LIT( KDefinition ,"State" );
_LIT( KData ,"Test the CActiveFavouritesDbNotifier constructor method" );
TestModuleIf().Printf( 0, KDefinition, KData );
TInt tempResult = iFavouritesDb.Open( iFavouritesSession, KTestDbName );
tempResult = tempResult;
CleanupClosePushL<RFavouritesDb>( iFavouritesDb );
CreatePopulatedDbL();
CActiveScheduler* scheduler = new (ELeave) CActiveScheduler;
CleanupStack::PushL( scheduler );
CActiveScheduler::Install( scheduler );
CFavouritesDbTestObserver* observer = new (ELeave) CFavouritesDbTestObserver( *this );
CleanupStack::PushL( observer );
observer->Start();
CActiveScheduler::Start();
CActiveFavouritesDbNotifier* notifier = new (ELeave) CActiveFavouritesDbNotifier( iFavouritesDb, (MFavouritesDbObserver &)*this );
CleanupStack::PushL( notifier );
_LIT( KData2 ,"Finished" );
TestModuleIf().Printf( 0, KDefinition, KData2 );
if( notifier )
{
_LIT( KDescription , "Test case passed" );
aResult.SetResult( KErrNone, KDescription );
}
else
{
_LIT( KDescription , "Test case failed" );
aResult.SetResult( KErrGeneral, KDescription );
}
CleanupStack::PopAndDestroy(4); // iFavouritesDb, observer, notifier
iFavouritesSession.DeleteDatabase( KTestDbName );
// Case was executed
return KErrNone;
}
/*
-------------------------------------------------------------------------------
Class: CFavouritesBCTest
Method: NotifierDestructorTestL
Description: Test the CActiveFavouritesDbNotifier destructor method.
Parameters: TTestResult& aErrorDescription: out:
Test result and on error case a short description of error
Return Values: TInt: Always KErrNone to indicate that test was valid
Errors/Exceptions: None
Status: Approved
-------------------------------------------------------------------------------
*/
TInt CFavouritesBCTest::NotifierDestructorTestL( TTestResult& aResult )
{
/* Simple server connect */
_LIT( KDefinition ,"State" );
_LIT( KData ,"Test the CActiveFavouritesDbNotifier destructor method" );
TestModuleIf().Printf( 0, KDefinition, KData );
TInt tempResult = iFavouritesDb.Open( iFavouritesSession, KTestDbName );
tempResult = tempResult;
CleanupClosePushL<RFavouritesDb>( iFavouritesDb );
CreatePopulatedDbL();
CActiveScheduler* scheduler = new (ELeave) CActiveScheduler;
CleanupStack::PushL( scheduler );
CActiveScheduler::Install( scheduler );
CFavouritesDbTestObserver* observer = new (ELeave) CFavouritesDbTestObserver( *this );
CleanupStack::PushL( observer );
observer->Start();
CActiveScheduler::Start();
CActiveFavouritesDbNotifier* notifier = new (ELeave) CActiveFavouritesDbNotifier( iFavouritesDb, (MFavouritesDbObserver &)*this );
CleanupStack::PushL( notifier );
notifier->~CActiveFavouritesDbNotifier();
_LIT( KData2 ,"Finished" );
TestModuleIf().Printf( 0, KDefinition, KData2 );
if( notifier )
{
_LIT( KDescription , "Test case passed" );
aResult.SetResult( KErrNone, KDescription );
}
else
{
_LIT( KDescription , "Test case failed" );
aResult.SetResult( KErrGeneral, KDescription );
}
CleanupStack::PopAndDestroy(4); // iFavouritesDb, observer, notifier
iFavouritesSession.DeleteDatabase( KTestDbName );
// Case was executed
return KErrNone;
}
/*
-------------------------------------------------------------------------------
Class: CFavouritesBCTest
Method: NotifierStartTestL
Description: Test the CActiveFavouritesDbNotifier Start method.
Parameters: TTestResult& aErrorDescription: out:
Test result and on error case a short description of error
Return Values: TInt: Always KErrNone to indicate that test was valid
Errors/Exceptions: None
Status: Approved
-------------------------------------------------------------------------------
*/
TInt CFavouritesBCTest::NotifierStartTestL( TTestResult& aResult )
{
/* Simple server connect */
_LIT( KDefinition ,"State" );
_LIT( KData ,"Test the CActiveFavouritesDbNotifier Start method" );
TestModuleIf().Printf( 0, KDefinition, KData );
TInt tempResult = iFavouritesDb.Open( iFavouritesSession, KTestDbName );
tempResult = tempResult;
CleanupClosePushL<RFavouritesDb>( iFavouritesDb );
CreatePopulatedDbL();
CActiveScheduler* scheduler = new (ELeave) CActiveScheduler;
CleanupStack::PushL( scheduler );
CActiveScheduler::Install( scheduler );
CFavouritesDbTestObserver* observer = new (ELeave) CFavouritesDbTestObserver( *this );
CleanupStack::PushL( observer );
observer->Start();
CActiveScheduler::Start();
CActiveFavouritesDbNotifier* notifier = new (ELeave) CActiveFavouritesDbNotifier( iFavouritesDb, (MFavouritesDbObserver &)*this );
CleanupStack::PushL( notifier );
TInt result = notifier->Start();
_LIT( KData2 ,"Finished" );
TestModuleIf().Printf( 0, KDefinition, KData2 );
if( result == KErrNone )
{
_LIT( KDescription , "Test case passed" );
aResult.SetResult( KErrNone, KDescription );
}
else
{
_LIT( KDescription , "Test case failed" );
aResult.SetResult( KErrGeneral, KDescription );
}
CleanupStack::PopAndDestroy(4); // iFavouritesDb, observer, notifier
iFavouritesSession.DeleteDatabase( KTestDbName );
// Case was executed
return KErrNone;
}
// ================= OTHER EXPORTED FUNCTIONS =================================
// End of File
|
[
"none@none"
] |
[
[
[
1,
265
]
]
] |
afdfada1bec0cd71c2595fa8cb7106c4ab14ecee
|
35231241243cb13bd3187983d224e827bb693df3
|
/branches/umptesting/MPReader/filexor.h
|
3e61cd35cfcb94ca4da7a927ed5c032792106fd8
|
[] |
no_license
|
casaretto/cgpsmapper
|
b597aa2775cc112bf98732b182a9bc798c3dd967
|
76d90513514188ef82f4d869fc23781d6253f0ba
|
refs/heads/master
| 2021-05-15T01:42:47.532459 | 2011-06-25T23:16:34 | 2011-06-25T23:16:34 | 1,943,334 | 2 | 2 | null | 2019-06-11T00:26:40 | 2011-06-23T18:31:36 |
C++
|
WINDOWS-1250
|
C++
| false | false | 1,433 |
h
|
#ifndef FileXORH
#define FileXORH
#include <stdio.h>
#include <string>
#include <stdexcept>
const int MAX_LINE_SIZE = 2048;
const int BUFFER_MAX = 64000;
class xor_fstream {
public:
xor_fstream(const char *file_name, const char *mode);
virtual ~xor_fstream(void);
void SetXorMask(unsigned char mask) { m_mask = mask; };
virtual int Read(void *Buffer, int Count);
virtual int Write(const void *Buffer, int Count);
void FillWrite(unsigned char value, int Count); // wypełnienie wartościami
std::string ReadString(void);
void WriteString(std::string text);
int ReadInput(std::string &key, std::string &value);
int SearchKey(std::string key, std::string &value, std::string terminator); // szuka klucza od pozycji biezacej do
///terminatora - przywraca pozycje!
std::string ReadLine(char terminator);
std::string ReadLine(void);
long int file_size;
long line_no;
std::string file_name;
void seekg(long offset, int whence);
long tellg(void);
bool error;
int headerOffset;
/*
-----------------------------------------------------------------------------------------------------------------------
-----------------------------------------------------------------------------------------------------------------------
*/
private:
FILE *stream;
unsigned char m_mask;
char m_buffer[BUFFER_MAX];
};
#endif
|
[
"marrud@ad713ecf-6e55-4363-b790-59b81426eeec"
] |
[
[
[
1,
51
]
]
] |
5e7de67c2035f0380419fb060b4acbbc01837873
|
ee2e06bda0a5a2c70a0b9bebdd4c45846f440208
|
/word/CppUTest/tests/UtestTest.cpp
|
77d8a750b7ba552aa78604f2b0770a9e1101b389
|
[] |
no_license
|
RobinLiu/Test
|
0f53a376e6753ece70ba038573450f9c0fb053e5
|
360eca350691edd17744a2ea1b16c79e1a9ad117
|
refs/heads/master
| 2021-01-01T19:46:55.684640 | 2011-07-06T13:53:07 | 2011-07-06T13:53:07 | 1,617,721 | 2 | 0 | null | null | null | null |
UTF-8
|
C++
| false | false | 5,024 |
cpp
|
/*
* Copyright (c) 2007, Michael Feathers, James Grenning and Bas Vodde
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the <organization> nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL <copyright holder> BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "CppUTest/TestHarness.h"
#include "CppUTest/TestOutput.h"
#include "CppUTest/TestTestingFixture.h"
TEST_GROUP(Utest)
{
TestTestingFixture* fixture;
TEST_SETUP()
{
fixture = new TestTestingFixture();
UT_PTR_SET(PlatformSpecificExitCurrentTest, FakePlatformSpecificExitCurrentTest);
}
TEST_TEARDOWN()
{
delete fixture;
}
};
static void _failMethod()
{
FAIL("This test fails");
}
TEST(Utest, FailurePrintsSomething)
{
fixture->setTestFunction(_failMethod);
fixture->runAllTests();
LONGS_EQUAL(1, fixture->getFailureCount());
fixture->assertPrintContains("This test fails");
}
static void _LongsEqualFailMethod()
{
LONGS_EQUAL(1, 0xff);
}
TEST(Utest, FailurePrintHexOutputForLongInts)
{
fixture->setTestFunction(_LongsEqualFailMethod);
fixture->runAllTests();
fixture->assertPrintContains("expected < 1 0x01>");
fixture->assertPrintContains("but was <255 0xff>");
}
static void _passMethod()
{
CHECK(true);
}
TEST(Utest, SuccessPrintsNothing)
{
fixture->setTestFunction(_passMethod);
fixture->runAllTests();
LONGS_EQUAL(0, fixture->getFailureCount());
fixture->assertPrintContains(".\nOK (1 tests");
}
TEST(Utest, allMacros)
{
CHECK(0 == 0);
LONGS_EQUAL(1,1);
BYTES_EQUAL(0xab,0xab);
CHECK_EQUAL("THIS", "THIS");
CHECK_EQUAL(100,100);
STRCMP_EQUAL("THIS", "THIS");
DOUBLES_EQUAL(1.0, 1.0, .01);
}
TEST(Utest, AssertsActLikeStatements)
{
if (fixture != 0)
CHECK(true)
else
CHECK(false)
if (fixture != 0)
CHECK_EQUAL(true, true)
else
CHECK_EQUAL(false, false)
if (fixture != 0)
STRCMP_EQUAL("", "")
else
STRCMP_EQUAL("", " ")
if (fixture != 0)
LONGS_EQUAL(1, 1)
else
LONGS_EQUAL(1, 0)
if (fixture != 0)
DOUBLES_EQUAL(1, 1, 0.01)
else
DOUBLES_EQUAL(1, 0, 0.01)
if (false)
FAIL("")
else
;
if (true)
;
else
FAIL("")
}
IGNORE_TEST(Utest, IgnoreTestSupportsAllMacros)
{
CHECK(true);
CHECK_EQUAL(true, true);
STRCMP_EQUAL("", "");
LONGS_EQUAL(1, 1);
DOUBLES_EQUAL(1, 1, 0.01);
FAIL("");
}
IGNORE_TEST(Utest, IgnoreTestAccessingFixture)
{
CHECK(fixture != 0);
}
TEST(Utest, MacrosUsedInSetup)
{
delete fixture->genTest;
fixture->genTest = new ExecFunctionTest(_failMethod);
fixture->setTestFunction(_passMethod);
fixture->runAllTests();
LONGS_EQUAL(1, fixture->getFailureCount());
}
TEST(Utest, MacrosUsedInTearDown)
{
delete fixture->genTest;
fixture->genTest = new ExecFunctionTest(0, _failMethod);
fixture->setTestFunction(_passMethod);
fixture->runAllTests();
LONGS_EQUAL(1, fixture->getFailureCount());
}
TEST_BASE(MyOwnTest)
{
MyOwnTest() : inTest(false) {}
bool inTest;
void setup()
{
CHECK(!inTest);
inTest = true;
}
void teardown()
{
CHECK(inTest);
inTest = false;
}
};
TEST_GROUP_BASE(UtestMyOwn, MyOwnTest)
{
};
TEST(UtestMyOwn, test)
{
CHECK(inTest);
}
class NullParameterTest : public Utest
{
};
TEST(UtestMyOwn, NullParameters)
{
NullParameterTest nullTest; /* Bug fix tests for creating a test without a name, fix in SimpleString */
TestRegistry* reg = TestRegistry::getCurrentRegistry();
nullTest.shouldRun(reg->getGroupFilter(), reg->getNameFilter());
}
|
[
"RobinofChina@43938a50-64aa-11de-9867-89bd1bae666e"
] |
[
[
[
1,
205
]
]
] |
92a3301a0daf432791a634c6955657606281ddad
|
b90f7dce513fd3d13bab0b8769960dea901d4f3b
|
/game_client/game_client/GameClientEventEmitter.h
|
fa5e695889309716c041ece35a9ae83e4d055b35
|
[] |
no_license
|
lasti15/easygametools
|
f447052cd4c42609955abd76b4c8571422816b11
|
0b819c957077a4eeaf9a2492772040dafdfca4c3
|
refs/heads/master
| 2021-01-10T09:14:52.182154 | 2011-03-09T01:51:51 | 2011-03-09T01:51:51 | 55,684,684 | 0 | 0 | null | null | null | null |
UTF-8
|
C++
| false | false | 350 |
h
|
#ifndef __GAMECLIENTEVENTEMITTER_H
#define __GAMECLIENTEVENTEMITTER_H
#include "RakNetTypes.h"
#include "Reference.h"
#include "GameClientEvent.h"
namespace ROG {
class GameClientEventEmitter : public Reference {
public:
virtual void fireEvent(GameClientEventType eventType, RakNet::Packet* eventPacket) = 0;
};
}
#endif
|
[
"[email protected]"
] |
[
[
[
1,
18
]
]
] |
6d972d72286f37680a5f181b5810850d5dce9136
|
25f79693b806edb9041e3786fa3cf331d6fd4b97
|
/src/core/cal/Buffer.cpp
|
91e5321a86e4266340d1db24e58c1a554bef370f
|
[] |
no_license
|
ouj/amd-spl
|
ff3c9faf89d20b5d6267b7f862c277d16aae9eee
|
54b38e80088855f5e118f0992558ab88a7dea5b9
|
refs/heads/master
| 2016-09-06T03:13:23.993426 | 2009-08-29T08:55:02 | 2009-08-29T08:55:02 | 32,124,284 | 0 | 0 | null | null | null | null |
UTF-8
|
C++
| false | false | 14,083 |
cpp
|
//////////////////////////////////////////////////////////////////////////
//!
//! \file Buffer.cpp
//! \date 27:2:2009 22:19
//! \author Jiawei Ou
//!
//! \brief Contains definition of Buffer class.
//!
//////////////////////////////////////////////////////////////////////////
#include "RuntimeDefs.h"
#include "CalCommonDefs.h"
#include <stdio.h>
#include "Utility.h"
namespace amdspl
{
namespace core
{
namespace cal
{
//////////////////////////////////////////////////////////////////////////
//!
//! \param format Indicate the CALformat of the buffer.
//! \param width Indicate the width of the 1D/2D buffer.
//! \param height Indicate the height of 2D buffer, it should be set to
//! zero for 1D buffer.
//! \return Constructor
//!
//! \brief Construct the Buffer object. Set all the members to default
//! values. The Buffer object will not be available until
//! Buffer::initialize() is called.
//!
//////////////////////////////////////////////////////////////////////////
Buffer::Buffer(CALformat format, unsigned int width, unsigned int height, unsigned int flag) :
_dataFormat(format), _width(width), _height(height), _res(0), _pitch(0),
_flag(flag), _inputEvent(NULL), _outputEvent(NULL)
{
}
//////////////////////////////////////////////////////////////////////////
//!
//! \return Destructor
//!
//! \brief Destroy the Buffer object, safely release the buffer's
//! resource handle.
//!
//////////////////////////////////////////////////////////////////////////
Buffer::~Buffer()
{
if(_res)
{
calResFree(_res);
_res = 0;
}
}
//////////////////////////////////////////////////////////////////////////
//!
//! \return bool True if the buffer is initialized successful. False if
//! there is an error during initialization.
//!
//! \brief Initialize the buffer before the buffer can be used, it is a
//! virtual function, should be implemented by derived classes.
//!
//////////////////////////////////////////////////////////////////////////
bool Buffer::initialize()
{
return true;
}
//////////////////////////////////////////////////////////////////////////
//!
//! \param ptr The CPU address contains the data going to be
//! transfered to the buffer.
//! \param size The size in bytes of the data the pointer points to.
//! \return bool True if data transfer is succeeded. False if there is
//! an error during data transfer.
//!
//! \brief Synchronized data transfer from CPU memory to the SPL Buffer
//! Sometimes the buffer is larger than the data that is going to
//! be transfered. In this case, if defaulVal is set, the method
//! will set the rest of buffer using the default value pointed by
//! defaultVal.
//!
//! \attention It is the developers' responsibility to make sure the
//! format and size of the CPU memory that ptr points to are
//! valid.
//!
//////////////////////////////////////////////////////////////////////////
bool Buffer::readData(void *ptr, unsigned long size)
{
char *cpuPtr = static_cast<char*>(ptr);
if (!cpuPtr)
{
return false;
}
waitInputEvent();
CALuint pitch;
char* gpuPtr = static_cast<char*>(getPointerCPU(pitch));
if (!gpuPtr)
{
return false;
}
// element size
unsigned short elementStride = utils::getElementBytes(_dataFormat);
//bytes in the gpu buffer
unsigned int height = _height == 0 ? 1 : _height; //1D
unsigned int bufferBytes =
elementStride * _width * height;
//bytes in the cpu buffer
unsigned int totalBytes = size * elementStride;
if (bufferBytes < totalBytes)
{
return false;
}
//bytes that should set the default value
unsigned int defaultBytes = bufferBytes - totalBytes;
unsigned int cpuRowStride = elementStride * _width;
unsigned int gpuRowStride = elementStride * pitch;
if (cpuRowStride == gpuRowStride)
{
memcpy(gpuPtr, cpuPtr, totalBytes);
}
else
{
unsigned int bytesCopied = 0;
for (unsigned int row = 0; row < height - 1; row++)
{
memcpy(gpuPtr, cpuPtr, cpuRowStride);
gpuPtr += gpuRowStride;
cpuPtr += cpuRowStride;
}
size_t remainBytes = totalBytes - (cpuPtr - static_cast<char*>(ptr));
if (remainBytes)
{
memcpy(gpuPtr, cpuPtr, remainBytes);
}
}
releasePointerCPU();
return true;
}
//////////////////////////////////////////////////////////////////////////
//!
//! \param ptr The CPU address where that data in buffer will be
//! transfered to.
//! \param size The size in bytes of the space the pointer points to.
//! \return bool True if data transfer is succeeded. False if there is
//! an error during data transfer.
//!
//! \brief Synchronized data transfer from SPL Buffer to CPU memory.
//!
//! \attention It is the developers' responsibility to make sure the format
//! and size of the CPU memory that ptr points to are valid.
//!
//////////////////////////////////////////////////////////////////////////
bool Buffer::writeData(void *ptr, unsigned long size)
{
char *cpuPtr = static_cast<char*>(ptr);
if (!cpuPtr)
{
return false;
}
waitOutputEvent();
CALuint pitch;
char* gpuPtr = static_cast<char*>(getPointerCPU(pitch));
if (!gpuPtr)
{
return false;
}
// element size
unsigned short elementStride = utils::getElementBytes(_dataFormat);
//bytes in the gpu buffer
unsigned int height = _height == 0 ? 1 : _height; //1D
unsigned int bufferBytes =
elementStride * _width * height;
//bytes in the cpu buffer
unsigned int totalBytes = size * elementStride;
if (bufferBytes < totalBytes)
{
return false;
}
unsigned int cpuRowStride = elementStride * _width;
unsigned int gpuRowStride = elementStride * pitch;
if (cpuRowStride == gpuRowStride)
{
memcpy(cpuPtr, gpuPtr, totalBytes);
}
else
{
for (unsigned int row = 0; row < height - 1; row++)
{
memcpy(cpuPtr, gpuPtr, cpuRowStride);
gpuPtr += gpuRowStride;
cpuPtr += cpuRowStride;
}
size_t remainBytes = totalBytes - (cpuPtr - static_cast<char*>(ptr));
if (remainBytes)
{
memcpy(cpuPtr, gpuPtr, remainBytes);
}
}
releasePointerCPU();
return true;
}
//////////////////////////////////////////////////////////////////////////
//!
//! \param e The input Event.
//! \return bool True if the input event is successfully set. False if the
//! the event is invalid.
//!
//! \brief Set the input event of the buffer. Called when the buffer is used
//! as a input buffer in a program.
//!
//////////////////////////////////////////////////////////////////////////
bool Buffer::setInputEvent(Event* e)
{
if (!e)
return false;
if (!e->isUnused())
{
_inputEvent = e;
return true;
}
else
return false;
}
//////////////////////////////////////////////////////////////////////////
//!
//! \param e The output Event.
//! \return bool True if the output event is successfully set. False if the
//! the event is invalid.
//!
//! \brief Set the output event of the buffer. Called when the buffer is used
//! as a output buffer in a program.
//!
//////////////////////////////////////////////////////////////////////////
bool Buffer::setOutputEvent(Event* e)
{
if (!e)
return false;
if (!e->isUnused())
{
_outputEvent = e;
return true;
}
else
return false;
}
//////////////////////////////////////////////////////////////////////////
//!
//! \return void
//!
//! \brief Wait for the input event to complete. Usually called before
//! using this buffer as an output buffer.
//!
//////////////////////////////////////////////////////////////////////////
void Buffer::waitInputEvent()
{
if (!_inputEvent)
return;
else
{
_inputEvent->waitEvent();
}
}
//////////////////////////////////////////////////////////////////////////
//!
//! \return void
//!
//! \brief Wait for the output event to complete. Usually called before
//! using this buffer as an input buffer.
//!
//////////////////////////////////////////////////////////////////////////
void Buffer::waitOutputEvent()
{
if (!_outputEvent)
return;
else
{
_outputEvent->waitEvent();
}
}
//////////////////////////////////////////////////////////////////////////
//!
//! \return unsigned int
//!
//! \brief Get the pitch of the buffer.
//!
//////////////////////////////////////////////////////////////////////////
unsigned int Buffer::getPitch()
{
if(!_pitch)
{
getPointerCPU(_pitch);
releasePointerCPU();
}
return _pitch;
}
//////////////////////////////////////////////////////////////////////////
//!
//! \param[out] pitch The pitch of the buffer will be set.
//! \return void* Return address of mapped memeory.
//!
//! \brief Maps Buffer to a CPU addressable pointer
//!
//////////////////////////////////////////////////////////////////////////
void* Buffer::getPointerCPU(CALuint &pitch)
{
void* bufferPtr;
CALresult result = calResMap(&bufferPtr, &pitch,
_res, 0);
CHECK_CAL_RESULT_ERROR2(result, "Failed to get CPU pointer\n");
return bufferPtr;
}
//////////////////////////////////////////////////////////////////////////
//!
//! \return void
//!
//! \brief Frees mapped memory
//!
//////////////////////////////////////////////////////////////////////////
void Buffer::releasePointerCPU()
{
CALresult result = calResUnmap(_res);
LOG_CAL_RESULT_ERROR(result, "Failed to unmap resource\n");
}
}
}
}
|
[
"jiawei.ou@1960d7c4-c739-11dd-8829-37334faa441c"
] |
[
[
[
1,
363
]
]
] |
fc452a6135b284e60b6b0050b40e00921fb7bb85
|
216ae2fd7cba505c3690eaae33f62882102bd14a
|
/utils/nxogre/include/NxOgreScenePrototype.h
|
792ff3e7c5ae262771df0c7eefae4638040104bb
|
[] |
no_license
|
TimelineX/balyoz
|
c154d4de9129a8a366c1b8257169472dc02c5b19
|
5a0f2ee7402a827bbca210d7c7212a2eb698c109
|
refs/heads/master
| 2021-01-01T05:07:59.597755 | 2010-04-20T19:53:52 | 2010-04-20T19:53:52 | 56,454,260 | 0 | 0 | null | null | null | null |
WINDOWS-1252
|
C++
| false | false | 2,373 |
h
|
/** File: NxOgreScenePrototype.h
Created on: 6-Nov-08
Author: Robin Southern "betajaen"
SVN: $Id$
© Copyright, 2008-2009 by Robin Southern, http://www.nxogre.org
This file is part of NxOgre.
NxOgre is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
NxOgre is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with NxOgre. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef NXOGRE_SCENEPROTOTYPE_H
#define NXOGRE_SCENEPROTOTYPE_H
#include "NxOgreStable.h"
#include "NxOgreCommon.h"
#include "NxOgrePointerClass.h"
#include "NxOgreSceneDescription.h"
namespace NxOgre_Namespace
{
/** \brief
*/
class NxOgrePublicClass ScenePrototype : public SceneDescription, public PointerClass<::NxOgre::Classes::_ScenePrototype>
{
public: // Functions
/** \brief ScenePrototype constructor
*/
ScenePrototype(void);
/** \brief ScenePrototype destructor
*/
~ScenePrototype(void);
/** \brief Reset the Scene to the most default values, with no Scenes.
*/
void reset(void);
/** \brief Does the prototype's variables are in the range of acceptable values?
*/
bool valid(void);
}; // class ScenePrototype
} // namespace NxOgre_Namespace
#endif
|
[
"umutert@b781d008-8b8c-11de-b664-3b115b7b7a9b"
] |
[
[
[
1,
75
]
]
] |
1544da81194857d01d51fe823f5db372856182fd
|
9566086d262936000a914c5dc31cb4e8aa8c461c
|
/EnigmaProtocol/Messages/MovementRequestMessage.hpp
|
e3186c4459b32eee87fae66b66b304a287fc1ae8
|
[] |
no_license
|
pazuzu156/Enigma
|
9a0aaf0cd426607bb981eb46f5baa7f05b66c21f
|
b8a4dfbd0df206e48072259dbbfcc85845caad76
|
refs/heads/master
| 2020-06-06T07:33:46.385396 | 2011-12-19T03:14:15 | 2011-12-19T03:14:15 | 3,023,618 | 1 | 0 | null | null | null | null |
WINDOWS-1252
|
C++
| false | false | 2,129 |
hpp
|
#ifndef MOVEMENTREQUESTMESSAGE_HPP_INCLUDED
#define MOVEMENTREQUESTMESSAGE_HPP_INCLUDED
/*
Copyright © 2009 Christopher Joseph Dean Schaefer (disks86)
This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software.
Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
*/
#include "MessageContainer.hpp"
#include "string.hpp"
namespace Enigma
{
class DllExport MovementRequestMessage : public MessageContainer
{
private:
protected:
public:
MovementRequestMessage(Message& message)
:MessageContainer(message){};
MovementRequestMessage(Enigma::f32 x1,Enigma::f32 y1, Enigma::f32 z1,Enigma::f32 x2,Enigma::f32 y2, Enigma::f32 z2);
MovementRequestMessage();
~MovementRequestMessage();
static const int GetMessageType(){return 8;}
static const int GetMessageLength(){return 8;}
void PrintMessage();
Enigma::f32 GetX1();
Enigma::f32 GetY1();
Enigma::f32 GetZ1();
Enigma::f32 GetX2();
Enigma::f32 GetY2();
Enigma::f32 GetZ2();
void SetX1(Enigma::f32 value);
void SetY1(Enigma::f32 value);
void SetZ1(Enigma::f32 value);
void SetX2(Enigma::f32 value);
void SetY2(Enigma::f32 value);
void SetZ2(Enigma::f32 value);
};
};
#endif // MOVEMENTREQUESTMESSAGE_HPP_INCLUDED
|
[
"[email protected]"
] |
[
[
[
1,
58
]
]
] |
908d854ea38db14da772cba84c9d676d0fd887f7
|
bfe8eca44c0fca696a0031a98037f19a9938dd26
|
/libjingle-0.4.0/talk/base/proxyinfo.h
|
ced91e4f4ed160583412c2bd213d3278b862c457
|
[
"BSD-3-Clause"
] |
permissive
|
luge/foolject
|
a190006bc0ed693f685f3a8287ea15b1fe631744
|
2f4f13a221a0fa2fecab2aaaf7e2af75c160d90c
|
refs/heads/master
| 2021-01-10T07:41:06.726526 | 2011-01-21T10:25:22 | 2011-01-21T10:25:22 | 36,303,977 | 0 | 0 | null | null | null | null |
UTF-8
|
C++
| false | false | 2,035 |
h
|
/*
* libjingle
* Copyright 2004--2005, Google Inc.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
* EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef TALK_BASE_PROXYINFO_H__
#define TALK_BASE_PROXYINFO_H__
#include <string>
#include "talk/base/socketaddress.h"
#include "talk/base/cryptstring.h"
namespace talk_base {
enum ProxyType { PROXY_NONE, PROXY_HTTPS, PROXY_SOCKS5, PROXY_UNKNOWN };
const char * ProxyToString(ProxyType proxy);
struct ProxyInfo {
ProxyType type;
SocketAddress address;
std::string username;
CryptString password;
ProxyInfo() : type(PROXY_NONE) { }
};
} // namespace talk_base
#endif // TALK_BASE_PROXYINFO_H__
|
[
"[email protected]@756bb6b0-a119-0410-8338-473b6f1ccd30"
] |
[
[
[
1,
51
]
]
] |
b1761b56c25d0dad75855b524380a3c3b9447916
|
1e976ee65d326c2d9ed11c3235a9f4e2693557cf
|
/CommonSources/BitmapSaver.h
|
4cb9cdcc917d3cce2b6872b92c77e3643abe1fba
|
[] |
no_license
|
outcast1000/Jaangle
|
062c7d8d06e058186cb65bdade68a2ad8d5e7e65
|
18feb537068f1f3be6ecaa8a4b663b917c429e3d
|
refs/heads/master
| 2020-04-08T20:04:56.875651 | 2010-12-25T10:44:38 | 2010-12-25T10:44:38 | 19,334,292 | 3 | 0 | null | null | null | null |
UTF-8
|
C++
| false | false | 1,846 |
h
|
// /*
// *
// * Copyright (C) 2003-2010 Alexandros Economou
// *
// * This file is part of Jaangle (http://www.jaangle.com)
// *
// * This Program is free software; you can redistribute it and/or modify
// * it under the terms of the GNU General Public License as published by
// * the Free Software Foundation; either version 2, or (at your option)
// * any later version.
// *
// * This Program is distributed in the hope that it will be useful,
// * but WITHOUT ANY WARRANTY; without even the implied warranty of
// * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// * GNU General Public License for more details.
// *
// * You should have received a copy of the GNU General Public License
// * along with GNU Make; see the file COPYING. If not, write to
// * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
// * http://www.gnu.org/copyleft/gpl.html
// *
// */
#ifndef _BitmapSaver_h_
#define _BitmapSaver_h_
class BitmapSaver
{
public:
BitmapSaver():m_format(F_Jpg),m_quality(70){}
~BitmapSaver(){}
enum SaveFormat
{
F_First,
F_Bmp,
F_Jpg,
F_Gif,
F_Tiff,
F_Png,
F_Last
};
void SetFormat(SaveFormat f);
void SetQuality(INT quality);
BOOL SaveHBITMAP(LPCTSTR fName, HBITMAP hBitmap);
BOOL SaveClipboard(LPCTSTR fName);
BOOL IsPictureInClipboard();
BOOL SaveScreenshot(LPCTSTR savePath, HWND hwndTarget, HWND hwndHide = NULL, BOOL bClient = FALSE);
private:
BOOL SaveFile(LPCTSTR fileName, HBITMAP hBitmap, SaveFormat format, INT quality);
PBITMAPINFO CreateBitmapInfoStruct(HBITMAP hBitmap);
int GetEncoderClsidByMIMETYPE(const WCHAR* mimeType, CLSID& clsid);
int GetEncoderCLSIDByDescription(const WCHAR* description, CLSID& clsid);
SaveFormat m_format;
INT m_quality;
};
#endif
|
[
"outcast1000@dc1b949e-fa36-4f9e-8e5c-de004ec35678"
] |
[
[
[
1,
64
]
]
] |
a5050a0470dc489531e67ce0439f44b40eeb8c69
|
559770fbf0654bc0aecc0f8eb33843cbfb5834d9
|
/haina/codes/beluga/client/moblie/Beluga_manage/Demo/Demo.h
|
3e3013f175905e42478982b9ee57e998d9658d76
|
[] |
no_license
|
CMGeorge/haina
|
21126c70c8c143ca78b576e1ddf352c3d73ad525
|
c68565d4bf43415c4542963cfcbd58922157c51a
|
refs/heads/master
| 2021-01-11T07:07:16.089036 | 2010-08-18T09:25:07 | 2010-08-18T09:25:07 | 49,005,284 | 1 | 0 | null | null | null | null |
UTF-8
|
C++
| false | false | 517 |
h
|
// Demo.h : main header file for the PROJECT_NAME application
//
#pragma once
#ifndef __AFXWIN_H__
#error "include 'stdafx.h' before including this file for PCH"
#endif
#ifdef POCKETPC2003_UI_MODEL
#include "resourceppc.h"
#endif
// CDemoApp:
// See Demo.cpp for the implementation of this class
//
class CDemoApp : public CWinApp
{
public:
CDemoApp();
// Overrides
public:
virtual BOOL InitInstance();
// Implementation
DECLARE_MESSAGE_MAP()
};
extern CDemoApp theApp;
|
[
"dennis.wsh@6c45ac76-16e4-11de-9d52-39b120432c5d"
] |
[
[
[
1,
32
]
]
] |
448d8d0b1f39f5fa34e1524866a1a236d2f9658d
|
478570cde911b8e8e39046de62d3b5966b850384
|
/apicompatanamdw/bcdrivers/mw/ipconnmgmt/connection_settings_api/src/cmmgrbctestsmanager.cpp
|
5d243af6ad635b7159bbe60d99fb6788d2089d48
|
[] |
no_license
|
SymbianSource/oss.FCL.sftools.ana.compatanamdw
|
a6a8abf9ef7ad71021d43b7f2b2076b504d4445e
|
1169475bbf82ebb763de36686d144336fcf9d93b
|
refs/heads/master
| 2020-12-24T12:29:44.646072 | 2010-11-11T14:03:20 | 2010-11-11T14:03:20 | 72,994,432 | 0 | 0 | null | null | null | null |
UTF-8
|
C++
| false | false | 24,301 |
cpp
|
/*
* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
* All rights reserved.
* This component and the accompanying materials are made available
* under the terms of "Eclipse Public License v1.0"
* which accompanies this distribution, and is available
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
*
* Initial Contributors:
* Nokia Corporation - initial contribution.
*
* Contributors:
*
* Description:
* This file contains implementation of binary compability test cases
* for RCmManager-class. (STIF harcoded test module).
*
*/
#include <cmmanager.h>
#include <cmmanagerdef.h>
#include <cmgenconnsettings.h>
#include <cmdestination.h>
#include <cmconnectionmethod.h>
#include <cmpluginpacketdatadef.h>
#ifndef CMMGRBC_S60_101_SUPPORT
#include <gulicon.h> // For CGulIcon
#endif // CMMGRBC_S60_101_SUPPORT
#include "cmmgrbc.h"
// -----------------------------------------------------------------------------
// CCmmgrBc::TCmManagerConstructionL
//
// Tests:
// inline RCmManager()
// IMPORT_C void OpenL()
// IMPORT_C void Close()
// IMPORT_C void OpenLC()
// -----------------------------------------------------------------------------
//
TInt CCmmgrBc::TCmManagerConstructionL( TTestResult& aResult )
{
TInt errorCount( 0 );
RCmManager* cmManager = new( ELeave ) RCmManager();
CleanupStack::PushL( cmManager );
cmManager->OpenL();
cmManager->Close();
CleanupStack::Pop( cmManager );
cmManager->OpenLC();
CleanupStack::PopAndDestroy( cmManager );
return SetTestCaseResult( aResult, errorCount );
}
// -----------------------------------------------------------------------------
// CCmmgrBc::TCmManagerCreateTablesAndOpenL
//
// Tests:
// IMPORT_C void CreateTablesAndOpenL()
// -----------------------------------------------------------------------------
//
TInt CCmmgrBc::TCmManagerCreateTablesAndOpenL( TTestResult& aResult )
{
TInt errorCount( 0 );
RCmManager cmManager;
CleanupClosePushL( cmManager );
cmManager.CreateTablesAndOpenL();
CleanupStack::PopAndDestroy( &cmManager );
return SetTestCaseResult( aResult, errorCount );
}
// -----------------------------------------------------------------------------
// CCmmgrBc::TCmManagerBearerPriorityArray
//
// Tests:
// IMPORT_C void BearerPriorityArrayL( RArray<TBearerPriority>& ) const
// IMPORT_C void UpdateBearerPriorityArrayL( const RArray<TBearerPriority>& )
// IMPORT_C void CleanupGlobalPriorityArray( RArray<TBearerPriority>& ) const
// -----------------------------------------------------------------------------
//
TInt CCmmgrBc::TCmManagerBearerPriorityArrayL( TTestResult& aResult )
{
TInt errorCount( 0 );
RCmManager cmManager;
CleanupClosePushL( cmManager );
cmManager.OpenL();
RArray<TBearerPriority> array;
CleanupClosePushL( array );
cmManager.BearerPriorityArrayL( array );
cmManager.UpdateBearerPriorityArrayL( array );
cmManager.CleanupGlobalPriorityArray( array );
CleanupStack::PopAndDestroy( &array );
CleanupStack::PopAndDestroy( &cmManager );
return SetTestCaseResult( aResult, errorCount );
}
// -----------------------------------------------------------------------------
// CCmmgrBc::TCmManagerDefConnSettingsL
//
// Tests:
// IMPORT_C void ReadDefConnL( TCmDefConnValue& )
// IMPORT_C void WriteDefConnL( const TCmDefConnValue& )
// -----------------------------------------------------------------------------
//
TInt CCmmgrBc::TCmManagerDefConnSettingsL( TTestResult& aResult )
{
TInt errorCount( 0 );
RCmManager cmManager;
CleanupClosePushL( cmManager );
cmManager.OpenL();
TCmDefConnValue defConn;
cmManager.ReadDefConnL( defConn );
cmManager.WriteDefConnL( defConn );
CleanupStack::PopAndDestroy( &cmManager );
return SetTestCaseResult( aResult, errorCount );
}
#ifdef CMMGRBC_S60_092_SUPPORT
// -----------------------------------------------------------------------------
// CCmmgrBc::TCmManagerGenConnSettingsL
//
// Tests:
// IMPORT_C void ReadGenConnSettingsL( TCmGenConnSettings& )
// IMPORT_C void WriteGenConnSettingsL( const TCmGenConnSettings& )
// -----------------------------------------------------------------------------
//
TInt CCmmgrBc::TCmManagerGenConnSettingsL( TTestResult& aResult )
{
TInt errorCount( 0 );
RCmManager cmManager;
CleanupClosePushL( cmManager );
cmManager.OpenL();
TCmGenConnSettings genConnSettings;
cmManager.ReadGenConnSettingsL( genConnSettings );
cmManager.WriteGenConnSettingsL( genConnSettings );
CleanupStack::PopAndDestroy( &cmManager );
return SetTestCaseResult( aResult, errorCount );
}
#endif // CMMGRBC_S60_092_SUPPORT
// -----------------------------------------------------------------------------
// CCmmgrBc::TCmManagerEasyWlanIdL
//
// Tests:
// IMPORT_C TUint32 EasyWlanIdL() const
// -----------------------------------------------------------------------------
//
TInt CCmmgrBc::TCmManagerEasyWlanIdL( TTestResult& aResult )
{
TInt errorCount( 0 );
RCmManager cmManager;
CleanupClosePushL( cmManager );
cmManager.OpenL();
TUint32 id = cmManager.EasyWlanIdL();
CleanupStack::PopAndDestroy( &cmManager );
return SetTestCaseResult( aResult, errorCount );
}
// -----------------------------------------------------------------------------
// CCmmgrBc::TCmManagerGetBearerInfoL
//
// Tests:
// IMPORT_C TUint32 GetBearerInfoIntL( TUint32, TUint32 ) const
// IMPORT_C TBool GetBearerInfoBoolL( TUint32, TUint32 ) const
// IMPORT_C HBufC* GetBearerInfoStringL( TUint32, TUint32 ) const
// IMPORT_C HBufC8* GetBearerInfoString8L( TUint32, TUint32 ) const
// -----------------------------------------------------------------------------
//
TInt CCmmgrBc::TCmManagerGetBearerInfoL( TTestResult& aResult )
{
TInt errorCount( 0 );
RCmManager cmManager;
CleanupClosePushL( cmManager );
cmManager.OpenL();
TInt err( KErrNone );
TUint32 intValue = 0;
TBool boolValue = 0;
HBufC* bufPointer = NULL;
HBufC8* buf8Pointer = NULL;
TRAP( err, intValue = cmManager.GetBearerInfoIntL( 0, 0 ) );
if ( err != KErrNotSupported )
{
intValue = intValue;
errorCount++;
_LIT( KLogStr01, "ERROR from GetBearerInfoIntL(), code <%d>" );
iLog->Log( KLogStr01, err );
}
err = KErrNone;
TRAP( err, boolValue = cmManager.GetBearerInfoBoolL( 0, 0 ) );
if ( err != KErrNotSupported )
{
boolValue = boolValue;
errorCount++;
_LIT( KLogStr01, "ERROR from GetBearerInfoBoolL(), code <%d>" );
iLog->Log( KLogStr01, err );
}
err = KErrNone;
TRAP( err, bufPointer = cmManager.GetBearerInfoStringL( 0, 0 ) );
if ( err != KErrNotSupported )
{
bufPointer = bufPointer;
errorCount++;
_LIT( KLogStr01, "ERROR from GetBearerInfoStringL(), code <%d>" );
iLog->Log( KLogStr01, err );
}
err = KErrNone;
TRAP( err, buf8Pointer = cmManager.GetBearerInfoString8L( 0, 0 ) );
if ( err != KErrNotSupported )
{
buf8Pointer = buf8Pointer;
errorCount++;
_LIT( KLogStr01, "ERROR from GetBearerInfoString8L(), code <%d>" );
iLog->Log( KLogStr01, err );
}
err = KErrNone;
CleanupStack::PopAndDestroy( &cmManager );
return SetTestCaseResult( aResult, errorCount );
}
// -----------------------------------------------------------------------------
// CCmmgrBc::TCmManagerGetConnMethodInfoL
//
// Tests:
// IMPORT_C TUint32 GetConnectionMethodInfoIntL( TUint32, TUint32 ) const
// IMPORT_C TBool GetConnectionMethodInfoBoolL( TUint32, TUint32 ) const
// IMPORT_C HBufC* GetConnectionMethodInfoStringL( TUint32, TUint32 ) const
// IMPORT_C HBufC8* GetConnectionMethodInfoString8L( TUint32, TUint32 ) const
// -----------------------------------------------------------------------------
//
TInt CCmmgrBc::TCmManagerGetConnMethodInfoL( TTestResult& aResult )
{
TInt errorCount( 0 );
RCmManager cmManager;
CleanupClosePushL( cmManager );
cmManager.OpenL();
TInt err( KErrNone );
TUint32 intValue = 0;
TBool boolValue = 0;
HBufC* bufPointer = NULL;
HBufC8* buf8Pointer = NULL;
TRAP( err, intValue = cmManager.GetConnectionMethodInfoIntL( 0, 0 ) );
if ( err != KErrNotFound )
{
intValue = intValue;
errorCount++;
_LIT( KLogStr01, "ERROR from GetConnectionMethodInfoIntL(), code <%d>" );
iLog->Log( KLogStr01, err );
}
err = KErrNone;
TRAP( err, boolValue = cmManager.GetConnectionMethodInfoBoolL( 0, 0 ) );
if ( err != KErrNotFound )
{
boolValue = boolValue;
errorCount++;
_LIT( KLogStr01, "ERROR from GetConnectionMethodInfoBoolL(), code <%d>" );
iLog->Log( KLogStr01, err );
}
err = KErrNone;
TRAP( err, bufPointer = cmManager.GetConnectionMethodInfoStringL( 0, 0 ) );
if ( err != KErrNotFound )
{
bufPointer = bufPointer;
errorCount++;
_LIT( KLogStr01, "ERROR from GetConnectionMethodInfoStringL(), code <%d>" );
iLog->Log( KLogStr01, err );
}
err = KErrNone;
TRAP( err, buf8Pointer = cmManager.GetConnectionMethodInfoString8L( 0, 0 ) );
if ( err != KErrNotFound )
{
buf8Pointer = buf8Pointer;
errorCount++;
_LIT( KLogStr01, "ERROR from GetConnectionMethodInfoString8L(), code <%d>" );
iLog->Log( KLogStr01, err );
}
err = KErrNone;
CleanupStack::PopAndDestroy( &cmManager );
return SetTestCaseResult( aResult, errorCount );
}
// -----------------------------------------------------------------------------
// CCmmgrBc::TCmManagerAllDestinationsL
//
// Tests:
// IMPORT_C void AllDestinationsL( RArray<TUint32>& ) const
// -----------------------------------------------------------------------------
//
TInt CCmmgrBc::TCmManagerAllDestinationsL( TTestResult& aResult )
{
TInt errorCount( 0 );
RCmManager cmManager;
CleanupClosePushL( cmManager );
cmManager.OpenL();
RArray<TUint32> idArray;
CleanupClosePushL( idArray );
cmManager.AllDestinationsL( idArray );
CleanupStack::PopAndDestroy( &idArray );
CleanupStack::PopAndDestroy( &cmManager );
return SetTestCaseResult( aResult, errorCount );
}
// -----------------------------------------------------------------------------
// CCmmgrBc::TCmManagerAllConnMethodsL
//
// Tests:
// IMPORT_C void ConnectionMethodL( RArray<TUint32>&, TBool, TBool, TBool ) const
// -----------------------------------------------------------------------------
//
TInt CCmmgrBc::TCmManagerAllConnMethodsL( TTestResult& aResult )
{
TInt errorCount( 0 );
RCmManager cmManager;
CleanupClosePushL( cmManager );
cmManager.OpenL();
RArray<TUint32> idArray;
CleanupClosePushL( idArray );
cmManager.ConnectionMethodL( idArray, EFalse, EFalse, ETrue );
CleanupStack::PopAndDestroy( &idArray );
CleanupStack::PopAndDestroy( &cmManager );
return SetTestCaseResult( aResult, errorCount );
}
// -----------------------------------------------------------------------------
// CCmmgrBc::TCmManagerSupportedBearersL
//
// Tests:
// IMPORT_C void SupportedBearersL( RArray<TUint32>& ) const
// -----------------------------------------------------------------------------
//
TInt CCmmgrBc::TCmManagerSupportedBearersL( TTestResult& aResult )
{
TInt errorCount( 0 );
RCmManager cmManager;
CleanupClosePushL( cmManager );
cmManager.OpenL();
RArray<TUint32> bearerArray;
CleanupClosePushL( bearerArray );
cmManager.SupportedBearersL( bearerArray );
CleanupStack::PopAndDestroy( &bearerArray );
CleanupStack::PopAndDestroy( &cmManager );
return SetTestCaseResult( aResult, errorCount );
}
// -----------------------------------------------------------------------------
// CCmmgrBc::TCmManagerCreateAndOpenDestinationsL
//
// Tests:
// IMPORT_C RCmDestination CreateDestinationL( const TDesC& )
// IMPORT_C RCmDestination CreateDestinationL( const TDesC&, TUint32 )
// IMPORT_C RCmDestination DestinationL( TUint32 ) const
// -----------------------------------------------------------------------------
//
TInt CCmmgrBc::TCmManagerCreateAndOpenDestinationsL( TTestResult& aResult )
{
TInt errorCount( 0 );
RCmManager cmManager;
CleanupClosePushL( cmManager );
cmManager.OpenL();
_LIT( KCmmgrbcSnapName01, "CmmgrbcTemp01" );
_LIT( KCmmgrbcSnapName02, "CmmgrbcTemp02" );
RCmDestination destination = cmManager.CreateDestinationL( KCmmgrbcSnapName01() );
CleanupClosePushL( destination );
destination.UpdateL();
TUint32 destinationId = destination.Id();
CleanupStack::PopAndDestroy( &destination );
TInt err( KErrNone );
RCmDestination destination2;
TRAP( err, destination2 = cmManager.CreateDestinationL( KCmmgrbcSnapName02(), destinationId ) );
CleanupClosePushL( destination2 );
if ( err != KErrAlreadyExists )
{
errorCount++;
_LIT( KLogStr01, "ERROR from CreateDestinationL(name,id), code <%d>" );
iLog->Log( KLogStr01, err );
}
CleanupStack::PopAndDestroy( &destination2 );
RCmDestination destination3 = cmManager.DestinationL( destinationId );
CleanupClosePushL( destination3 );
destination3.DeleteLD();
CleanupStack::Pop( &destination3 );
CleanupStack::PopAndDestroy( &cmManager );
return SetTestCaseResult( aResult, errorCount );
}
// -----------------------------------------------------------------------------
// CCmmgrBc::TCmManagerCreateAndOpenConnMethodsL
//
// Tests:
// IMPORT_C RCmConnectionMethod CreateConnectionMethodL( TUint32 )
// IMPORT_C RCmConnectionMethod CreateConnectionMethodL( TUint32, TUint32 )
// IMPORT_C RCmConnectionMethod ConnectionMethodL( TUint32 ) const
// -----------------------------------------------------------------------------
//
TInt CCmmgrBc::TCmManagerCreateAndOpenConnMethodsL( TTestResult& aResult )
{
TInt errorCount( 0 );
TInt err( KErrNone );
RCmManager cmManager;
CleanupClosePushL( cmManager );
cmManager.OpenL();
RCmConnectionMethod connMethod1;
TRAP( err, connMethod1 = cmManager.CreateConnectionMethodL( 0 ) );
CleanupClosePushL( connMethod1 );
if ( err != KErrArgument )
{
errorCount++;
_LIT( KLogStr01, "ERROR from CreateConnectionMethodL(bearer), code <%d>" );
iLog->Log( KLogStr01, err );
}
err = KErrNone;
CleanupStack::PopAndDestroy( &connMethod1 );
RCmConnectionMethod connMethod2;
TRAP( err, connMethod2 = cmManager.CreateConnectionMethodL( 0, 1 ) );
CleanupClosePushL( connMethod2 );
if ( err != KErrArgument )
{
errorCount++;
_LIT( KLogStr01, "ERROR from CreateConnectionMethodL(bearer,id), code <%d>" );
iLog->Log( KLogStr01, err );
}
err = KErrNone;
CleanupStack::PopAndDestroy( &connMethod2 );
RArray<TUint32> idArray;
CleanupClosePushL( idArray );
cmManager.ConnectionMethodL( idArray, EFalse, EFalse, ETrue );
if ( idArray.Count() > 0 )
{
_LIT( KLogStr02, "id = %d" );
for ( TInt i = 0; i < idArray.Count(); i++ )
{
iLog->Log( KLogStr02, idArray[i] );
}
RCmConnectionMethod connMethod3;
connMethod3 = cmManager.ConnectionMethodL( idArray[idArray.Count()-1] );
CleanupClosePushL( connMethod3 );
CleanupStack::PopAndDestroy( &connMethod3 );
}
else
{
RCmConnectionMethod connMethod3;
TRAP( err, connMethod3 = cmManager.ConnectionMethodL( 1 ) );
CleanupClosePushL( connMethod3 );
if ( err != KErrNotFound )
{
errorCount++;
_LIT( KLogStr01, "ERROR from ConnectionMethodL(id), code <%d>" );
iLog->Log( KLogStr01, err );
}
err = KErrNone;
CleanupStack::PopAndDestroy( &connMethod3 );
}
CleanupStack::PopAndDestroy( &idArray );
CleanupStack::PopAndDestroy( &cmManager );
return SetTestCaseResult( aResult, errorCount );
}
// -----------------------------------------------------------------------------
// CCmmgrBc::TCmManagerCopyAndRemoveAllConnMethodL
//
// Tests:
// IMPORT_C TInt CopyConnectionMethodL( RCmDestination&, RCmConnectionMethod& )
// IMPORT_C void RemoveAllReferencesL( RCmConnectionMethod& )
// -----------------------------------------------------------------------------
//
TInt CCmmgrBc::TCmManagerCopyAndRemoveAllConnMethodL( TTestResult& aResult )
{
TInt errorCount( 0 );
_LIT( KCmmgrbcSnapName01, "CmmgrbcTempSnap1" );
_LIT( KCmmgrbcSnapName02, "CmmgrbcTempSnap2" );
_LIT( KCmmgrbcIapName1, "CmmgrbcTempIap1" );
_LIT( KCmmgrbcIapAp, "internet" );
RCmManager cmManager;
CleanupClosePushL( cmManager );
cmManager.OpenL();
// Create 2 destinations
RCmDestination destination1;
destination1 = cmManager.CreateDestinationL( KCmmgrbcSnapName01() );
CleanupClosePushL( destination1 );
destination1.UpdateL();
MyDelay();
RCmDestination destination2;
destination2 = cmManager.CreateDestinationL( KCmmgrbcSnapName02() );
CleanupClosePushL( destination2 );
destination2.UpdateL();
MyDelay();
// Check supported bearers. If packet data bearer is not supported, test
// can't be executed.
// Since packet data should always be supported, fail the test so the cause
// can be investigated.
RArray<TUint32> bearerArray;
CleanupClosePushL( bearerArray );
cmManager.SupportedBearersL( bearerArray );
TBool packetDataSupported( EFalse );
for ( TInt i = 0; i < bearerArray.Count(); i++ )
{
if ( bearerArray[i] == KUidPacketDataBearerType )
{
packetDataSupported = ETrue;
}
}
CleanupStack::PopAndDestroy( &bearerArray );
if ( !packetDataSupported )
{
errorCount++;
_LIT( KLogStr01, "ERROR: Packet data bearer is unsupported. Test stopped" );
iLog->Log( KLogStr01 );
}
else
{
// Create a connection method
RCmConnectionMethod connectionMethod1;
connectionMethod1 = destination1.CreateConnectionMethodL( KUidPacketDataBearerType );
CleanupClosePushL( connectionMethod1 );
connectionMethod1.SetStringAttributeL( CMManager::ECmName, KCmmgrbcIapName1() );
connectionMethod1.SetStringAttributeL( CMManager::EPacketDataAPName, KCmmgrbcIapAp() );
destination1.UpdateL();
MyDelay();
cmManager.CopyConnectionMethodL( destination2, connectionMethod1 );
MyDelay();
cmManager.RemoveAllReferencesL( connectionMethod1 );
MyDelay();
connectionMethod1.DeleteL();
MyDelay();
CleanupStack::PopAndDestroy( &connectionMethod1 );
}
// Remove the created destinations
destination1.DeleteLD();
MyDelay();
destination2.DeleteLD();
MyDelay();
CleanupStack::Pop( &destination2 );
CleanupStack::Pop( &destination1 );
CleanupStack::PopAndDestroy( &cmManager );
return SetTestCaseResult( aResult, errorCount );
}
// -----------------------------------------------------------------------------
// CCmmgrBc::TCmManagerMoveAndRemoveConnMethodL
//
// Tests:
// IMPORT_C TInt MoveConnectionMethodL( RCmDestination&, RCmDestination&, RCmConnectionMethod& )
// IMPORT_C void RemoveConnectionMethodL( RCmDestination&, RCmConnectionMethod& )
// -----------------------------------------------------------------------------
//
TInt CCmmgrBc::TCmManagerMoveAndRemoveConnMethodL( TTestResult& aResult )
{
TInt errorCount( 0 );
_LIT( KCmmgrbcSnapName01, "CmmgrbcTempSnap1" );
_LIT( KCmmgrbcSnapName02, "CmmgrbcTempSnap2" );
_LIT( KCmmgrbcIapName1, "CmmgrbcTempIap1" );
_LIT( KCmmgrbcIapAp, "internet" );
RCmManager cmManager;
CleanupClosePushL( cmManager );
cmManager.OpenL();
// Create 2 destinations
RCmDestination destination1;
destination1 = cmManager.CreateDestinationL( KCmmgrbcSnapName01() );
CleanupClosePushL( destination1 );
destination1.UpdateL();
MyDelay();
RCmDestination destination2;
destination2 = cmManager.CreateDestinationL( KCmmgrbcSnapName02() );
CleanupClosePushL( destination2 );
destination2.UpdateL();
MyDelay();
// Check supported bearers. If packet data bearer is not supported, test
// can't be executed.
// Since packet data should always be supported, fail the test so the cause
// can be investigated.
RArray<TUint32> bearerArray;
CleanupClosePushL( bearerArray );
cmManager.SupportedBearersL( bearerArray );
TBool packetDataSupported( EFalse );
for ( TInt i = 0; i < bearerArray.Count(); i++ )
{
if ( bearerArray[i] == KUidPacketDataBearerType )
{
packetDataSupported = ETrue;
}
}
CleanupStack::PopAndDestroy( &bearerArray );
if ( !packetDataSupported )
{
errorCount++;
_LIT( KLogStr01, "ERROR: Packet data bearer is unsupported. Test stopped" );
iLog->Log( KLogStr01 );
}
else
{
// Create a connection method
RCmConnectionMethod connectionMethod1;
connectionMethod1 = destination1.CreateConnectionMethodL( KUidPacketDataBearerType );
CleanupClosePushL( connectionMethod1 );
connectionMethod1.SetStringAttributeL( CMManager::ECmName, KCmmgrbcIapName1() );
connectionMethod1.SetStringAttributeL( CMManager::EPacketDataAPName, KCmmgrbcIapAp() );
destination1.UpdateL();
MyDelay();
cmManager.MoveConnectionMethodL( destination1, destination2, connectionMethod1 );
MyDelay();
cmManager.RemoveConnectionMethodL( destination2, connectionMethod1 );
MyDelay();
connectionMethod1.DeleteL();
MyDelay();
CleanupStack::PopAndDestroy( &connectionMethod1 );
}
// Remove the created destinations
destination1.DeleteLD();
MyDelay();
destination2.DeleteLD();
MyDelay();
CleanupStack::Pop( &destination2 );
CleanupStack::Pop( &destination1 );
CleanupStack::PopAndDestroy( &cmManager );
return SetTestCaseResult( aResult, errorCount );
}
#ifndef CMMGRBC_S60_101_SUPPORT
// -----------------------------------------------------------------------------
// CCmmgrBc::TCmManagerUncategorizedIconL
//
// Tests:
// IMPORT_C CGulIcon* UncategorizedIconL() const
// -----------------------------------------------------------------------------
//
TInt CCmmgrBc::TCmManagerUncategorizedIconL( TTestResult& aResult )
{
TInt errorCount( 0 );
RCmManager cmManager;
CleanupClosePushL( cmManager );
cmManager.OpenL();
CGulIcon* p;
p = NULL;
TRAPD( err, p = cmManager.UncategorizedIconL() );
if ( err )
{
_LIT( KLogStr01, "LEAVE from UncategorizedIconL(), code <%d>" );
iLog->Log( KLogStr01, err );
}
else
{
_LIT( KLogStr01, "No LEAVE from UncategorizedIconL(), code <%d>" );
iLog->Log( KLogStr01, err );
}
delete p;
CleanupStack::PopAndDestroy( &cmManager );
return SetTestCaseResult( aResult, errorCount );
}
#endif // CMMGRBC_S60_101_SUPPORT
// End of file
|
[
"none@none"
] |
[
[
[
1,
729
]
]
] |
df6aa2f840b72b4c15880492b1d162c47d1c9f4d
|
4d3983366ea8a2886629d9a39536f0cd05edd001
|
/src/main/bitmap.cpp
|
895edc34102403c2d9aa8ba49773f3a7e7adc83e
|
[] |
no_license
|
clteng5316/rodents
|
033a06d5ad11928425a40203a497ea95e98ce290
|
7be0702d0ad61d9a07295029ba77d853b87aba64
|
refs/heads/master
| 2021-01-10T13:05:13.757715 | 2009-08-07T14:46:13 | 2009-08-07T14:46:13 | 36,857,795 | 1 | 0 | null | null | null | null |
SHIFT_JIS
|
C++
| false | false | 5,360 |
cpp
|
// bitmap.cpp
#include "stdafx.h"
#include "win32.hpp"
#include "math.hpp"
#include "string.hpp"
static Color SysColor(int n)
{
COLORREF c = ::GetSysColor(n);
return Color(GetRValue(c), GetGValue(c), GetBValue(c));
}
static void CopyBits(void* dst, int dststride, const void* src, int srcstride, size_t bpp, size_t width, size_t height)
{
if (dststride >= 0 && dststride == srcstride)
{
memcpy(dst, src, srcstride * height);
}
else
{
BYTE* d = (BYTE*)dst;
BYTE* s = (BYTE*)src;
for (size_t i = 0; i < height; ++i)
{
memcpy(d, s, bpp * width);
d += dststride;
s += srcstride;
}
}
}
//==========================================================================================================================
HBITMAP BitmapLoad(IStream* stream, const SIZE* sz) throw()
{
Image image(stream);
if (image.GetLastStatus() != Ok)
return NULL;
return BitmapLoad(&image, sz);
}
HBITMAP BitmapLoad(PCWSTR filename, const SIZE* sz) throw()
{
Image image(filename);
if (image.GetLastStatus() != Ok)
return NULL;
return BitmapLoad(&image, sz);
}
HBITMAP BitmapLoad(Image* image, const SIZE* sz) throw()
{
int w = image->GetWidth();
int h = image->GetHeight();
if (w <= 0 || h <= 0)
return null;
if (sz && (sz->cx < w || sz->cy < h))
{
double sq = sz->cx * sz->cy;
// 面積一定
if (w > h)
{
int ww = math::min(sz->cx * 2, (long) math::sqrt(sq * w / h));
h = ww * h / w;
w = ww;
}
else
{
int hh = math::min(sz->cy * 2, (long) math::sqrt(sq * h / w));
w = hh * w / h;
h = hh;
}
}
// 非常に汚い画像になる場合があるので GetThumbnailImage は使わない
RECT rc = { 0, 0, w, h };
HDC dcScreen = GetDC(NULL);
HBITMAP bitmap = CreateCompatibleBitmap(dcScreen, w, h);
HDC dc = CreateCompatibleDC(dcScreen);
ReleaseDC(NULL, dcScreen);
HGDIOBJ old = SelectObject(dc, bitmap);
FillRect(dc, &rc, (HBRUSH)::GetStockObject(WHITE_BRUSH));
Graphics(dc).DrawImage(image, 0, 0, w, h);
SelectObject(dc, old);
DeleteDC(dc);
return bitmap;
}
//==========================================================================================================================
HIMAGELIST ImageListLoad(IStream* stream) throw()
{
HIMAGELIST imagelist = NULL;
Bitmap* image = new Bitmap(stream);
if (image->GetLastStatus() == Ok)
imagelist = ImageListLoad(image);
delete image;
return imagelist;
}
HIMAGELIST ImageListLoad(PCWSTR filename) throw()
{
HIMAGELIST imagelist = NULL;
Bitmap* image = new Bitmap(filename);
if (image->GetLastStatus() == Ok)
imagelist = ImageListLoad(image);
delete image;
return imagelist;
}
HIMAGELIST ImageListLoad(Bitmap* image)
{
int w = image->GetWidth();
int h = image->GetHeight();
HIMAGELIST imagelist = ImageList_Create(h, h, ILC_COLOR32, w/h, 20);
ImageList_SetBkColor(imagelist, CLR_NONE);
if (image->GetPixelFormat() == PixelFormat32bppARGB)
{
Rect rcLock(0, 0, w, h);
BitmapData bits;
if (image->LockBits(&rcLock, ImageLockModeRead, PixelFormat32bppARGB, &bits) == Ok)
{
// TODO: ビットマップのコピーを減らすべし。
// 現在、GDI+ Bitmap → DIBSection → ImageList内バッファ と複数回のコピーが発生している。
// DIBSection をスキップできれば、コピーを減らせる。そのためには以下のどちらかの方法がある。
// ・GDI+ Bitmapの内部データを直接参照するDIBitmapを作成する。
// ・ImageList内のバッファに直接書き込む。
const int bpp = 4; // sizeof(pixel for PixelFormat32bppARGB)
BITMAPINFO info = { 0 };
info.bmiHeader.biSize = sizeof(info.bmiHeader);
info.bmiHeader.biWidth = w;
info.bmiHeader.biHeight = h;
info.bmiHeader.biPlanes = 1;
info.bmiHeader.biBitCount = 32;
info.bmiHeader.biCompression = BI_RGB;
BYTE* dst = NULL;
int dststride = ((w * bpp + 3) & ~3);
HBITMAP bitmap = CreateDIBSection(NULL, &info, DIB_RGB_COLORS, (void**)&dst, NULL, 0);
CopyBits(dst + dststride * (h-1), -dststride, bits.Scan0, bits.Stride, bpp, w, h);
image->UnlockBits(&bits);
ImageList_Add(imagelist, bitmap, NULL);
DeleteObject(bitmap);
return imagelist;
}
}
// アルファなしビットマップ
HBITMAP bitmap;
if (image->GetHBITMAP(SysColor(COLOR_3DFACE), &bitmap) != Ok)
return NULL;
ImageList_Add(imagelist, bitmap, NULL);
DeleteObject(bitmap);
return imagelist;
}
typedef std::pair<PCWSTR, const GUID*> E2F;
static const E2F EXT2FMT[] =
{
E2F(L"bmp" , &ImageFormatBMP),
E2F(L"emf" , &ImageFormatEMF),
E2F(L"exif" , &ImageFormatEXIF),
E2F(L"gif" , &ImageFormatGIF),
E2F(L"ico" , &ImageFormatIcon),
E2F(L"jpe" , &ImageFormatJPEG),
E2F(L"jpeg" , &ImageFormatJPEG),
E2F(L"jpg" , &ImageFormatJPEG),
E2F(L"png" , &ImageFormatPNG),
E2F(L"tif" , &ImageFormatTIFF),
E2F(L"tiff" , &ImageFormatTIFF),
E2F(L"wmf" , &ImageFormatWMF),
};
const GUID* ImageFormatFromExtension(PCWSTR extension)
{
while (*extension == L'.') { ++extension; }
const E2F* i = std::lower_bound(EXT2FMT, endof(EXT2FMT), extension, Less());
if (i != endof(EXT2FMT) && _wcsicmp(extension, i->first) == 0)
return i->second;
return null;
}
|
[
"itagaki.takahiro@fad0b036-4cad-11de-8d8d-752d95cf3e3c"
] |
[
[
[
1,
193
]
]
] |
ba823de0c8cc54509524235402aa2953191a837c
|
7b4c786d4258ce4421b1e7bcca9011d4eeb50083
|
/_统计专用/C++Primer中文版(第4版)/第一次-代码集合-20090414/第十四章 重载操作符与转换/20090221_习题14.25_为CheckedPtr类增加关系操作符.cpp
|
682bb649fdc733391832aed320a59a87ce6463be
|
[] |
no_license
|
lzq123218/guoyishi-works
|
dbfa42a3e2d3bd4a984a5681e4335814657551ef
|
4e78c8f2e902589c3f06387374024225f52e5a92
|
refs/heads/master
| 2021-12-04T11:11:32.639076 | 2011-05-30T14:12:43 | 2011-05-30T14:12:43 | null | 0 | 0 | null | null | null | null |
GB18030
|
C++
| false | false | 773 |
cpp
|
bool operator==(const CheckedPtr& lhs, const CheckedPtr& rhs)
{
return lhs.beg == rhs.beg && lhs.end == rhs.end && lhs.curr == rhs.curr; //指向同一数组才有意义
}
bool operator!=(const CheckedPtr& lhs, const CheckedPtr& rhs)
{
return !(lhs == rhs); //相互联系起来定义
}
bool operator<(const CheckedPtr& lhs, const CheckedPtr& rhs)
{
return lhs.beg == rhs.beg && lhs.end == rhs.end && lhs.curr < rhs.curr;
}
bool operator<=(const CheckedPtr& lhs, const CheckedPtr& rhs)
{
return !(lhs > rhs);
}
bool operator>(const CheckedPtr& lhs, const CheckedPtr& rhs)
{
return lhs.beg == rhs.beg && lhs.end == rhs.end && lhs.curr > rhs.curr;
}
bool operator>=(const CheckedPtr& lhs, const CheckedPtr& rhs)
{
return !(lhs < rhs);
}
|
[
"baicaibang@70501136-4834-11de-8855-c187e5f49513"
] |
[
[
[
1,
29
]
]
] |
25d6a3e22837f6a857a420f524e2e13cc2e57b1b
|
54cacc105d6bacdcfc37b10d57016bdd67067383
|
/trunk/source/math/matrices/RBTMatrix.h
|
49f29e5de090990b0b65b282398b18f050199b36
|
[] |
no_license
|
galek/hesperus
|
4eb10e05945c6134901cc677c991b74ce6c8ac1e
|
dabe7ce1bb65ac5aaad144933d0b395556c1adc4
|
refs/heads/master
| 2020-12-31T05:40:04.121180 | 2009-12-06T17:38:49 | 2009-12-06T17:38:49 | null | 0 | 0 | null | null | null | null |
UTF-8
|
C++
| false | false | 1,953 |
h
|
/***
* hesperus: RBTMatrix.h
* Copyright Stuart Golodetz, 2009. All rights reserved.
***/
#ifndef H_HESP_RBTMATRIX
#define H_HESP_RBTMATRIX
#include <source/math/vectors/Vector3.h>
namespace hesp {
//#################### TYPEDEFS ####################
typedef shared_ptr<class RBTMatrix> RBTMatrix_Ptr;
typedef shared_ptr<const class RBTMatrix> RBTMatrix_CPtr;
/**
This class represents rigid-body transformation matrices.
*/
class RBTMatrix
{
//#################### PRIVATE VARIABLES ####################
private:
double m[3][4];
//#################### CONSTRUCTORS ####################
private:
RBTMatrix();
//#################### STATIC FACTORY METHODS ####################
public:
static RBTMatrix_Ptr from_axis_angle_translation(Vector3d axis, double angle, const Vector3d& translation);
static RBTMatrix_Ptr identity();
static RBTMatrix_Ptr zeros();
//#################### PUBLIC OPERATORS ####################
public:
double& operator()(int i, int j);
double operator()(int i, int j) const;
//#################### PUBLIC METHODS ####################
public:
void add_scaled(const RBTMatrix_CPtr& mat, double scale);
Vector3d apply_to_point(const Vector3d& p) const;
Vector3d apply_to_vector(const Vector3d& v) const;
static RBTMatrix_Ptr copy(const RBTMatrix_CPtr& rhs);
RBTMatrix_Ptr inverse() const;
std::vector<double> rep() const;
void reset_to_zeros();
};
//#################### GLOBAL OPERATORS ####################
RBTMatrix_Ptr& operator+=(RBTMatrix_Ptr& lhs, const RBTMatrix_CPtr& rhs);
RBTMatrix_Ptr& operator*=(RBTMatrix_Ptr& lhs, const RBTMatrix_CPtr& rhs);
RBTMatrix_Ptr& operator*=(RBTMatrix_Ptr& lhs, double scale);
RBTMatrix_Ptr operator*(const RBTMatrix_CPtr& lhs, const RBTMatrix_CPtr& rhs);
RBTMatrix_Ptr operator*(const RBTMatrix_CPtr& lhs, double scale);
RBTMatrix_Ptr operator*(double scale, const RBTMatrix_CPtr& rhs);
}
#endif
|
[
"[email protected]"
] |
[
[
[
1,
62
]
]
] |
a40ec947b86ca3198e4879c00cd70b9dc38f0d4f
|
77aa13a51685597585abf89b5ad30f9ef4011bde
|
/dep/src/boost/boost/mpl/for_each.hpp
|
aab615d66b5e6a6435fe047ae17b3efbe2fbaf61
|
[] |
no_license
|
Zic/Xeon-MMORPG-Emulator
|
2f195d04bfd0988a9165a52b7a3756c04b3f146c
|
4473a22e6dd4ec3c9b867d60915841731869a050
|
refs/heads/master
| 2021-01-01T16:19:35.213330 | 2009-05-13T18:12:36 | 2009-05-14T03:10:17 | 200,849 | 8 | 10 | null | null | null | null |
UTF-8
|
C++
| false | false | 2,930 |
hpp
|
#ifndef BOOST_MPL_FOR_EACH_HPP_INCLUDED
#define BOOST_MPL_FOR_EACH_HPP_INCLUDED
// Copyright Aleksey Gurtovoy 2000-2008
//
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
// See http://www.boost.org/libs/mpl for documentation.
// $Id: for_each.hpp 49267 2008-10-11 06:19:02Z agurtovoy $
// $Date: 2008-10-11 02:19:02 -0400 (Sat, 11 Oct 2008) $
// $Revision: 49267 $
#include <boost/mpl/is_sequence.hpp>
#include <boost/mpl/begin_end.hpp>
#include <boost/mpl/apply.hpp>
#include <boost/mpl/bool.hpp>
#include <boost/mpl/next_prior.hpp>
#include <boost/mpl/deref.hpp>
#include <boost/mpl/identity.hpp>
#include <boost/mpl/assert.hpp>
#include <boost/mpl/aux_/unwrap.hpp>
#include <boost/type_traits/is_same.hpp>
#include <boost/utility/value_init.hpp>
namespace boost { namespace mpl {
namespace aux {
template< bool done = true >
struct for_each_impl
{
template<
typename Iterator
, typename LastIterator
, typename TransformFunc
, typename F
>
static void execute(
Iterator*
, LastIterator*
, TransformFunc*
, F
)
{
}
};
template<>
struct for_each_impl<false>
{
template<
typename Iterator
, typename LastIterator
, typename TransformFunc
, typename F
>
static void execute(
Iterator*
, LastIterator*
, TransformFunc*
, F f
)
{
typedef typename deref<Iterator>::type item;
typedef typename apply1<TransformFunc,item>::type arg;
// dwa 2002/9/10 -- make sure not to invoke undefined behavior
// when we pass arg.
value_initialized<arg> x;
aux::unwrap(f, 0)(boost::get(x));
typedef typename mpl::next<Iterator>::type iter;
for_each_impl<boost::is_same<iter,LastIterator>::value>
::execute((iter*)0, (LastIterator*)0, (TransformFunc*)0, f);
}
};
} // namespace aux
// agurt, 17/mar/02: pointer default parameters are necessary to workaround
// MSVC 6.5 function template signature's mangling bug
template<
typename Sequence
, typename TransformOp
, typename F
>
inline
void for_each(F f, Sequence* = 0, TransformOp* = 0)
{
BOOST_MPL_ASSERT(( is_sequence<Sequence> ));
typedef typename begin<Sequence>::type first;
typedef typename end<Sequence>::type last;
aux::for_each_impl< boost::is_same<first,last>::value >
::execute((first*)0, (last*)0, (TransformOp*)0, f);
}
template<
typename Sequence
, typename F
>
inline
void for_each(F f, Sequence* = 0)
{
for_each<Sequence, identity<> >(f);
}
}}
#endif // BOOST_MPL_FOR_EACH_HPP_INCLUDED
|
[
"pepsi1x1@a6a5f009-272a-4b40-a74d-5f9816a51f88"
] |
[
[
[
1,
116
]
]
] |
c71ede8fdeee64a1bd7c0acde71d3460b6969397
|
8a816dc2da5158e8d4f2081e6086575346869a16
|
/CSMExporter/CSMOpts.cpp
|
c0b847ca5d6802ba4bca9cc7c19a705feca93570
|
[] |
no_license
|
yyzreal/3ds-max-exporter-plugin
|
ca43f9193afd471581075528b27d8a600fd2b7fa
|
249f24c29dcfd6dd072c707f7642cf56cba06ef0
|
refs/heads/master
| 2020-04-10T14:50:13.717379 | 2011-06-12T15:10:54 | 2011-06-12T15:10:54 | 50,292,994 | 0 | 1 | null | 2016-01-24T15:07:28 | 2016-01-24T15:07:28 | null |
GB18030
|
C++
| false | false | 21,479 |
cpp
|
#include "CSMOpts.h"
HWND CSMOpts::m_hCheckAnim = 0;
HWND CSMOpts::m_hListAnim = 0;
HWND CSMOpts::m_hBtnAddAnim = 0;
HWND CSMOpts::m_hBtnEditAnim = 0;
HWND CSMOpts::m_hBtnDelAnim = 0;
HWND CSMOpts::m_hCheckTag = 0;
HWND CSMOpts::m_hBtnHead = 0;
HWND CSMOpts::m_hBtnUpper = 0;
HWND CSMOpts::m_hBtnLower = 0;
HWND CSMOpts::m_hBtnProp = 0;
HWND CSMOpts::m_hBtnHeadX = 0;
HWND CSMOpts::m_hBtnUpperX = 0;
HWND CSMOpts::m_hBtnLowerX = 0;
HWND CSMOpts::m_hBtnPropX = 0;
HWND CSMOpts::m_hCheckProp = 0;
HWND CSMOpts::m_hComBoxMount = 0;
HWND CSMOpts::m_hEditAnimName = 0;
HWND CSMOpts::m_hEditFirstFrame = 0;
HWND CSMOpts::m_hEditLastFrame = 0;
HWND CSMOpts::m_hListObj = 0;
CSMOpts::CSMOpts( int firstFrame, int lastFrame, vector< string > objList )
{
m_bExportAnim = m_bExportTags = m_bExportProperty = FALSE;
m_firstSceneFrame = firstFrame;
m_lastSceneFrame = lastFrame;
m_settedFrame = 0;
m_bIsEditingAnim = FALSE;
m_objList = objList;
}
CSMOpts::~CSMOpts()
{
}
BOOL CSMOpts::ShowOptionDialog()
{
// 弹出一个模态对话框,如果返回0,则用户点击了Cancel
return 0 != DialogBoxParam( hInstance,
MAKEINTRESOURCE( IDO_OPTIONS ),
GetActiveWindow(),
OptionDialogProc, ( LPARAM )this );
}
void CSMOpts::EnableAnimControls( BOOL bEnable )
{
EnableWindow( m_hListAnim, bEnable );
EnableWindow( m_hBtnAddAnim, bEnable );
EnableWindow( m_hBtnEditAnim, bEnable );
EnableWindow( m_hBtnDelAnim, bEnable );
}
void CSMOpts::EnableTagControls( BOOL bEnable )
{
EnableWindow( m_hBtnHead, bEnable );
EnableWindow( m_hBtnUpper, bEnable );
EnableWindow( m_hBtnLower, bEnable );
EnableWindow( m_hBtnProp, bEnable );
EnableWindow( m_hBtnHeadX, bEnable );
EnableWindow( m_hBtnUpperX, bEnable );
EnableWindow( m_hBtnLowerX, bEnable );
EnableWindow( m_hCheckProp, bEnable );
EnableWindow( m_hBtnPropX, m_bExportProperty );
EnableWindow( m_hComBoxMount, m_bExportProperty );
}
void CSMOpts::EnablePropControls( BOOL bEnable )
{
EnableWindow( m_hBtnProp, bEnable );
EnableWindow( m_hBtnPropX, bEnable );
EnableWindow( m_hComBoxMount, bEnable );
}
void CSMOpts::SetExportAnim( HWND hWnd, BOOL b )
{
m_bExportAnim = b;
int animCount = SendMessage( m_hListAnim, LVM_GETITEMCOUNT, 0, 0 );
if ( m_bExportAnim == TRUE && animCount == 0 )
{
// 动画所需的信息不完整,不导出动画
m_bExportAnim = FALSE;
MessageBox( hWnd, "你选择了导出动画,但你没有添加动画帧信息,将不会导出动画", "警告!", MB_ICONWARNING );
}
}
void CSMOpts::SetExportTags( HWND hWnd, BOOL b )
{
m_bExportTags = b;
char buf[64];
string strHead, strUpper, strLower;
ZeroMemory( buf, 64 );
GetDlgItemText( hWnd, IDC_EDIT_HEAD, buf, 64 );
strHead = buf;
ZeroMemory( buf, 64 );
GetDlgItemText( hWnd, IDC_EDIT_UPPER, buf, 64 );
strUpper = buf;
ZeroMemory( buf, 64 );
GetDlgItemText( hWnd, IDC_EDIT_LOWER, buf, 64 );
strLower = buf;
if ( m_bExportTags == TRUE &&
( strHead == "" ||
strUpper == "" ||
strLower == "" ) )
{
// TAG所需的信息不完整,不导出TAG
m_bExportTags = FALSE;
MessageBox( hWnd, "你选择了导出TAG信息,但你没有为Head, Upper, Lower全部绑定到场景节点,将不会导出TAG", "警告!", MB_ICONWARNING );
}
}
void CSMOpts::SetExportProp( HWND hWnd, BOOL b )
{
m_bExportProperty = b;
char buf[64];
string strProp, strMountTo;
ZeroMemory( buf, 64 );
GetDlgItemText( hWnd, IDC_EDIT_PROPERTY, buf, 64 );
strProp = buf;
ZeroMemory( buf, 64 );
int curSel = SendMessage( m_hComBoxMount, CB_GETCURSEL, 0, 0 );
SendMessage( m_hComBoxMount, CB_GETLBTEXT, ( WPARAM )curSel, ( LPARAM )buf );
strMountTo = buf;
if ( m_bExportProperty == TRUE && ( m_bExportTags == FALSE || strProp == "" || strMountTo == "" ) )
{
// 道具所需的信息不完整,不导出道具
m_bExportTags = FALSE;
MessageBox( hWnd, "你选择了导出道具,但道具信息填写不完整,将不会导出道具", "警告!", MB_ICONWARNING );
}
}
INT_PTR CALLBACK CSMOpts::OptionDialogProc( HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam )
{
static CSMOpts *imp = NULL;
switch( message )
{
case WM_INITDIALOG: // 初始化选项对话框
{
imp = reinterpret_cast< CSMOpts* >( lParam );
CenterWindow( hWnd,GetParent( hWnd ) );
m_hCheckAnim = GetDlgItem( hWnd, IDC_CHECK_ANIM );
m_hListAnim = GetDlgItem( hWnd, IDC_LIST_ANIM );
m_hBtnAddAnim = GetDlgItem( hWnd, IDC_BUTTON_ADD );
m_hBtnEditAnim = GetDlgItem( hWnd, IDC_BUTTON_EDIT );
m_hBtnDelAnim = GetDlgItem( hWnd, IDC_BUTTON_DELETE );
m_hCheckTag = GetDlgItem( hWnd, IDC_CHECK_TAGS );
m_hBtnHead = GetDlgItem( hWnd, IDC_BUTTON_HEAD );
m_hBtnUpper = GetDlgItem( hWnd, IDC_BUTTON_UPPER );
m_hBtnLower = GetDlgItem( hWnd, IDC_BUTTON_LOWER );
m_hBtnProp = GetDlgItem( hWnd, IDC_BUTTON_PROPERTY );
m_hBtnHeadX = GetDlgItem( hWnd, IDC_BUTTON_HEAD_X );
m_hBtnUpperX = GetDlgItem( hWnd, IDC_BUTTON_UPPER_X );
m_hBtnLowerX = GetDlgItem( hWnd, IDC_BUTTON_LOWER_X );
m_hBtnPropX = GetDlgItem( hWnd, IDC_BUTTON_PROPERTY_X );
m_hCheckProp = GetDlgItem( hWnd, IDC_CHECK_PROPERTY );
m_hComBoxMount = GetDlgItem( hWnd, IDC_COMBO_MOUNTTO );
SendMessage( m_hListAnim, LVM_SETEXTENDEDLISTVIEWSTYLE, 0, ( LPARAM )LVS_EX_FULLROWSELECT | LVS_EX_GRIDLINES );
// 创建动画列表的列标题
LVCOLUMN listCol;
memset( &listCol, 0, sizeof( LVCOLUMN ) );
listCol.mask = LVCF_TEXT | LVCF_WIDTH | LVCF_FMT | LVCF_SUBITEM;
listCol.fmt = LVCFMT_LEFT;
listCol.pszText = "Name";
listCol.cchTextMax = sizeof( listCol.pszText );
listCol.cx = 80;
listCol.iSubItem = 0;
SendMessage( m_hListAnim, LVM_INSERTCOLUMN, 0, ( LPARAM )&listCol );
listCol.pszText = "First Frame";
listCol.cchTextMax = sizeof( listCol.pszText );
listCol.cx = 80;
listCol.iSubItem = 0;
SendMessage( m_hListAnim, LVM_INSERTCOLUMN, 1, ( LPARAM )&listCol );
listCol.pszText = "Last Frame";
listCol.cchTextMax = sizeof( listCol.pszText );
listCol.cx = 80;
listCol.iSubItem = 0;
SendMessage( m_hListAnim, LVM_INSERTCOLUMN, 2, ( LPARAM )&listCol );
SetCheckBox( hWnd, IDC_CHECK_ANIM, FALSE );
imp->EnableAnimControls( FALSE );
if ( FALSE )//imp->GetNumObj() < 3 )
{
// 不足以导出头部、上身、下身,禁止TAG
SetCheckBox( hWnd, IDC_CHECK_TAGS, FALSE );
imp->EnableTagControls( imp->IfExportTags() );
EnableWindow( m_hCheckTag, FALSE );
}
else
{
SetCheckBox( hWnd, IDC_CHECK_TAGS, FALSE );
imp->EnableTagControls( FALSE );
string str;
str = "Upper";
SendMessage( m_hComBoxMount, CB_ADDSTRING, 0, ( LPARAM )str.c_str() );
str = "Head";
SendMessage( m_hComBoxMount, CB_ADDSTRING, 0, ( LPARAM )str.c_str() );
str = "Lower";
SendMessage( m_hComBoxMount, CB_ADDSTRING, 0, ( LPARAM )str.c_str() );
}
return TRUE;
}
case WM_COMMAND:
switch( wParam )
{
case IDC_CHECK_ANIM:
imp->EnableAnimControls( IsDlgButtonChecked( hWnd, IDC_CHECK_ANIM ) );
break;
case IDC_CHECK_TAGS:
imp->EnableTagControls( IsDlgButtonChecked( hWnd, IDC_CHECK_TAGS ) );
break;
case IDC_CHECK_PROPERTY:
imp->EnablePropControls( IsDlgButtonChecked( hWnd, IDC_CHECK_PROPERTY ) );
break;
case IDC_BUTTON_ADD: // 添加动画
{
imp->SetEditingAnim( FALSE );
if ( TRUE == imp->ShowAnimDialog() )
{
AnimRecord &newAnim = imp->GetNewAnimRecord();
int itemCount = SendMessage( m_hListAnim, LVM_GETITEMCOUNT, 0, 0 );
LVITEM listItem;
memset( &listItem, 0, sizeof( LVITEM ) );
char buffer[64];
ZeroMemory( buffer, 64 );
strcpy( buffer, newAnim.animName.c_str() );
listItem.mask = LVIF_TEXT;
listItem.cchTextMax = static_cast< int >( newAnim.animName.size() );
listItem.pszText = buffer;
listItem.iItem = itemCount;
listItem.iSubItem = 0;
SendMessage( m_hListAnim, LVM_INSERTITEM, 0, ( LPARAM )&listItem );
itoa( newAnim.firstFrame, buffer, 10 );
listItem.cchTextMax = sizeof( buffer );
listItem.pszText = buffer;
listItem.iItem = itemCount;
listItem.iSubItem = 1;
SendMessage( m_hListAnim, LVM_SETITEM, 0, ( LPARAM )&listItem );
itoa( newAnim.lastFrame, buffer, 10 );
listItem.cchTextMax = sizeof( buffer );
listItem.pszText = buffer;
listItem.iItem = itemCount;
listItem.iSubItem = 2;
SendMessage( m_hListAnim, LVM_SETITEM, 0, ( LPARAM )&listItem );
imp->SetSettedFrame( max( newAnim.lastFrame, imp->GetSettedFrame() ) );
}
break;
}
case IDC_BUTTON_EDIT: // 编辑动画
{
int nSel = -1;
nSel = SendMessage( m_hListAnim, LVM_GETSELECTIONMARK, 0, 0 );
int nSelCount = SendMessage( m_hListAnim, LVM_GETSELECTEDCOUNT, 0, 0 );
if ( nSelCount != 0 )
{
AnimRecord curAnim;
LVITEM listItem;
memset( &listItem, 0, sizeof( LVITEM ) );
char buffer[64];
ZeroMemory( buffer, 64 );
listItem.mask = LVIF_TEXT;
listItem.iItem = nSel;
listItem.cchTextMax = 64;
listItem.pszText = buffer;
listItem.iSubItem = 0;
SendMessage( m_hListAnim, LVM_GETITEM, 0, ( LPARAM )&listItem );
curAnim.animName = listItem.pszText;
listItem.iSubItem = 1;
SendMessage( m_hListAnim, LVM_GETITEM, 0, ( LPARAM )&listItem );
curAnim.firstFrame = atoi( listItem.pszText );
listItem.iSubItem = 2;
SendMessage( m_hListAnim, LVM_GETITEM, 0, ( LPARAM )&listItem );
curAnim.lastFrame = atoi( listItem.pszText );
imp->SetCurAnimRecord( curAnim.animName, curAnim.firstFrame, curAnim.lastFrame );
imp->SetEditingAnim( TRUE );
if ( TRUE == imp->ShowAnimDialog() )
{
curAnim = imp->GetCurAnimRecord();
ZeroMemory( buffer, 64 );
strcpy( buffer, curAnim.animName.c_str() );
listItem.iSubItem = 0;
listItem.pszText = buffer;
SendMessage( m_hListAnim, LVM_SETITEM, 0, ( LPARAM )&listItem );
itoa( curAnim.firstFrame, buffer, 10 );
listItem.iSubItem = 1;
listItem.pszText = buffer;
SendMessage( m_hListAnim, LVM_SETITEM, 0, ( LPARAM )&listItem );
itoa( curAnim.lastFrame, buffer, 10 );
listItem.iSubItem = 2;
listItem.pszText = buffer;
SendMessage( m_hListAnim, LVM_SETITEM, 0, ( LPARAM )&listItem );
}
}
break;
}
case IDC_BUTTON_DELETE: // 删除动画
{
int nSel = -1;
nSel = SendMessage( m_hListAnim, LVM_GETSELECTIONMARK, 0, 0 );
int nSelCount = SendMessage( m_hListAnim, LVM_GETSELECTEDCOUNT, 0, 0 );
if ( nSelCount != 0 )
{
SendMessage( m_hListAnim, LVM_DELETEITEM, nSel, 0 );
}
break;
}
case IDC_BUTTON_HEAD: // 选择头部
{
if ( TRUE == imp->ShowObjListDialog() )
{
imp->m_sHeadNode = imp->m_sGettingNode;
SetDlgItemText( hWnd, IDC_EDIT_HEAD, imp->m_sHeadNode.c_str() );
}
break;
}
case IDC_BUTTON_UPPER: // 选择上半身
{
if ( TRUE == imp->ShowObjListDialog() )
{
imp->m_sUpperNode = imp->m_sGettingNode;
SetDlgItemText( hWnd, IDC_EDIT_UPPER, imp->m_sUpperNode.c_str() );
}
break;
}
case IDC_BUTTON_LOWER: // 选择下半身
{
if ( TRUE == imp->ShowObjListDialog() )
{
imp->m_sLowerNode = imp->m_sGettingNode;
SetDlgItemText( hWnd, IDC_EDIT_LOWER, imp->m_sLowerNode.c_str() );
}
break;
}
case IDC_BUTTON_PROPERTY: // 选择道具
{
if ( TRUE == imp->ShowObjListDialog() )
{
imp->m_sPropNode = imp->m_sGettingNode;
SetDlgItemText( hWnd, IDC_EDIT_PROPERTY, imp->m_sPropNode.c_str() );
}
break;
}
case IDC_BUTTON_HEAD_X: // 取消头部的选择
{
imp->m_sHeadNode = "";
SetDlgItemText( hWnd, IDC_EDIT_HEAD, imp->m_sHeadNode.c_str() );
break;
}
case IDC_BUTTON_UPPER_X: // 取消上半身的选择
{
imp->m_sUpperNode = "";
SetDlgItemText( hWnd, IDC_EDIT_UPPER, imp->m_sUpperNode.c_str() );
break;
}
case IDC_BUTTON_LOWER_X: // 取消下半身的选择
{
imp->m_sLowerNode = "";
SetDlgItemText( hWnd, IDC_EDIT_LOWER, imp->m_sLowerNode.c_str() );
break;
}
case IDC_BUTTON_PROPERTY_X: // 取消道具的选择
{
imp->m_sPropNode = "";
SetDlgItemText( hWnd, IDC_EDIT_PROPERTY, imp->m_sPropNode.c_str() );
break;
}
case IDC_OK: // 确定
{
// 是否导出动画、TAG、道具
imp->SetExportAnim( hWnd, IsDlgButtonChecked( hWnd, IDC_CHECK_ANIM ) );
imp->SetExportTags( hWnd, IsDlgButtonChecked( hWnd, IDC_CHECK_TAGS ) );
imp->SetExportProp( hWnd, IsDlgButtonChecked( hWnd, IDC_CHECK_PROPERTY ) );
if ( imp->IfExportAnim() == TRUE )
{
// 从UI获取动画数据
int animCount = SendMessage( m_hListAnim, LVM_GETITEMCOUNT, 0, 0 );
for ( int i = 0; i < animCount; i ++ )
{
AnimRecord anim;
LVITEM listItem;
memset( &listItem, 0, sizeof( LVITEM ) );
char buffer[64];
ZeroMemory( buffer, 64 );
listItem.mask = LVIF_TEXT;
listItem.iItem = i;
listItem.cchTextMax = 64;
listItem.pszText = buffer;
listItem.iSubItem = 0;
SendMessage( m_hListAnim, LVM_GETITEM, 0, ( LPARAM )&listItem );
anim.animName = listItem.pszText;
listItem.iSubItem = 1;
SendMessage( m_hListAnim, LVM_GETITEM, 0, ( LPARAM )&listItem );
anim.firstFrame = atoi( listItem.pszText );
listItem.iSubItem = 2;
SendMessage( m_hListAnim, LVM_GETITEM, 0, ( LPARAM )&listItem );
anim.lastFrame = atoi( listItem.pszText );
imp->AddAnimRecord( anim );
}
}
if ( imp->IfExportTags() == TRUE )
{
char buf[64];
ZeroMemory( buf, 64 );
GetDlgItemText( hWnd, IDC_EDIT_HEAD, buf, 64 );
imp->m_sHeadNode = buf;
ZeroMemory( buf, 64 );
GetDlgItemText( hWnd, IDC_EDIT_UPPER, buf, 64 );
imp->m_sUpperNode = buf;
ZeroMemory( buf, 64 );
GetDlgItemText( hWnd, IDC_EDIT_LOWER, buf, 64 );
imp->m_sLowerNode = buf;
if ( imp->IfExprotProperty() )
{
ZeroMemory( buf, 64 );
GetDlgItemText( hWnd, IDC_EDIT_PROPERTY, buf, 64 );
imp->m_sPropNode = buf;
int curSel = SendMessage( m_hComBoxMount, CB_GETCURSEL, 0, 0 );
ZeroMemory( buf, 64 );
SendMessage( m_hComBoxMount, CB_GETLBTEXT, ( WPARAM )curSel, ( LPARAM )buf );
imp->m_propMountTo = buf;
}
}
EndDialog( hWnd, IDOK );
return TRUE;
}
case IDC_CANCEL: // 取消
EndDialog( hWnd, 0 );
return TRUE;
}
return TRUE;
case WM_CLOSE:
EndDialog( hWnd, 0 );
return TRUE;
}
return 0;
}
BOOL CSMOpts::ShowAnimDialog()
{
// 弹出一个模态对话框,如果返回0,则用户点击了Cancel
return 0 != DialogBoxParam( hInstance,
MAKEINTRESOURCE( IDD_DLG_ANIM ),
GetActiveWindow(),
AnimDialogProc, ( LPARAM )this );
}
INT_PTR CALLBACK CSMOpts::AnimDialogProc( HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam )
{
static CSMOpts *imp = NULL;
switch( message )
{
case WM_INITDIALOG: // 初始化动画窗口
{
imp = reinterpret_cast< CSMOpts* >( lParam );
CenterWindow( hWnd,GetParent( hWnd ) );
m_hEditAnimName = GetDlgItem( hWnd, IDC_EDIT_ANIM_NAME );
m_hEditFirstFrame = GetDlgItem( hWnd, IDC_EDIT_FFRAME );
m_hEditLastFrame = GetDlgItem( hWnd, IDC_EDIT_LFRAME );
if( imp->IsEditingAnim() == TRUE )
{
char buffer[64];
ZeroMemory( buffer, 64 );
AnimRecord &curAnim = imp->GetCurAnimRecord();
SetDlgItemText( hWnd, IDC_EDIT_ANIM_NAME, curAnim.animName.c_str() );
itoa( curAnim.firstFrame, buffer, 10 );
SetDlgItemText( hWnd, IDC_EDIT_FFRAME, buffer );
itoa( curAnim.lastFrame, buffer, 10 );
SetDlgItemText( hWnd, IDC_EDIT_LFRAME, buffer );
}
else
{
char buffer[64];
ZeroMemory( buffer, 64 );
itoa( imp->GetSettedFrame(), buffer, 10 );
SetDlgItemText( hWnd, IDC_EDIT_FFRAME, buffer );
itoa( imp->GetLastFrame(), buffer, 10 );
SetDlgItemText( hWnd, IDC_EDIT_LFRAME, buffer );
}
return TRUE;
}
case WM_COMMAND:
switch( wParam )
{
case IDC_BUTTON_FF_MINUS: // 动画首帧减一
{
char buffer[64];
ZeroMemory( buffer, 64 );
GetDlgItemText( hWnd, IDC_EDIT_FFRAME, buffer, 64 );
int frame = atoi( buffer );
if ( frame <= imp->GetFristFrame() )
{
frame = imp->GetFristFrame();
}
else
{
frame--;
}
itoa( frame, buffer, 10 );
SetDlgItemText( hWnd, IDC_EDIT_FFRAME, buffer );
break;
}
case IDC_BUTTON_FF_PLUS: // 动画首帧加一
{
char buffer[64];
ZeroMemory( buffer, 64 );
GetDlgItemText( hWnd, IDC_EDIT_FFRAME, buffer, 64 );
int frame = atoi( buffer );
ZeroMemory( buffer, 64 );
GetDlgItemText( hWnd, IDC_EDIT_LFRAME, buffer, 64 );
int curLastFrame = atoi( buffer );
if ( frame >= curLastFrame )
{
frame = curLastFrame;
}
else
{
frame++;
}
itoa( frame, buffer, 10 );
SetDlgItemText( hWnd, IDC_EDIT_FFRAME, buffer );
break;
}
case IDC_BUTTON_LF_MINUS: // 动画末帧减一
{
char buffer[64];
ZeroMemory( buffer, 64 );
GetDlgItemText( hWnd, IDC_EDIT_LFRAME, buffer, 64 );
int frame = atoi( buffer );
ZeroMemory( buffer, 64 );
GetDlgItemText( hWnd, IDC_EDIT_FFRAME, buffer, 64 );
int curFirstFrame = atoi( buffer );
if ( frame <= curFirstFrame )
{
frame = curFirstFrame;
}
else
{
frame--;
}
itoa( frame, buffer, 10 );
SetDlgItemText( hWnd, IDC_EDIT_LFRAME, buffer );
break;
}
case IDC_BUTTON_LF_PLUS: // 动画末帧加一
{
char buffer[64];
ZeroMemory( buffer, 64 );
GetDlgItemText( hWnd, IDC_EDIT_LFRAME, buffer, 64 );
int frame = atoi( buffer );
if ( frame >= imp->GetLastFrame() )
{
frame = imp->GetLastFrame();
}
else
{
frame++;
}
itoa( frame, buffer, 10 );
SetDlgItemText( hWnd, IDC_EDIT_LFRAME, buffer );
break;
}
case ID_ANIM_BTN_OK: // 确定
{
char buffer[64];
ZeroMemory( buffer, 64 );
GetDlgItemText( hWnd, IDC_EDIT_ANIM_NAME, buffer, 64 );
string animName = buffer;
ZeroMemory( buffer, 64 );
GetDlgItemText( hWnd, IDC_EDIT_FFRAME, buffer, 64 );
int firstFrame = atoi( buffer );
ZeroMemory( buffer, 64 );
GetDlgItemText( hWnd, IDC_EDIT_LFRAME, buffer, 64 );
int lastFrame = atoi( buffer );
if ( animName.size() != 0 )
{
if ( imp->IsEditingAnim() == FALSE )
{
imp->SetNewAnimRecord( animName, firstFrame, lastFrame );
}
else
{
imp->SetCurAnimRecord( animName, firstFrame, lastFrame );
}
EndDialog( hWnd, IDOK );
}
else
{
MessageBox( hWnd, "请输入动画名称", "动画名称空缺", MB_ICONERROR );
break;
}
return TRUE;
}
case ID_ANIM_BTN_CANCEL: // 取消
EndDialog( hWnd, 0 );
return TRUE;
}
return TRUE;
case WM_CLOSE:
EndDialog( hWnd, 0 );
return TRUE;
}
return 0;
}
BOOL CSMOpts::ShowObjListDialog()
{
// 弹出一个模态对话框,如果返回0,则用户点击了Cancel
return 0 != DialogBoxParam( hInstance,
MAKEINTRESOURCE( IDD_DLG_OBJLIST ),
GetActiveWindow(),
ObjListDialogProc, ( LPARAM )this );
}
INT_PTR CALLBACK CSMOpts::ObjListDialogProc( HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam )
{
static CSMOpts *imp = NULL;
switch( message )
{
case WM_INITDIALOG: // 初始化列表窗口
{
imp = reinterpret_cast< CSMOpts* >( lParam );
CenterWindow( hWnd,GetParent( hWnd ) );
m_hListObj = GetDlgItem( hWnd, IDC_LIST_OBJ );
for ( int i = 0; i < imp->GetNumObj(); i ++ )
{
string name = imp->GetObj( i );
if ( name != imp->m_sHeadNode &&
name != imp->m_sLowerNode &&
name != imp->m_sUpperNode &&
name != imp->m_sPropNode )
{
SendMessage( m_hListObj, LB_ADDSTRING, 0, ( LPARAM )name.c_str() );
}
}
return TRUE;
}
case WM_COMMAND:
switch( wParam )
{
case ID_OBJLIST_OK: // 确定
{
int curSel = SendMessage( m_hListObj, LB_GETCURSEL, 0, 0 );
char buf[64];
ZeroMemory( buf, 64 );
SendMessage( m_hListObj, LB_GETTEXT, curSel, ( LPARAM )buf );
imp->m_sGettingNode = buf;
EndDialog( hWnd, IDOK );
return TRUE;
}
case ID_OBJLIST_CANCEL: // 取消
EndDialog( hWnd, 0 );
return TRUE;
}
return TRUE;
case WM_CLOSE:
EndDialog( hWnd, 0 );
return TRUE;
}
return 0;
}
|
[
"[email protected]@4008efc8-90d6-34c1-d252-cb7169c873e6"
] |
[
[
[
1,
737
]
]
] |
129690307605c2ded55ba3eb3958952de67d987e
|
241c6a1683325fdae37f5cea2716e8e639dd09a4
|
/extension.h
|
76bc95d57f1634b136a735131bfc505a2f97e235
|
[] |
no_license
|
awstanley/rpgtools-hg-tmp
|
060bb8abe19512b282bb04ec433a0158623afaf8
|
02b50dff4d80c32f12065b18390ea71bedb130df
|
refs/heads/master
| 2020-11-24T17:43:26.561364 | 2011-07-17T21:40:02 | 2011-07-17T21:40:02 | 228,278,083 | 0 | 0 | null | null | null | null |
UTF-8
|
C++
| false | false | 6,092 |
h
|
/******************************************************************************
* vim: set ts=4 :
******************************************************************************
* RPGTools Extension
* Copyright (C) 2011 A.W. 'Swixel' Stanley.
******************************************************************************
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* As a special exception, AlliedModders LLC gives you permission to link the
* code of this program (as well as its derivative works) to "Half-Life 2," the
* "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
* by the Valve Corporation. You must obey the GNU General Public License in
* all respects for all other code used. Additionally, AlliedModders LLC grants
* this exception to all derivative works. AlliedModders LLC defines further
* exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
* or <http://www.sourcemod.net/license.php>.
*****************************************************************************/
#ifndef _INCLUDE_SOURCEMOD_EXTENSION_PROPER_H_
#define _INCLUDE_SOURCEMOD_EXTENSION_PROPER_H_
/*****************************************************************************
* Hardcoded teams
*****************************************************************************/
#define LWTEAM 2
#define OTHERTEAM 3
/*****************************************************************************
* Includes, typedefs, and namespaces
*****************************************************************************/
#include "smsdk_ext.h"
#include <sourcehook.h>
#include <sourcehook_pibuilder.h>
#include <convar.h>
#include <icvar.h>
#include <eiface.h>
#include <variant_t.h>
#include <utldict.h>
#include <game/server/iplayerinfo.h>
#include <networkvar.h>
#include <ehandle.h>
typedef CHandle<CBaseEntity> EHANDLE;
typedef CBaseEntity CEntity;
#include "tdi.h"
using namespace SourceHook;
/*****************************************************************************
* Header definitions
*****************************************************************************/
// - Hooks
bool Hook_ChangeTeam(int Team);
int Hook_GetMaxHealth();
int Hook_OnTakeDamage(CTakeDamageInfo &info);
float Hook_GetPlayerMaxSpeed();
void Hook_SetCommandClient(int iClient);
// - Use forwards from here, to stop Pawn from having to call.
void Hook_ClientPutInServer(edict_t *pEntity, char const *playername);
void Hook_ClientLeaveServer(edict_t *pEntity);
/*****************************************************************************
* Structs
*****************************************************************************/
struct RPGChar
{
float DamageStat; // Damage Bonus
float ShieldStat; // Armour Bonus
float SpeedStat; // Speed Bonus
int HealthStat; // Health Bonus
// Float:fDamageStat=0.0, Float:fShieldStat=0.0, iHealthStat=0, Float:fSpeedStat=0.0
RPGChar(float D, float A, int H, float S)
{
DamageStat = D;
HealthStat = H;
ShieldStat = A;
SpeedStat = S;
};
};
// Toys
#define HOOK_SPEED 0
#define HOOK_ONTAKEDAMAGE 1
#define HOOK_HEALTH 2
// Utils!
#define HOOK_FLASHLIGHT 3
#define HOOK_FAKEDEATH 4 // CreateRagdollEntity
class RPGTools :
public SDKExtension,
public IConCommandBaseAccessor,
public IMetamodListener
{
public: // Data
RPGChar **Slots;
bool *Hooks;
bool *FlashLight;
public: //SDK
virtual bool SDK_OnLoad(char *error, size_t maxlength, bool late);
virtual void SDK_OnUnload();
public:
#if defined SMEXT_CONF_METAMOD
virtual bool SDK_OnMetamodLoad(ISmmAPI *ismm, char *error, size_t maxlength, bool late);
void SDK_OnAllLoaded();
#endif
public: //IConCommandBaseAccessor
bool RegisterConCommandBase(ConCommandBase *pCommand);
};
extern IGameConfig *g_pGameConf;
// Now that it's defined:
extern RPGTools g_RPGTools;
bool IsPlayerValid(int iClient, CBaseEntity *&pBasePlayer);
bool Hook_LevelInit(const char *pMapName, char const *pMapEntities, char const *pOldLevel, char const *pLandmarkName, bool loadGame,bool background);
void KillAllStats();
void Hook_LevelShutdown();
void Hook_ClientLeaveServer(edict_t *pEntity);
void Hook_ClientPutInServer(edict_t *pEntity, char const *playername);
int Hook_OnTakeDamage(CTakeDamageInfo &info);
int Hook_GetMaxHealth();
void Hook_CreateRagdollEntity();
void Hook_FlashLightTurnOn();
void Hook_FlashLightTurnOff();
bool Hook_FlashLightIsOn();
void Hook_UpdateOnRemove();
float Hook_GetPlayerMaxSpeed();
// WHEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE CATFISH EYES ON A DONKEY
// -- Holy crap, people read my source code?!
void RegisterPlayer(CBaseEntity *pBasePlayer);
void UnregisterPlayer(CBaseEntity *pBasePlayer);
// Natives
static cell_t RPG_SetPlayerStat(IPluginContext *pContext, const cell_t *params);
static cell_t RPG_SetPlayerStats(IPluginContext *pContext, const cell_t *params);
static cell_t RPG_GetPlayerStats(IPluginContext *pContext, const cell_t *params);
static cell_t RPG_ToggleFlashLight(IPluginContext *pContext, const cell_t *params);
static cell_t RPG_SetFlashLight(IPluginContext *pContext, const cell_t *params);
static cell_t RPG_GetFlashLight(IPluginContext *pContext, const cell_t *params);
static cell_t RPG_FakeDeath(IPluginContext *pContext, const cell_t *params);
#endif // _INCLUDE_SOURCEMOD_EXTENSION_PROPER_H_
|
[
"[email protected]"
] |
[
[
[
1,
164
]
]
] |
175dd4532f838110bfbff6b21946d8fefd02b114
|
bfdfb7c406c318c877b7cbc43bc2dfd925185e50
|
/engine/hyValue.h
|
246df33fe351d4662a3c0be8f68781f2f7192d1f
|
[
"MIT"
] |
permissive
|
ysei/Hayat
|
74cc1e281ae6772b2a05bbeccfcf430215cb435b
|
b32ed82a1c6222ef7f4bf0fc9dedfad81280c2c0
|
refs/heads/master
| 2020-12-11T09:07:35.606061 | 2011-08-01T12:38:39 | 2011-08-01T12:38:39 | null | 0 | 0 | null | null | null | null |
SHIFT_JIS
|
C++
| false | false | 7,304 |
h
|
/*
* copyright 2010 FUKUZAWA Tadashi. All rights reserved.
*/
#ifndef m_HYVALUE_H_
#define m_HYVALUE_H_
#include "HSymbol.h"
#include "hyTuning.h"
#include "hyStack.h"
#include "hyCellList.h"
#ifdef TEST__CPPUNIT
#include <ostream>
#endif
namespace Hayat {
namespace Engine {
class Value;
class Bytecode;
class Context;
class Object;
class HClass;
typedef Stack<Value> ValueStack;
typedef CellList<Value> ValueList;
HMD_EXTERN_DECL const HClass* HC_Object; // 全クラスのスーパークラス
HMD_EXTERN_DECL const HClass* HC_NilClass;
HMD_EXTERN_DECL const HClass* HC_Int;
HMD_EXTERN_DECL const HClass* HC_Float;
HMD_EXTERN_DECL const HClass* HC_Math;
HMD_EXTERN_DECL const HClass* HC_Class;
HMD_EXTERN_DECL const HClass* HC_Bool;
HMD_EXTERN_DECL const HClass* HC_Symbol;
HMD_EXTERN_DECL const HClass* HC_String;
HMD_EXTERN_DECL const HClass* HC_Thread;
HMD_EXTERN_DECL const HClass* HC_Exception;
HMD_EXTERN_DECL const HClass* HC_Array;
HMD_EXTERN_DECL const HClass* HC_Stack;
HMD_EXTERN_DECL const HClass* HC_Hash;
HMD_EXTERN_DECL const HClass* HC_StringBuffer;
HMD_EXTERN_DECL const HClass* HC_List;
HMD_EXTERN_DECL const HClass* HC_Closure;
HMD_EXTERN_DECL const HClass* HC_Context;
HMD_EXTERN_DECL const HClass* HC_Fiber;
HMD_EXTERN_DECL const HClass* HC_Method;
// Object参照
HMD_EXTERN_DECL const HClass* HC_REF;
// 間接ローカル変数参照
HMD_EXTERN_DECL const HClass* HC_INDIRECT_REF;
// 間接ローカル変数実体
HMD_EXTERN_DECL const HClass* HC_INDIRECT_ENT;
#ifdef HY_ENABLE_RELOCATE_OBJECT
// Object移動情報
extern const HClass* HC_RELOCATED_OBJ;
#endif
class Value {
public:
const HClass* type;
union {
hyu32 data;
hyf32 floatData;
hys32 intData;
void* ptrData;
Object* objPtr;
};
public:
#if defined(HMD_DEBUG) && !defined(TEST__CPPUNIT)
#define CHECKTYPE(t) checkType(t)
#define CHECKTYPE_UNREF(t) checkType_unref(t)
void checkType(SymbolID_t classSym) const;
void checkType_unref(SymbolID_t classSym) const;
#else
#define CHECKTYPE(t) ((void)t)
#define CHECKTYPE_UNREF(t) ((void)t)
void checkType(SymbolID_t) const {};
void checkType_unref(SymbolID_t) const {};
#endif
Value(void);
Value(const Value &o) { *this = o; }
Value(const HClass* klass, hyu32 val) { type = klass; data = val; }
Value(const HClass* klass, hyf32 val) { type = klass; floatData = val; }
Value(const HClass* klass, hys32 val) { type = klass; intData = val; }
Value(const HClass* klass, void* val) { type = klass; ptrData = val; }
static Value fromBool(bool b);
static Value fromInt(hys32 i) {return Value(HC_Int, i);}
static Value fromFloat(hyf32 f) {return Value(HC_Float, f);}
static Value fromObj(Object* o);
static Value fromSymbol(SymbolID_t sym) {return Value(HC_Symbol, (hyu32)sym);}
static Value fromClass(const HClass* pClass) {return Value(HC_Class, (void*)pClass);}
static Value fromString(const char* str) {return Value(HC_String, (void*)str);}
static Value fromList(ValueList* list) {return Value(HC_List, (void*)list);}
const HClass* getType(void) const;
bool toBool(void) const {CHECKTYPE(HSym_Bool); return (data != 0);}
hys32 toInt(void) const {CHECKTYPE(HSym_Int); return intData;}
hyf32 toFloat(void) const;
SymbolID_t toSymbol(void) const {CHECKTYPE(HSym_Symbol); return (SymbolID_t)data;}
Object* toObj(void) const {HMD_DEBUG_ASSERT(type == HC_REF); return objPtr;}
template <typename T> T* toCppObj(void) { return (T*) m_toCppObj(); }
template <typename T> T* toCppObj(SymbolID_t classSym) {CHECKTYPE_UNREF(classSym); return (T*) m_toCppObj();}
template <typename T> T* ptrCast(void) { return (T*) ptrData; }
template <typename T> T* ptrCast(SymbolID_t classSym) {CHECKTYPE(classSym); return (T*) ptrData;}
// オブジェクトのtypeをテストする
#ifdef HMD_DEBUG
Object* toObj(SymbolID_t sym) const;
#else
Object* toObj(SymbolID_t) const { return objPtr;}
#endif
const HClass* toClass(void) const {CHECKTYPE(HSym_Class); return (const HClass*)ptrData;}
const char* toString(void) const;
ValueList* toList(void) const {CHECKTYPE(HSym_List); return (ValueList*)ptrData;}
// ハッシュコードを計算
hyu32 hashCode(Context* context);
// 等しいかどうか
bool equals(Context* context, const Value& o) const;
static void initStdlib(Bytecode& bytecode);
static void destroyStdlib(void); // for unittest
const hyu8* getTypeName(void) const;
SymbolID_t getTypeSymbol(void) const;
// クラスならそのクラスを返す
// そうでなければインスタンスのクラスを返す
const HClass* getScope(void) const;
friend bool operator==(const Value& d1, const Value& d2) {
return (d1.type == d2.type) && (d1.data == d2.data);
}
#ifdef TEST__CPPUNIT
friend std::ostream& operator<<(std::ostream& out, const Value& d) {
out << (d.data ? "true" : "false") << ":<Bool>";
return out;
}
#endif
protected:
void* m_toCppObj(void);
static void m_setConstValues(void);
};
HMD_EXTERN_DECL const Value NIL_VALUE; // nil
HMD_EXTERN_DECL const Value TRUE_VALUE; // true
HMD_EXTERN_DECL const Value FALSE_VALUE; // false
HMD_EXTERN_DECL const Value INT_0_VALUE; // 0 :<Int>
HMD_EXTERN_DECL const Value INT_1_VALUE; // 1 :<Int>
HMD_EXTERN_DECL const Value INT_M1_VALUE; // -1 :<Int>
HMD_EXTERN_DECL const Value EMPTY_LIST_VALUE; // '()
inline Value::Value(void) {
*this = NIL_VALUE;
}
inline Value Value::fromObj(Object* o) {
if (o == NULL) return NIL_VALUE;
return Value(HC_REF, (void*)o);
}
inline Value Value::fromBool(bool b) {
return b ? TRUE_VALUE : FALSE_VALUE;
}
}
}
namespace Hayat {
namespace Common {
template<> void* Stack<Hayat::Engine::Value>::operator new(size_t);
template<> void Stack<Hayat::Engine::Value>::operator delete(void*);
template<> hyu32 Stack<Hayat::Engine::Value>::getExpandCapacity(void);
}
}
#endif /* m_HYVALUE_H_ */
|
[
"[email protected]"
] |
[
[
[
1,
194
]
]
] |
8b20d25f9bbe005ac91e1371a537307ff6e9d5bd
|
c7a66fcf27ae7c2dc41dc557b5c8eee4dd81d9d2
|
/trunk/tabsrmm/m_popup.h
|
28f730262482ae2a2c8016c08790935bbfe85dab
|
[] |
no_license
|
BackupTheBerlios/mimplugins-svn
|
1c142eb7186055dfa8deb747529fb99d5fbf201b
|
18dd487e64a0c3f9d4595ea43e64bc5c80aa765d
|
refs/heads/master
| 2021-01-04T14:06:28.579672 | 2008-01-13T00:12:59 | 2008-01-13T00:12:59 | 40,820,556 | 0 | 0 | null | null | null | null |
UTF-8
|
C++
| false | false | 13,939 |
h
|
/*
===============================================================================
PopUp plugin
Plugin Name: PopUp
Plugin authors: Luca Santarelli aka hrk ([email protected])
Victor Pavlychko aka zazoo ([email protected])
===============================================================================
The purpose of this plugin is to give developers a common "platform/interface"
to show PopUps. It is born from the source code of NewStatusNotify, another
plugin I've made.
Remember that users *must* have this plugin enabled, or they won't get any
popup. Write this in the requirements, do whatever you wish ;-)... but tell
them!
===============================================================================
*/
#ifndef M_POPUP_H
#define M_POPUP_H
/*
NOTE! Since Popup 1.0.1.2 there is a main meun group called "PopUps" where I
have put a "Enable/Disable" item. You can add your own "enable/disable" items
by adding these lines before you call MS_CLIST_ADDMAINMENUITEM:
mi.pszPopUpName = Translate("PopUps");
mi.position = 0; //You don't need it and it's better if you put it to zero.
*/
//#define MAX_CONTACTNAME 32
//#define MAX_SECONDLINE 40
#define MAX_CONTACTNAME 2048
#define MAX_SECONDLINE 2048
#define POPUP_USE_SKINNED_BG 0xffffffff
//This is the basic data you'll need to fill and pass to the service function.
typedef struct {
HANDLE lchContact; //Handle to the contact, can be NULL (main contact).
HICON lchIcon; //Handle to a icon to be shown. Cannot be NULL.
char lpzContactName[MAX_CONTACTNAME]; //This is the contact name or the first line in the plugin. Cannot be NULL.
char lpzText[MAX_SECONDLINE]; //This is the second line text. Users can choose to hide it. Cannot be NULL.
COLORREF colorBack; //COLORREF to be used for the background. Can be NULL, default will be used.
COLORREF colorText; //COLORREF to be used for the text. Can be NULL, default will be used.
WNDPROC PluginWindowProc; //Read below. Can be NULL; default will be used.
void * PluginData; //Read below. Can be NULL.
} POPUPDATA, * LPPOPUPDATA;
typedef struct {
HANDLE lchContact;
HICON lchIcon;
char lpzContactName[MAX_CONTACTNAME];
char lpzText[MAX_SECONDLINE];
COLORREF colorBack; //Set background to POPUP_USE_SKINNED_BG to turn on skinning
COLORREF colorText;
WNDPROC PluginWindowProc;
void * PluginData;
int iSeconds; //Custom delay time in seconds. -1 means "forever", 0 means "default time".
// char cZero[16];
LPCTSTR lpzClass; //PopUp class. Used with skinning. See PopUp/AddClass for details
COLORREF skinBack; //Background color for colorizable skins
char cZero[16 - sizeof(LPCTSTR) - sizeof(COLORREF)];
//some unused bytes which may come useful in the future.
} POPUPDATAEX, *LPPOPUPDATAEX;
/*
When you call MS_POPUP_ADDPOPUP, my plugin will check if the given POPUPDATA structure is filled with acceptable values. If not, the data will be rejected and no popup will be shown.
- lpzText should be given, because it's really bad if a user chooses to have the second line displayed
and it's empty :-) Just write it and let the user choose if it will be displayed or not.
- PluginWindowProc is a WNDPROC address you have to give me. Why? What? Where? Calm down 8)
My plugin will take care of the creation of the popup, of the destruction of the popup, of the come into
view and the hiding of the popup. Transparency, animations... all this stuff.
My plugin will not (as example) open the MessageWindow when you left click on a popup.
Why? Because I don't know if your popup desires to open the MessageWindow :))))
This means that you need to make a WNDPROC which takes care of the WM_messages you need.
For example, WM_COMMAND or WM_CONTEXTMENU or WM_LMOUSEUP or whatever.
At the end of your WNDPROC remember to "return DefWindowProc(hwnd, msg, wParam, lParam);"
When you process a message that needs a return value (an example could be WM_CTLCOLORSTATIC,
but you don't need to catch it 'cause it's my plugin's job), simply return the nedeed value. :)
The default WNDPROC does nothing.
- PluginData is a pointer to a void, which means a pointer to anything. You can make your own structure
to store the data you need (example: a status information, a date, your name, whatever) and give me a
pointer to that struct.
You will need to destroy that structure and free the memory when the PopUp is going to be destroyed. You'll know this when you receive a UM_FREEPLUGINDATA. The name tells it all: free your own plugin data.
Appendix A: Messages my plugin will handle and your WNDPROC will never see.
WM_CREATE, WM_DESTROY, WM_TIMER, WM_ERASEBKGND
WM_CTLCOLOR* [whatever it may be: WM_CTLCOLORDLG, WM_CTLCOLORSTATIC...]
WM_PAINT, WM_PRINT, WM_PRINTCLIENT
Appendix B: "What do I need to do?!?".
Here is an example in C.
//Your plugin is in /plugins/myPlugin/ or in miranda32/something/
#include "../../plugins/PopUp/m_popup.h"
Define your own plugin data if you need it. In this example, we need it and we'll use NewStatusNotify as example: thsi plugin shows a popup when someone in your contact list changes his/hers status. We'll need to know his status, both current and old one.
typedef struct {
WORD oldStatus;
WORD newStatus;
} MY_PLUGIN_DATA;
When we need to show the popup, we do:
{
POPUPDATA ppd;
hContact = A_VALID_HANDLE_YOU_GOT_FROM_SOMEWHERE;
hIcon = A_VALID_HANDLE_YOU_GOT_SOMEWHERE;
char * lpzContactName = (char*)CallService(MS_CLIST_GETCONTACTDISPLAYNAME,(WPARAM)lhContact,0);
//99% of the times you'll just copy this line.
//1% of the times you may wish to change the contact's name. I don't know why you should, but you can.
char * lpzText;
//The text for the second line. You could even make something like: char lpzText[128]; lstrcpy(lpzText, "Hello world!"); It's your choice.
COLORREF colorBack = GetSysColor(COLOR_BTNFACE); //The colour of Miranda's option Pages (and many other windows...)
COLORREF colorText = RGB(255,255,255); //White.
MY_PLUGIN_DATA * mpd = (MY_PLUGIN_DATA*)malloc(sizeof(MY_PLUGIN_DATA));
ZeroMemory(ppd, sizeof(ppd)); //This is always a good thing to do.
ppd.lchContact = (HANDLE)hContact; //Be sure to use a GOOD handle, since this will not be checked.
ppd.lchIcon = hIcon;
lstrcpy(ppd.lpzContactName, lpzContactName);
lstrcpy(ppd.lpzText, lpzText);
ppd.colorBack = colorBack;
ppd.colorText = colorText;
ppd.PluginWindowProc = (WNDPROC)PopupDlgProc;
//Now the "additional" data.
mpd->oldStatus = ID_STATUS_OFFLINE;
mpd->newStatus = ID_STATUS_ONLINE;
//Now that the plugin data has been filled, we add it to the PopUpData.
ppd.PluginData = mpd;
//Now that every field has been filled, we want to see the popup.
CallService(MS_POPUP_ADDPOPUP, (WPARAM)&ppd, 0);
}
Obviously, you have previously declared some:
static int CALLBACK PopupDlgProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
switch(message) {
case WM_COMMAND:
if ((HIWORD)wParam == STN_CLICKED) { //It was a click on the Popup.
PUDeletePopUp(hWnd);
return TRUE;
}
break;
case UM_FREEPLUGINDATA: {
MY_PLUGIN_DATA * mpd = NULL;
mpd = (MY_PLUGIN_DATA*)CallService(MS_POPUP_GETPLUGINDATA, (WPARAM)hWnd,(LPARAM)mpd);
if (mdp > 0) free(mpd);
return TRUE; //TRUE or FALSE is the same, it gets ignored.
}
default:
break;
}
return DefWindowProc(hWnd, message, wParam, lParam);
}
*/
/*
Creates, adds and shows a popup, given a (valid) POPUPDATA structure pointer.
wParam = (WPARAM)(*POPUPDATA)PopUpDataAddress
lParam = 0
Returns: > 0 on success, 0 if creation went bad, -1 if the PopUpData contained unacceptable values.
NOTE: it returns -1 if the PopUpData was not valid, if there were already too many popups, if the module was disabled.
Otherwise, it can return anything else...
*/
#define MS_POPUP_ADDPOPUP "PopUp/AddPopUp"
static int __inline PUAddPopUp(POPUPDATA* ppdp) {
return CallService(MS_POPUP_ADDPOPUP, (WPARAM)ppdp,0);
}
#define MS_POPUP_ADDPOPUPEX "PopUp/AddPopUpEx"
static int __inline PUAddPopUpEx(POPUPDATAEX* ppdp) {
return CallService(MS_POPUP_ADDPOPUPEX, (WPARAM)ppdp,0);
}
/*
Returns the handle to the contact associated to the specified PopUpWindow.
You will probably need to know this handle inside your WNDPROC. Exampole: you want to open the MessageWindow. :-)
Call MS_POPUP_GETCONTACT on the hWnd you were given in the WNDPROC.
wParam = (WPARAM)(HWND)hPopUpWindow
lParam = 0;
Returns: the HANDLE of the contact. Can return NULL, meaning it's the main contact. -1 means failure.
*/
#define MS_POPUP_GETCONTACT "PopUp/GetContact"
static HANDLE __inline PUGetContact(HWND hPopUpWindow) {
return (HANDLE)CallService(MS_POPUP_GETCONTACT, (WPARAM)hPopUpWindow,0);
}
/*
wParam = (WPARAM)(HWND)hPopUpWindow
lParam = (LPARAM)(PLUGINDATA*)PluginDataAddress;
Returns: the address of the PLUGINDATA structure. Can return NULL, meaning nothing was given. -1 means failure.
IMPORTANT NOTE: it doesn't seem to work if you do:
CallService(..., (LPARAM)aPointerToAStruct);
and then use that struct.
Do this, instead:
aPointerToStruct = CallService(..., (LPARAM)aPointerToAStruct);
and it will work. Just look at the example I've written above (PopUpDlgProc).
*/
#define MS_POPUP_GETPLUGINDATA "PopUp/GetPluginData"
static void __inline * PUGetPluginData(HWND hPopUpWindow) {
long * uselessPointer = NULL;
return (void*)CallService(MS_POPUP_GETPLUGINDATA,(WPARAM)hPopUpWindow,(LPARAM)uselessPointer);
}
/*
wParam = 0
lParam = 0
Returns: 0 if the user has chosen not to have the second line, 1 if he choose to have the second line.
*/
#define MS_POPUP_ISSECONDLINESHOWN "PopUp/IsSecondLineShown"
static BOOL __inline PUIsSecondLineShown() {
return (BOOL)CallService(MS_POPUP_ISSECONDLINESHOWN,0,0);
}
/*
Requests an action or an answer from PopUp module.
wParam = (WPARAM)wpQuery
returns 0 on success, -1 on error, 1 on stupid calls ;-)
*/
#define PUQS_ENABLEPOPUPS 1 //returns 0 if state was changed, 1 if state wasn't changed
#define PUQS_DISABLEPOPUPS 2 // " "
#define PUQS_GETSTATUS 3 //Returns 1 (TRUE) if popups are enabled, 0 (FALSE) if popups are disabled.
#define MS_POPUP_QUERY "PopUp/Query"
/*
UM_FREEPLUGINDATA
wParam = lParam = 0. Process this message if you have allocated your own memory. (i.e.: POPUPDATA.PluginData != NULL)
*/
#define UM_FREEPLUGINDATA (WM_USER + 0x0200)
/*
UM_DESTROYPOPUP
wParam = lParam = 0. Send this message when you want to destroy the popup, or use the function below.
*/
#define UM_DESTROYPOPUP (WM_USER + 0x0201)
static int __inline PUDeletePopUp(HWND hWndPopUp) {
return (int)SendMessage(hWndPopUp, UM_DESTROYPOPUP,0,0);
}
/*
UM_INITPOPUP
wParam = (WPARAM)(HWND)hPopUpWindow (but this is useless, since I'll directly send it to your hPopUpWindow
lParam = 0.
This message is sent to the PopUp when its creation has been finished, so POPUPDATA (and thus your PluginData) is reachable.
Catch it if you needed to catch WM_CREATE or WM_INITDIALOG, which you'll never ever get in your entire popup-life.
Return value: if you process this message, return 0. If you don't process it, return 0. Do whatever you like ;-)
*/
#define UM_INITPOPUP (WM_USER + 0x0202)
/*
wParam = (WPARAM)(HWND)hPopUpWindow
lParam = (LPARAM)(char*)lpzNewText
returns: > 0 for success, -1 for failure, 0 if the failure is due to second line not being shown. (but you could call PUIsSecondLineShown() before changing the text...)
Changes the text displayed in the second line of the popup.
*/
#define MS_POPUP_CHANGETEXT "PopUp/Changetext"
static int __inline PUChangeText(HWND hWndPopUp, LPCTSTR lpzNewText) {
return (int)CallService(MS_POPUP_CHANGETEXT, (WPARAM)hWndPopUp, (LPARAM)lpzNewText);
}
/*
This is mainly for developers.
Shows a warning message in a PopUp. It's useful if you need a "MessageBox" like function, but you don't want a modal window (which will interfere with a DialogProcedure. MessageBox steals focus and control, this one not.
wParam = (char*) lpzMessage
lParam = 0;
Returns: 0 if the popup was shown, -1 in case of failure.
*/
#define SM_WARNING 0x01 //Triangle icon.
#define SM_NOTIFY 0x02 //Exclamation mark icon.
#define MS_POPUP_SHOWMESSAGE "PopUp/ShowMessage"
static int __inline PUShowMessage(char* lpzText, BYTE kind) {
return (int)CallService(MS_POPUP_SHOWMESSAGE, (WPARAM)lpzText,(LPARAM)kind);
}
/*
Each skinned popup (e.g. with colorBack == POPUP_USE_SKINNED_BG) should have
class set. Then you can choose separate skin for each class (for example, you
can create separate class for your plugin and use it for all ypu popups. User
would became able to choose skin for your popups independently from others)
You have to register popup class before using it. To do so call "PopUp/AddClass"
with lParam = (LPARAM)(const char *)popUpClassName.
All class names are translated (via Translate()) before being added to list. You
should use english names for them.
There are three predefined classes and one for backward compatability.
Note that you can add clases after popup wal loaded, e.g. you shoul intercept
ME_SYSTEM_MODULESLOADED event
*/
#define MS_POPUP_ADDCLASS "PopUp/AddClass"
#define POPUP_CLASS_DEFAULT "Default"
#define POPUP_CLASS_WARNING "Warning"
#define POPUP_CLASS_NOTIFY "Notify"
#define POPUP_CLASS_OLDAPI "PopUp 1.0.1.x compatability" // for internal purposes
static void __inline PUAddClass(const char *lpzClass){
CallService(MS_POPUP_ADDCLASS, 0, (LPARAM)lpzClass);
}
#endif
|
[
"silvercircle@9e22c628-c204-0410-9d24-ab429885713d"
] |
[
[
[
1,
308
]
]
] |
896849f11bc743cb22a1736fa87bc79e4f431eef
|
7707c79fe6a5b216a62bb175133249663a0fa12b
|
/trunk/DlgPartlist.cpp
|
3a422e48062856d848af0d65ffd29eaeb740cd8b
|
[] |
no_license
|
BackupTheBerlios/freepcb-svn
|
51be4b266e80f336045e2242b3388928c0b731f1
|
0ae28845832421c80bbdb10eae514a6e13d01034
|
refs/heads/master
| 2021-01-20T12:42:11.484059 | 2010-06-03T04:43:44 | 2010-06-03T04:43:44 | 40,441,767 | 0 | 0 | null | null | null | null |
UTF-8
|
C++
| false | false | 10,976 |
cpp
|
// DlgPartlist.cpp : implementation file
//
#include "stdafx.h"
#include "FreePcb.h"
#include "DlgPartlist.h"
#include "DlgAddPart.h"
//global partlist_info so that sorting callbacks will work
partlist_info pl;
// columns for list
enum {
COL_VIS = 0,
COL_NAME,
COL_PACKAGE,
COL_FOOTPRINT,
COL_VALUE
};
// sort types
enum {
SORT_UP_NAME = 0,
SORT_DOWN_NAME,
SORT_UP_PACKAGE,
SORT_DOWN_PACKAGE,
SORT_UP_FOOTPRINT,
SORT_DOWN_FOOTPRINT,
SORT_UP_VALUE,
SORT_DOWN_VALUE
};
// global callback function for sorting
// lp1, lp2 are indexes to global arrays above
//
int CALLBACK ComparePartlist( LPARAM lp1, LPARAM lp2, LPARAM type )
{
int ret = 0;
switch( type )
{
case SORT_UP_NAME:
case SORT_DOWN_NAME:
ret = (strcmp( ::pl[lp1].ref_des, ::pl[lp2].ref_des ));
break;
case SORT_UP_PACKAGE:
case SORT_DOWN_PACKAGE:
ret = (strcmp( ::pl[lp1].package, ::pl[lp2].package ));
break;
case SORT_UP_FOOTPRINT:
case SORT_DOWN_FOOTPRINT:
if( ::pl[lp1].shape && ::pl[lp2].shape )
ret = (strcmp( ::pl[lp1].shape->m_name, ::pl[lp2].shape->m_name ));
else
ret = 0;
break;
case SORT_UP_VALUE:
case SORT_DOWN_VALUE:
ret = (strcmp( ::pl[lp1].value, ::pl[lp2].value ));
break;
}
switch( type )
{
case SORT_DOWN_NAME:
case SORT_DOWN_PACKAGE:
case SORT_DOWN_FOOTPRINT:
case SORT_DOWN_VALUE:
ret = -ret;
break;
}
return ret;
}
// CDlgPartlist dialog
IMPLEMENT_DYNAMIC(CDlgPartlist, CDialog)
CDlgPartlist::CDlgPartlist(CWnd* pParent /*=NULL*/)
: CDialog(CDlgPartlist::IDD, pParent)
{
}
CDlgPartlist::~CDlgPartlist()
{
}
void CDlgPartlist::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
DDX_Control(pDX, IDC_LIST1, m_list_ctrl);
DDX_Control(pDX, IDC_BUTTON_ADD, m_button_add);
DDX_Control(pDX, IDC_BUTTON_EDIT, m_button_edit);
DDX_Control(pDX, IDC_BUTTON_DELETE, m_button_delete);
if( pDX->m_bSaveAndValidate )
{
// leaving, get value_vis checkbox states
for (int iItem=0; iItem<m_list_ctrl.GetItemCount(); iItem++ )
{
int ip = m_list_ctrl.GetItemData( iItem );
BOOL iTest = ListView_GetCheckState( m_list_ctrl, iItem );
::pl[ip].value_vis = ListView_GetCheckState( m_list_ctrl, iItem );
}
m_plist->ImportPartListInfo( &::pl, 0 );
}
DDX_Control(pDX, IDC_CHECK1, m_check_footprint);
DDX_Control(pDX, IDC_CHECK2, m_check_package);
DDX_Control(pDX, IDC_CHECK3, m_check_value);
}
BEGIN_MESSAGE_MAP(CDlgPartlist, CDialog)
ON_BN_CLICKED(IDC_BUTTON_ADD, OnBnClickedButtonAdd)
ON_BN_CLICKED(IDC_BUTTON_EDIT, OnBnClickedButtonEdit)
ON_BN_CLICKED(IDC_BUTTON_DELETE, OnBnClickedButtonDelete)
ON_NOTIFY(LVN_COLUMNCLICK, IDC_LIST1, OnLvnColumnClickList1)
ON_BN_CLICKED(IDC_BUTTON_VAL_VIS, OnBnClickedValueVisible)
ON_BN_CLICKED(IDC_BUTTON_VAL_INVIS, OnBnClickedValueInvisible)
ON_NOTIFY(NM_CLICK, IDC_LIST1, OnNMClickList1)
END_MESSAGE_MAP()
BOOL CDlgPartlist::OnInitDialog()
{
CDialog::OnInitDialog();
m_plist->ExportPartListInfo( &::pl, NULL );
m_sort_type = SORT_UP_NAME;
DrawListCtrl();
m_check_footprint.EnableWindow(0);
m_check_package.EnableWindow(0);
m_check_value.EnableWindow(0);
return TRUE;
}
void CDlgPartlist::DrawListCtrl()
{
// now set up listview control
int nItem;
LVITEM lvitem;
CString str;
DWORD old_style = m_list_ctrl.GetExtendedStyle();
m_list_ctrl.SetExtendedStyle( LVS_EX_FULLROWSELECT | LVS_EX_FLATSB | LVS_EX_CHECKBOXES | old_style );
m_list_ctrl.DeleteAllItems();
m_list_ctrl.InsertColumn( COL_VIS, "Value Vis", LVCFMT_LEFT, 60 );
m_list_ctrl.InsertColumn( COL_NAME, "Reference", LVCFMT_LEFT, 70 );
m_list_ctrl.InsertColumn( COL_PACKAGE, "Package", LVCFMT_LEFT, 150 );
m_list_ctrl.InsertColumn( COL_FOOTPRINT, "Footprint", LVCFMT_LEFT, 150 );
m_list_ctrl.InsertColumn( COL_VALUE, "Value", LVCFMT_LEFT, 200 );
for( int i=0; i<::pl.GetSize(); i++ )
{
lvitem.mask = LVIF_TEXT | LVIF_PARAM;
lvitem.pszText = "";
lvitem.lParam = i;
nItem = m_list_ctrl.InsertItem( i, "" );
m_list_ctrl.SetItemData( i, (LPARAM)i );
ListView_SetCheckState( m_list_ctrl, nItem, ::pl[i].value_vis );
m_list_ctrl.SetItem( i, COL_NAME, LVIF_TEXT, ::pl[i].ref_des, 0, 0, 0, 0 );
m_list_ctrl.SetItem( i, COL_PACKAGE, LVIF_TEXT, ::pl[i].package, 0, 0, 0, 0 );
if( ::pl[i].shape )
m_list_ctrl.SetItem( i, COL_FOOTPRINT, LVIF_TEXT, ::pl[i].shape->m_name, 0, 0, 0, 0 );
else
m_list_ctrl.SetItem( i, COL_FOOTPRINT, LVIF_TEXT, "", 0, 0, 0, 0 );
m_list_ctrl.SetItem( i, COL_VALUE, LVIF_TEXT, ::pl[i].value, 0, 0, 0, 0 );
}
m_list_ctrl.SortItems( ::ComparePartlist, m_sort_type ); // resort
RestoreSelections();
}
void CDlgPartlist::Initialize( CPartList * plist,
CMapStringToPtr * shape_cache_map,
CFootLibFolderMap * footlibfoldermap,
int units, CDlgLog * log )
{
m_units = units;
m_plist = plist;
m_footprint_cache_map = shape_cache_map;
m_footlibfoldermap = footlibfoldermap;
m_sort_type = SORT_UP_NAME;
m_dlg_log = log;
}
// CDlgPartlist message handlers
void CDlgPartlist::OnBnClickedButtonEdit()
{
SaveSelections();
// save value_vis checkbox states
for (int Item=0; Item<m_list_ctrl.GetItemCount(); Item++ )
{
int ip = m_list_ctrl.GetItemData( Item );
::pl[ip].value_vis = ListView_GetCheckState( m_list_ctrl, Item );
}
// edit selected part(s)
int n_sel = m_list_ctrl.GetSelectedCount();
if( n_sel == 0 )
AfxMessageBox( "You have no part selected" );
BOOL bMultiple = FALSE;
if( n_sel > 1 )
bMultiple = TRUE;
POSITION pos = m_list_ctrl.GetFirstSelectedItemPosition();
if (pos == NULL)
ASSERT(0);
int iItem = m_list_ctrl.GetNextSelectedItem(pos);
int i = m_list_ctrl.GetItemData( iItem );
CDlgAddPart dlg;
int multiple_mask = MSK_FOOTPRINT * m_check_footprint.GetCheck()
+ MSK_PACKAGE * m_check_package.GetCheck()
+ MSK_VALUE * m_check_value.GetCheck();
if( bMultiple && multiple_mask == 0 )
{
AfxMessageBox( "To edit multiple parts, please select Footprint, Package or Value" );
return;
}
dlg.Initialize( &::pl, i, FALSE, FALSE, bMultiple, multiple_mask,
m_footprint_cache_map, m_footlibfoldermap, m_units, m_dlg_log );
int ret = dlg.DoModal();
if( ret == IDOK )
{
CString str;
if( bMultiple )
{
// update all selected parts with new package and footprint
POSITION pos = m_list_ctrl.GetFirstSelectedItemPosition();
while( pos )
{
int iItem = m_list_ctrl.GetNextSelectedItem(pos);
int ip = m_list_ctrl.GetItemData( iItem );
if( ip != i )
{
if( multiple_mask & MSK_FOOTPRINT )
{
::pl[ip].shape = ::pl[i].shape;
::pl[ip].ref_size = ::pl[i].ref_size;
::pl[ip].ref_width = ::pl[i].ref_width;
}
if( multiple_mask & MSK_PACKAGE )
::pl[ip].package = ::pl[i].package;
if( multiple_mask & MSK_VALUE )
::pl[ip].value = ::pl[i].value;
}
}
}
DrawListCtrl();
}
}
void CDlgPartlist::OnBnClickedButtonAdd()
{
SaveSelections();
// save value_vis checkbox states
for (int Item=0; Item<m_list_ctrl.GetItemCount(); Item++ )
{
int ip = m_list_ctrl.GetItemData( Item );
::pl[ip].value_vis = ListView_GetCheckState( m_list_ctrl, Item );
}
// now add part
CDlgAddPart dlg;
dlg.Initialize( &::pl, -1, FALSE, TRUE, FALSE, 0,
m_footprint_cache_map, m_footlibfoldermap, m_units, m_dlg_log );
int ret = dlg.DoModal();
if( ret == IDOK )
{
DrawListCtrl();
}
}
void CDlgPartlist::OnBnClickedButtonDelete()
{
int n_sel = m_list_ctrl.GetSelectedCount();
if( n_sel == 0 )
AfxMessageBox( "You have no part selected" );
else
{
while( m_list_ctrl.GetSelectedCount() )
{
POSITION pos = m_list_ctrl.GetFirstSelectedItemPosition();
if (pos == NULL)
ASSERT(0);
int iItem = m_list_ctrl.GetNextSelectedItem(pos);
int ip = m_list_ctrl.GetItemData( iItem );
::pl[ip].deleted = TRUE;
m_list_ctrl.DeleteItem( iItem );
}
}
}
// set m_sort_type based on column clicked and last sort,
// then sort the list, then save m_last_sort_type = m_sort_type
//
void CDlgPartlist::OnLvnColumnClickList1(NMHDR *pNMHDR, LRESULT *pResult)
{
LPNMLISTVIEW pNMLV = reinterpret_cast<LPNMLISTVIEW>(pNMHDR);
int column = pNMLV->iSubItem;
if( column == COL_NAME )
{
if( m_sort_type == SORT_UP_NAME )
m_sort_type = SORT_DOWN_NAME;
else
m_sort_type = SORT_UP_NAME;
m_list_ctrl.SortItems( ::ComparePartlist, m_sort_type );
}
else if( column == COL_PACKAGE )
{
if( m_sort_type == SORT_UP_PACKAGE )
m_sort_type = SORT_DOWN_PACKAGE;
else
m_sort_type = SORT_UP_PACKAGE;
m_list_ctrl.SortItems( ::ComparePartlist, m_sort_type );
}
else if( column == COL_FOOTPRINT )
{
if( m_sort_type == SORT_UP_FOOTPRINT )
m_sort_type = SORT_DOWN_FOOTPRINT;
else
m_sort_type = SORT_UP_FOOTPRINT;
m_list_ctrl.SortItems( ::ComparePartlist, m_sort_type );
}
else if( column == COL_VALUE )
{
if( m_sort_type == SORT_UP_VALUE )
m_sort_type = SORT_DOWN_VALUE;
else
m_sort_type = SORT_UP_VALUE;
m_list_ctrl.SortItems( ::ComparePartlist, m_sort_type );
}
*pResult = 0;
}
void CDlgPartlist::OnBnClickedValueVisible()
{
SaveSelections();
POSITION pos = m_list_ctrl.GetFirstSelectedItemPosition();
while( pos )
{
int iItem = m_list_ctrl.GetNextSelectedItem(pos);
int ip = m_list_ctrl.GetItemData( iItem );
::pl[ip].value_vis = TRUE;
}
DrawListCtrl();
RestoreSelections();
}
void CDlgPartlist::OnBnClickedValueInvisible()
{
SaveSelections();
POSITION pos = m_list_ctrl.GetFirstSelectedItemPosition();
while( pos )
{
int iItem = m_list_ctrl.GetNextSelectedItem(pos);
int ip = m_list_ctrl.GetItemData( iItem );
::pl[ip].value_vis = FALSE;
}
DrawListCtrl();
}
void CDlgPartlist::OnNMClickList1(NMHDR *pNMHDR, LRESULT *pResult)
{
static int last_n_sel = 0;
int n_sel = m_list_ctrl.GetSelectedCount();
if( n_sel != last_n_sel )
{
m_check_footprint.EnableWindow( n_sel > 1 );
m_check_package.EnableWindow( n_sel > 1 );
m_check_value.EnableWindow( n_sel > 1 );
}
last_n_sel = n_sel;
*pResult = 0;
}
void CDlgPartlist::SaveSelections()
{
int nItems = m_list_ctrl.GetItemCount();
bSelected.SetSize( ::pl.GetSize() );
for( int iItem=0; iItem<nItems; iItem++ )
{
int ip = m_list_ctrl.GetItemData( iItem );
if( m_list_ctrl.GetItemState( iItem, LVIS_SELECTED ) == LVIS_SELECTED )
bSelected[ip] = TRUE;
else
bSelected[ip] = FALSE;
}
}
void CDlgPartlist::RestoreSelections()
{
int nItems = m_list_ctrl.GetItemCount();
for( int iItem=0; iItem<nItems; iItem++ )
{
int ip = m_list_ctrl.GetItemData( iItem );
if( ip < bSelected.GetSize() )
if( bSelected[ip] == TRUE )
m_list_ctrl.SetItemState( iItem, LVIS_SELECTED, LVIS_SELECTED );
}
bSelected.SetSize(0);
}
|
[
"allanwright@21cd2c34-3bff-0310-83e0-c30e317e0b48"
] |
[
[
[
1,
399
]
]
] |
7bae2c5b5aed5350da0615b4d5591347311c8002
|
6ad58793dd1f859c10d18356c731b54f935c5e9e
|
/MYUltilityClass/PSP_AscCnFont.h
|
d952a0f4b10cf3802d711e995ae1a0408f94e553
|
[] |
no_license
|
ntchris/kittybookportable
|
83f2cf2fbc2cd1243b585f85fb6bc5dd285aa227
|
933a5b096524c24390c32c654ce8624ee35d3835
|
refs/heads/master
| 2021-01-10T05:49:32.035999 | 2009-06-12T08:50:21 | 2009-06-12T08:50:21 | 45,051,534 | 0 | 0 | null | null | null | null |
UTF-8
|
C++
| false | false | 3,988 |
h
|
#ifndef __PSP_ASCFONTS__
#define __PSP_ASCFONTS__
#include <PSP_Global.h>
using namespace PSP_Constants;
struct Dot_Font_Data
{
//dot , pixel
unsigned short width;
//dot , pixel
unsigned short heigh;
const unsigned char * fontData;
unsigned short sizeByte;
unsigned short dotsPerByte ;
};
// get the font data
class PSP_ASCFONTS8_16
{
static ASCFontBitMap ascFontBitMap [ ] ;
static bool ascBMPinited;
static const unsigned char * const font_dot_matrix_p;
//one byte offer 8 dots data
static const unsigned short dotsPerByte = 8 ;
//================================================================
//
// Every ASC takes 16 bytes,
// so the 2nd ASC should return fontp + (2-1)*16 = 16
// 3rd ASC : fontp+ (3-1)* 16 = 32.
// The input index is just the ASC.
// eg. index = 'a' get 'a's data.
//================================================================
static void getFontData( unsigned index, Dot_Font_Data * font_data );
static bool drawASC8_16ToBMP ( unsigned char _char, ASCFontBitMap &bitmap );
static const unsigned short defaultColor =1;
static void loadAllASCBitMap ( void );
//private constructor to prevent creating instance
PSP_ASCFONTS8_16 ();
~PSP_ASCFONTS8_16();
public:
static const unsigned char oneAscCharUseByte_LIB = PSP_Constants::oneAscCharUseByte_LIB;
static const unsigned int maxIndex;
static const unsigned short width = DotFont16ASCfont_width ;
static const unsigned short heigh = DotFont16ASCfont_heigh;
static ASCFontBitMap * getASCBmp( char ascchar );
};
//For Chinese 16X16 DOT FONT
class PSP_CNFONTS16_16
{
//private:
const static unsigned short defaultIndex = 0;
//this index has no font, I can use it.
const static unsigned short noFontHZKIndex = 6520;
const static unsigned short noFontHanZi = 63137 ;//f6 a1
//==========================================================================
// Chinese HanZi to HanZi LIB index
//==========================================================================
static unsigned long HanZiToHZKLibIndex ( const HanZi &hanzi );
const static unsigned char defaultColor = 1;
//================================================================
// index is the font's position in the HZK lib.
// eg. if the HZK contains 10000 HanZi,
// so getFontData( 1 ) gets the 1st HanZi's data.
// getFontData( 10 ) gets the 10th HanZi's data.
// every HanZi takes 32 bytes,
// so the 2nd HZ should return fontp+ (2-1)*32 = 32
// 3rd HZ : fontp+ (3-1)* 32 = 64.
// To get the index of a perticular HanZi,
// you must use cnToHZKIndex ( const HanZi &hanzi ).
// HanZi contains the HanZi char * data. ( two chars )
//================================================================
static void getFontData( unsigned index, Dot_Font_Data * font_data );
static const unsigned char * const font_dot_matrix_p ;
static bool drawKouHuBitMap ( HanZi16FontBitMap &bitmap );
public:
//Font width : 16 dots
static const unsigned short width = 16;
//Font heigh : 16 dots
static const unsigned short heigh = 16;
//One HanZi uses 32 bytes
static const unsigned char oneHanZiUseByte = 32;
static const unsigned short dotsPerByte = 8 ;
static const unsigned int maxIndex;
static bool drawHanZi16ToBMP ( unsigned short hanZi, HanZi16FontBitMap &bitmap ) ;
static bool getBitMapHZKLibIndex ( unsigned short index , HanZi16FontBitMap &bitmap ) ;
static void selfTest( void );
};
#endif // __PSP_ASCFONTS__
|
[
"ntchris0623@05aa5984-5704-11de-9010-b74abb91d602"
] |
[
[
[
1,
124
]
]
] |
86243bd22e76fff6e2662d77dec1091ed90095fd
|
d752d83f8bd72d9b280a8c70e28e56e502ef096f
|
/FugueDLL/Parser/Op Generation/Tuples.cpp
|
590973ce8bfac6428d43259ab8ab58985bd8a719
|
[] |
no_license
|
apoch/epoch-language.old
|
f87b4512ec6bb5591bc1610e21210e0ed6a82104
|
b09701714d556442202fccb92405e6886064f4af
|
refs/heads/master
| 2021-01-10T20:17:56.774468 | 2010-03-07T09:19:02 | 2010-03-07T09:19:02 | 34,307,116 | 0 | 0 | null | null | null | null |
UTF-8
|
C++
| false | false | 2,824 |
cpp
|
//
// The Epoch Language Project
// FUGUE Virtual Machine
//
// Operation generation code - operations for working with tuples
//
#include "pch.h"
#include "Parser/Parser State Machine/ParserState.h"
#include "Parser/Parse.h"
#include "Virtual Machine/Operations/Variables/TupleOps.h"
#include "Virtual Machine/Operations/UtilityOps.h"
#include "Virtual Machine/Core Entities/Program.h"
#include "Virtual Machine/Core Entities/Scopes/ScopeDescription.h"
using namespace Parser;
//
// Create an operation to read a value out of a tuple
//
VM::OperationPtr ParserState::CreateOperation_ReadTuple()
{
if(PassedParameterCount.top() != 2)
{
ReportFatalError("readtuple() function expects 2 parameters");
for(size_t i = PassedParameterCount.top(); i > 0; --i)
TheStack.pop_back();
return VM::OperationPtr(new VM::Operations::NoOp);
}
StackEntry member = TheStack.back();
TheStack.pop_back();
StackEntry tuplevar = TheStack.back();
TheStack.pop_back();
if(member.Type != StackEntry::STACKENTRYTYPE_IDENTIFIER || tuplevar.Type != StackEntry::STACKENTRYTYPE_IDENTIFIER)
{
ReportFatalError("Invalid parameters to readtuple()");
return VM::OperationPtr(new VM::Operations::NoOp);
}
if(CurrentScope->GetVariableType(tuplevar.StringValue) != VM::EpochVariableType_Tuple)
{
ReportFatalError("Variable is not a tuple type");
return VM::OperationPtr(new VM::Operations::NoOp);
}
return VM::OperationPtr(new VM::Operations::ReadTuple(ParsedProgram->PoolStaticString(tuplevar.StringValue), ParsedProgram->PoolStaticString(member.StringValue)));
}
//
// Create an operation to write a value into a tuple
//
VM::OperationPtr ParserState::CreateOperation_AssignTuple()
{
if(PassedParameterCount.top() != 3)
{
ReportFatalError("assigntuple() function expects 3 parameters");
for(size_t i = PassedParameterCount.top(); i > 0; --i)
TheStack.pop_back();
return VM::OperationPtr(new VM::Operations::NoOp);
}
StackEntry value = TheStack.back();
TheStack.pop_back();
StackEntry member = TheStack.back();
TheStack.pop_back();
StackEntry tuplevar = TheStack.back();
TheStack.pop_back();
if(member.Type != StackEntry::STACKENTRYTYPE_IDENTIFIER || tuplevar.Type != StackEntry::STACKENTRYTYPE_IDENTIFIER)
{
ReportFatalError("Invalid parameters to assigntuple()");
return VM::OperationPtr(new VM::Operations::NoOp);
}
if(CurrentScope->GetVariableType(tuplevar.StringValue) != VM::EpochVariableType_Tuple)
{
ReportFatalError("Variable is not a tuple type");
return VM::OperationPtr(new VM::Operations::NoOp);
}
return VM::OperationPtr(new VM::Operations::AssignTuple(ParsedProgram->PoolStaticString(tuplevar.StringValue), ParsedProgram->PoolStaticString(member.StringValue)));
}
|
[
"[email protected]"
] |
[
[
[
1,
94
]
]
] |
6c29e12691f85391e4279852fcf2fec31004076c
|
656de8005c621f24d86a65062a49abd98b0ec753
|
/adbusqt/qdbusobject.cpp
|
5c77715efa8c037cfb38f58d93091b2082bb43ef
|
[] |
no_license
|
jmckaskill/adbus
|
0016002b99e68d6c1e118a53931bd253661439e2
|
a8ad1368cfc5b925b336c6243626f86d96a353b0
|
refs/heads/master
| 2016-09-05T12:00:38.077922 | 2010-03-22T20:49:51 | 2010-03-22T20:49:51 | 340,965 | 5 | 2 | null | null | null | null |
UTF-8
|
C++
| false | false | 23,658 |
cpp
|
/* vim: ts=4 sw=4 sts=4 et
*
* Copyright (c) 2009 James R. McKaskill
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*
* ----------------------------------------------------------------------------
*/
#include "qdbusobject_p.hxx"
#include "qdbusmessage_p.hxx"
#include "qdbuserror_p.hxx"
#include "qdbusconnection_p.hxx"
#include <QCoreApplication>
#include <QMetaObject>
#include <QMetaMethod>
#include <QMetaProperty>
#include <QThread>
#include <QDomDocument>
#include <QDomElement>
/* ------------------------------------------------------------------------- */
QDBusProxy::QDBusProxy()
: m_Msg(NULL)
{}
QDBusProxy::~QDBusProxy()
{ adbus_msg_free(m_Msg); }
/* ------------------------------------------------------------------------- */
QEvent::Type QDBusProxyEvent::type = (QEvent::Type) QEvent::registerEventType();
// Called on the connection thread
void QDBusProxy::ProxyCallback(void* user, adbus_Callback cb, void* cbuser)
{
QDBusProxy* s = (QDBusProxy*) user;
if (QThread::currentThread() == s->thread()) {
cb(cbuser);
} else {
QDBusProxyEvent* e = new QDBusProxyEvent;
e->cb = cb;
e->user = cbuser;
QCoreApplication::postEvent(s, e);
}
}
/* ------------------------------------------------------------------------- */
QEvent::Type QDBusProxyMsgEvent::type = (QEvent::Type)QEvent::registerEventType();
QDBusProxyMsgEvent::~QDBusProxyMsgEvent()
{
adbus_conn_deref(connection);
adbus_freedata(&msg);
}
// Called on the connection thread
int QDBusProxy::ProxyMsgCallback(void* user, adbus_MsgCallback cb, adbus_CbData* d)
{
QDBusProxy* s = (QDBusProxy*) user;
if (QThread::currentThread() == s->thread()) {
return adbus_dispatch(cb, d);
} else {
QDBusProxyMsgEvent* e = new QDBusProxyMsgEvent;
e->cb = cb;
e->connection = d->connection;
e->user1 = d->user1;
e->user2 = d->user2;
adbus_clonedata(d->msg, &e->msg);
adbus_conn_ref(e->connection);
QCoreApplication::postEvent(s, e);
// We will send the return on the other thread
d->ret = NULL;
return 0;
}
}
/* ------------------------------------------------------------------------- */
// Called on the local thread
bool QDBusProxy::event(QEvent* event)
{
if (event->type() == QDBusProxyEvent::type) {
QDBusProxyEvent* e = (QDBusProxyEvent*) event;
e->cb(e->user);
return true;
} else if (event->type() == QDBusProxyMsgEvent::type) {
QDBusProxyMsgEvent* e = (QDBusProxyMsgEvent*) event;
adbus_CbData d = {};
d.connection = e->connection;
d.msg = &e->msg;
d.user1 = e->user1;
d.user2 = e->user2;
if (e->ret) {
if (!m_Msg) {
m_Msg = adbus_msg_new();
}
d.ret = m_Msg;
adbus_msg_reset(d.ret);
}
adbus_dispatch(e->cb, &d);
if (d.ret) {
adbus_msg_send(d.ret, d.connection);
}
return true;
} else {
return QObject::event(event);
}
}
/* ------------------------------------------------------------------------- */
QDBusObject::QDBusObject(const QDBusConnection& connection, QObject* tracked)
: m_QConnection(connection),
m_Connection(QDBusConnectionPrivate::Connection(connection)),
m_Tracked(tracked)
{
// Filter events in order to get the ThreadChange event
m_Tracked->installEventFilter(this);
connect(m_Tracked, SIGNAL(destroyed()), this, SLOT(destroy()), Qt::DirectConnection);
}
void QDBusObject::Delete(void* u)
{
QDBusObject* d = (QDBusObject*) u;
// Remove all pending binds, matches, and replies
QDBusUserData* i;
DIL_FOREACH(QDBusUserData, i, &d->m_Matches, hl) {
adbus_conn_removematch(d->m_Connection, ((QDBusMatchData*) d)->connMatch);
}
Q_ASSERT(dil_isempty(&d->m_Matches));
DIL_FOREACH(QDBusUserData, i, &d->m_Replies, hl) {
adbus_conn_removereply(d->m_Connection, ((QDBusReplyData*) d)->connReply);
}
Q_ASSERT(dil_isempty(&d->m_Replies));
DIL_FOREACH(QDBusUserData, i, &d->m_Binds, hl) {
adbus_conn_unbind(d->m_Connection, ((QDBusBindData*) d)->connBind);
}
Q_ASSERT(dil_isempty(&d->m_Binds));
delete d;
}
void QDBusObject::destroy()
{
if (m_Tracked) {
QDBusConnectionPrivate::RemoveObject(m_QConnection, m_Tracked);
}
// Kill all incoming events from the connection thread
setParent(NULL);
moveToThread(NULL);
// Delete the object on the proxy thread - this ensures that it receives all
// of our messages up to this point safely and removing services can only be
// done on the connection thread.
adbus_conn_proxy(m_Connection, &QDBusObject::Delete, this);
}
/* ------------------------------------------------------------------------- */
int QDBusObject::ReplyCallback(adbus_CbData* d)
{
QDBusUserData* data = (QDBusUserData*) d->user1;
adbus_Iterator argiter = {};
adbus_iter_args(&argiter, d->msg);
if (data->argList.GetArguments(&argiter))
return -1;
data->object->qt_metacall(QMetaObject::InvokeMetaMethod, data->methodIndex, data->argList.Data());
return 0;
}
/* ------------------------------------------------------------------------- */
int QDBusObject::ErrorCallback(adbus_CbData* d)
{
QDBusUserData* data = (QDBusUserData*) d->user1;
DBusError dbusError = {d->msg};
QDBusError err(&dbusError);
QDBusMessage msg;
if (QDBusMessagePrivate::Copy(d->msg, &msg))
return -1;
// Error methods are void (QDBusError, QDBusMessage)
void* args[] = {0, &err, &msg};
data->object->qt_metacall(QMetaObject::InvokeMetaMethod, data->errorIndex, args);
return 0;
}
/* ------------------------------------------------------------------------- */
int QDBusObject::MethodCallback(adbus_CbData* d)
{
QDBusUserData* method = (QDBusUserData*) d->user1;
QDBusUserData* bind = (QDBusUserData*) d->user2;
adbus_Iterator argiter = {};
adbus_iter_args(&argiter, d->msg);
if (method->argList.GetArguments(&argiter))
return -1;
bind->object->qt_metacall(QMetaObject::InvokeMetaMethod, method->methodIndex, method->argList.Data());
if (d->ret) {
method->argList.GetReturns(adbus_msg_argbuffer(d->ret));
}
return 0;
}
/* ------------------------------------------------------------------------- */
int QDBusObject::GetPropertyCallback(adbus_CbData* d)
{
QDBusUserData* prop = (QDBusUserData*) d->user1;
QDBusUserData* bind = (QDBusUserData*) d->user2;
bind->object->qt_metacall(QMetaObject::ReadProperty, prop->methodIndex, prop->argList.Data());
prop->argList.GetProperty(d->getprop);
return 0;
}
/* ------------------------------------------------------------------------- */
int QDBusObject::SetPropertyCallback(adbus_CbData* d)
{
QDBusUserData* prop = (QDBusUserData*) d->user1;
QDBusUserData* bind = (QDBusUserData*) d->user2;
if (prop->argList.SetProperty(&d->setprop))
return -1;
bind->object->qt_metacall(QMetaObject::WriteProperty, prop->methodIndex, prop->argList.Data());
return 0;
}
/* ------------------------------------------------------------------------- */
void QDBusObject::DoAddReply(void* u)
{
QDBusReplyData* d = (QDBusReplyData*) u;
dil_insert_after(QDBusUserData, &d->owner->m_Replies, d, &d->hl);
d->connReply = adbus_conn_addreply(d->connection, &d->reply);
}
bool QDBusObject::addReply(const QByteArray& remote, uint32_t serial, QObject* receiver, const char* returnMethod, const char* errorMethod)
{
int returnIndex = -1;
int errorIndex = -1;
const QMetaObject* meta = receiver->metaObject();
if (returnMethod && *returnMethod) {
// If the method is set it must be a valid slot
if (returnMethod[0] != '1') {
return false;
}
returnMethod++;
returnIndex = meta->indexOfSlot(returnMethod);
if (returnIndex < 0) {
returnIndex = meta->indexOfSlot(QMetaObject::normalizedSignature(returnMethod).constData());
if (returnIndex < 0) {
return false;
}
}
}
if (errorMethod && *errorMethod) {
if (errorMethod[0] != '1') {
return false;
}
errorMethod++;
errorIndex = meta->indexOfSlot(errorMethod);
if (errorIndex < 0) {
errorIndex = meta->indexOfSlot(QMetaObject::normalizedSignature(errorMethod).constData());
if (errorIndex < 0) {
return false;
}
}
}
if (returnIndex < 0 && errorIndex < 0)
return false;
QList<QDBusArgumentType> types;
if (returnIndex >= 0 && qDBusLookupParameters(meta->method(returnIndex), &types))
return false;
QDBusReplyData* d = new QDBusReplyData;
d->argList.init(types);
d->methodIndex = returnIndex;
d->errorIndex = errorIndex;
d->object = receiver;
d->owner = this;
d->remote = remote;
d->reply.remote = d->remote.constData();
d->reply.remoteSize = d->remote.size();
d->reply.serial = serial;
d->reply.release[0] = &QDBusReplyData::Free;
d->reply.ruser[0] = d;
d->reply.cuser = d;
d->reply.euser = d;
d->reply.proxy = &ProxyMsgCallback;
d->reply.puser = this;
if (returnIndex >= 0)
d->reply.callback = &ReplyCallback;
if (errorIndex >= 0)
d->reply.error = &ErrorCallback;
adbus_conn_proxy(m_Connection, &DoAddReply, d);
return true;
}
/* ------------------------------------------------------------------------- */
void QDBusObject::DoAddMatch(void* u)
{
QDBusMatchData* d = (QDBusMatchData*) u;
dil_insert_after(QDBusUserData, &d->owner->m_Matches, d, &d->hl);
d->connMatch = adbus_conn_addmatch(d->connection, &d->match);
}
bool QDBusObject::addMatch(
const QByteArray& service,
const QByteArray& path,
const QByteArray& interface,
const QByteArray& name,
QObject* receiver,
const char* slot)
{
if (!slot || !*slot)
return false;
const QMetaObject* meta = receiver->metaObject();
QByteArray normalized = QMetaObject::normalizedSignature(slot);
int methodIndex = meta->indexOfMethod(normalized.constData());
if (methodIndex < 0)
return false;
QMetaMethod metaMethod = meta->method(methodIndex);
if (metaMethod.methodType() != QMetaMethod::Slot && metaMethod.methodType() != QMetaMethod::Signal)
return false;
QList<QDBusArgumentType> types;
if (qDBusLookupParameters(metaMethod, &types))
return false;
QDBusMatchData* d = new QDBusMatchData;
d->argList.init(types);
d->methodIndex = methodIndex;
d->object = receiver;
d->owner = this;
d->sender = service;
d->match.sender = d->sender.constData();
d->match.senderSize = d->sender.size();
d->path = path;
d->match.path = d->path.constData();
d->match.pathSize = d->path.size();
if (!interface.isEmpty()) {
d->interface = interface;
d->match.interface = d->interface.constData();
d->match.interfaceSize = d->interface.size();
}
d->member = name;
d->match.member = d->member.constData();
d->match.memberSize = d->member.size();
d->match.release[0] = &QDBusUserData::Free;
d->match.ruser[0] = d;
d->match.callback = &ReplyCallback;
d->match.cuser = d;
d->match.proxy = &ProxyMsgCallback;
d->match.puser = this;
adbus_conn_proxy(m_Connection, &DoAddMatch, d);
return true;
}
/* ------------------------------------------------------------------------- */
// Signals and methods both come through QMetaObject::method
static adbus_Member* AddMethod(adbus_Interface* iface, QMetaMethod method, int methodIndex)
{
QMetaMethod::MethodType type = method.methodType();
QMetaMethod::Access access = method.access();
const char* name = method.signature();
const char* nend = strchr(name, '(');
if (nend == NULL)
return NULL;
QList<QDBusArgumentType> arguments;
if (qDBusLookupParameters(method, &arguments))
return NULL;
QList<QByteArray> names = method.parameterNames();
if (names.size() != arguments.size())
return NULL;
switch (type)
{
case QMetaMethod::Method:
case QMetaMethod::Slot:
{
if (access < QMetaMethod::Public)
return NULL;
adbus_Member* mbr = adbus_iface_addmethod(iface, name, int(nend - name));
for (int i = 0; i < arguments.size(); i++) {
QDBusArgumentType* a = &arguments[i];
if (a->isReturn) {
adbus_mbr_retsig(mbr, a->dbusSignature.constData(), a->dbusSignature.size());
adbus_mbr_retsig(mbr, names[i].constData(), names[i].size());
} else {
adbus_mbr_argsig(mbr, a->dbusSignature.constData(), a->dbusSignature.size());
adbus_mbr_argsig(mbr, names[i].constData(), names[i].size());
}
}
QDBusUserData* d = new QDBusUserData;
d->argList.init(arguments);
d->methodIndex = methodIndex;
adbus_mbr_setmethod(mbr, &QDBusObject::MethodCallback, d);
adbus_mbr_addrelease(mbr, &QDBusUserData::Free, d);
return mbr;
}
case QMetaMethod::Signal:
{
if (access != QMetaMethod::Protected)
return NULL;
adbus_Member* mbr = adbus_iface_addmethod(iface, name, int(nend - name));
for (int i = 0; i < arguments.size(); i++) {
QDBusArgumentType* a = &arguments[i];
if (a->isReturn)
continue;
adbus_mbr_argsig(mbr, a->dbusSignature.constData(), a->dbusSignature.size());
adbus_mbr_argsig(mbr, names[i].constData(), names[i].size());
}
return mbr;
}
default:
return NULL;
}
}
/* ------------------------------------------------------------------------- */
static adbus_Member* AddProperty(adbus_Interface* iface, QMetaProperty prop, int propertyIndex)
{
QDBusArgumentType arg;
if (qDBusLookupCppSignature(prop.typeName(), &arg))
return NULL;
if (!prop.isValid() && !prop.isWritable())
return NULL;
QDBusUserData* d = new QDBusUserData;
d->argList.init(arg);
d->methodIndex = propertyIndex;
adbus_Member* mbr = adbus_iface_addproperty(iface, prop.name(), -1, arg.dbusSignature.constData(), arg.dbusSignature.size());
if (prop.isValid()) {
adbus_mbr_setgetter(mbr, &QDBusObject::GetPropertyCallback, d);
}
if (prop.isWritable()) {
adbus_mbr_setsetter(mbr, &QDBusObject::SetPropertyCallback, d);
}
adbus_mbr_addrelease(mbr, &QDBusUserData::Free, d);
return mbr;
}
/* ------------------------------------------------------------------------- */
void QDBusObject::DoBind(void* u)
{
QDBusBindData* d = (QDBusBindData*) u;
dil_insert_after(QDBusUserData, &d->owner->m_Binds, d, &d->hl);
d->connBind = adbus_conn_bind(d->connection, &d->bind);
adbus_iface_deref(d->bind.interface);
}
bool QDBusObject::bindFromMetaObject(const QByteArray& path, QObject* object, QDBusConnection::RegisterOptions options)
{
// See if we have to export anything
if ((options & QDBusConnection::ExportAllContents) == 0)
return true;
const QMetaObject* meta;
for (meta = object->metaObject(); meta != NULL; meta = meta->superClass()) {
adbus_Interface* iface = adbus_iface_new(meta->className(), -1);
int mbegin = meta->methodOffset();
int mend = mbegin + meta->methodCount();
for (int mi = mbegin; mi < mend; mi++)
AddMethod(iface, meta->method(mi), mi);
int pbegin = meta->propertyOffset();
int pend = pbegin + meta->propertyCount();
for (int pi = pbegin; pi < pend; pi++)
AddProperty(iface, meta->property(pi), pi);
QDBusBindData* d = new QDBusBindData;
d->owner = this;
d->object = object;
d->path = path;
d->bind.path = d->path.constData();
d->bind.pathSize = d->path.size();
// interface is freed in DoBind
d->bind.interface = iface;
d->bind.cuser2 = d;
d->bind.release[0] = &QDBusBindData::Free;
d->bind.ruser[0] = d;
d->bind.proxy = &ProxyMsgCallback;
d->bind.puser = this;
adbus_conn_proxy(m_Connection, &DoBind, d);
}
return true;
}
/* ------------------------------------------------------------------------- */
static int GetAttribute(const QDomElement& element, const char* field, QByteArray* data)
{
QDomNode attr = element.attributes().namedItem(field);
if (!attr.isAttr())
return -1;
*data = attr.toAttr().value().toUtf8();
return 0;
}
static void GetAnnotations(adbus_Member* mbr, const QDomElement& xmlMember)
{
for (QDomElement anno = xmlMember.firstChildElement("annotation");
!anno.isNull();
anno = anno.nextSiblingElement("annotation"))
{
QByteArray annoName, annoValue;
if (GetAttribute(anno, "name", &annoName) || GetAttribute(anno, "value", &annoValue))
continue;
adbus_mbr_annotate(mbr,
annoName.constData(),
annoName.size(),
annoValue.constData(),
annoValue.size());
}
}
bool QDBusObject::bindFromXml(const QByteArray& path, QObject* object, const char* xml)
{
// Since the various callback use InvokeMetaMethod directly we need to at
// least check the xml against the meta object. In fact its much easier to
// pull the argument names and signatures out of the meta object.
const QMetaObject* meta = object->metaObject();
QDomDocument doc;
if (!doc.setContent(QByteArray(xml), false))
return false;
QDomElement xmlInterface = doc.documentElement();
if (xmlInterface.tagName() != "interface")
return false;
QByteArray ifaceName;
if (GetAttribute(xmlInterface, "name", &ifaceName))
return false;
adbus_Interface* iface = adbus_iface_new(ifaceName.constData(), ifaceName.size());
QDomElement member;
for (QDomElement xmlMember = xmlInterface.firstChildElement();
!xmlMember.isNull();
xmlMember = xmlMember.nextSiblingElement())
{
QByteArray name;
if (GetAttribute(xmlMember, "name", &name))
continue;
// Ignore the arguments and signatures given by the xml (its safer
// and easier to just pull the types out of QMetaObject). We need
// to pull out the annotations out of the xml.
QString tag = xmlMember.tagName();
if (tag == "method") {
int methodIndex = meta->indexOfSlot(name.constData());
if (methodIndex < 0)
methodIndex = meta->indexOfMethod(name.constData());
if (methodIndex < 0)
continue;
QMetaMethod metaMethod = meta->method(methodIndex);
adbus_Member* mbr = AddMethod(iface, metaMethod, methodIndex);
GetAnnotations(mbr, xmlMember);
} else if (tag == "signal") {
int sigIndex = meta->indexOfSignal(name.constData());
if (sigIndex < 0)
continue;
QMetaMethod metaMethod = meta->method(sigIndex);
adbus_Member* mbr = AddMethod(iface, metaMethod, sigIndex);
GetAnnotations(mbr, xmlMember);
} else if (tag == "property") {
int propIndex = meta->indexOfProperty(name.constData());
if (propIndex < 0)
continue;
QMetaProperty metaProperty = meta->property(propIndex);
adbus_Member* mbr = AddProperty(iface, metaProperty, propIndex);
GetAnnotations(mbr, xmlMember);
}
}
QDBusBindData* d = new QDBusBindData;
d->object = object;
d->owner = this;
d->path = path;
d->bind.path = d->path.constData();
d->bind.pathSize = d->path.size();
// interface is freed in DoBind
d->bind.interface = iface;
d->bind.cuser2 = d;
d->bind.release[0] = &QDBusUserData::Free;
d->bind.ruser[0] = d;
d->bind.proxy = &ProxyMsgCallback;
d->bind.puser = this;
adbus_conn_proxy(m_Connection, &DoBind, d);
return true;
}
/* ------------------------------------------------------------------------- */
static QEvent::Type sThreadChangeCompleteEvent = (QEvent::Type) QEvent::registerEventType();
bool QDBusObject::event(QEvent* e)
{
if (e->type() == sThreadChangeCompleteEvent) {
setParent(NULL);
return true;
} else {
return QDBusProxy::event(e);
}
}
bool QDBusObject::eventFilter(QObject* object, QEvent* event)
{
Q_ASSERT(object == m_Tracked);
if (event->type() == QEvent::ThreadChange) {
// We get the thread change event before the actual thread change occurs.
// We want to move with the object (ie whilst the lock in
// QObject::moveToThread is still held), so that we don't get events on
// the wrong thread. The only of doing this is to insert ourselves as a
// child of the tracked object, and then remove ourselves after we've
// moved.
setParent(m_Tracked);
// Post ourselves the thread change event which we will catch in
// QDBusObject::event on the new thread.
QCoreApplication::postEvent(this, new QEvent(sThreadChangeCompleteEvent));
}
return false;
}
|
[
"[email protected]"
] |
[
[
[
1,
770
]
]
] |
e9047d883e648404a231bf8f85c5639da059203d
|
011359e589f99ae5fe8271962d447165e9ff7768
|
/src/burner/tracklst.cpp
|
2c739503a6d92dd3353951d4462fbd6078f3b858
|
[] |
no_license
|
PS3emulators/fba-next-slim
|
4c753375fd68863c53830bb367c61737393f9777
|
d082dea48c378bddd5e2a686fe8c19beb06db8e1
|
refs/heads/master
| 2021-01-17T23:05:29.479865 | 2011-12-01T18:16:02 | 2011-12-01T18:16:02 | 2,899,840 | 1 | 0 | null | null | null | null |
UTF-8
|
C++
| false | false | 7,486 |
cpp
|
// sound track list, by regret
/* changelog:
update 1: create (ref: caname)
*/
#include "burner.h"
#include "tracklst.h"
#if defined (_XBOX)
#define MAX_PLAYLIST_ITEM 128
#define MAX_PLAYLIST_SECT 32
int nTrackCnt, nSectCnt;
int nCurrentTrack, nCurrentSect;
bool bNoSect;
static bool bNoTrack;
struct playlist_t
{
UINT16 code;
char desc[80];
char notes[80];
};
static playlist_t playlist[MAX_PLAYLIST_SECT][MAX_PLAYLIST_ITEM];
// send sound code to system
void sendSoundCode(UINT16 nCode)
{
int nHardware = (BurnDrvGetHardwareCode() & HARDWARE_PUBLIC_MASK);
switch (nHardware) {
case HARDWARE_SNK_NEOGEO:
NeoZ80Cmd(nCode);
break;
case HARDWARE_CAPCOM_CPS1:
case HARDWARE_CAPCOM_CPS1_GENERIC:
case HARDWARE_CAPCOM_CPSCHANGER:
CpsSoundCmd(nCode);
break;
case HARDWARE_CAPCOM_CPS2:
case HARDWARE_CAPCOM_CPS1_QSOUND:
QSoundCMD(nCode);
break;
default:
break;
}
}
// get track/section info from sound.dat
int getTrackCode(int nSect, int nTrack)
{
return playlist[nSect][nTrack].code;
}
TCHAR* getTrackDesc(int nSect, int nTrack, bool bIsSect)
{
char TrackTitle[180] = "";
char Notes[81] = "";
if (playlist[nSect][nTrack].desc[0])
strcpy(TrackTitle, playlist[nSect][nTrack].desc);
if (!bIsSect)
{
if (playlist[nSect][nTrack].notes[0])
{
sprintf(Notes, " - %s", playlist[nSect][nTrack].notes);
strcat(TrackTitle, Notes);
}
}
return (TCHAR *)U8toW(TrackTitle);
}
static TCHAR* getTrackInfo(bool bIsSect)
{
static TCHAR TrackTitle[180] = _T("");
TCHAR* pTrackDesc = NULL;
if (bIsSect)
{
pTrackDesc = getTrackDesc(0, nCurrentSect - 1, bIsSect);
sprintf(TrackTitle, _T("Sect%d: %s"), nCurrentSect, pTrackDesc);
}
else
{
pTrackDesc = getTrackDesc(nCurrentSect, nCurrentTrack, bIsSect);
sprintf(TrackTitle, _T("%.4x: %s"), playlist[nCurrentSect][nCurrentTrack].code, pTrackDesc);
}
return TrackTitle;
}
static void displayTrackInfo()
{
VidSNewTinyMsg(getTrackInfo(false), 0x90C0E0);
}
static void displaySectInfo()
{
VidSNewTinyMsg(getTrackInfo(true), 0x90C0E0);
}
// switch track
static void sendPlaylistCode()
{
sendSoundCode(playlist[nCurrentSect][nCurrentTrack].code);
}
void playNextTrack()
{
if (bNoTrack || !bDrvOkay)
return;
nCurrentTrack++;
if (nCurrentTrack >= nTrackCnt)
nCurrentTrack = 0;
sendPlaylistCode();
displayTrackInfo();
}
void playPreviousTrack()
{
if (bNoTrack || !bDrvOkay)
return;
nCurrentTrack--;
if (nCurrentTrack < 0)
nCurrentTrack = nTrackCnt - 1;
sendPlaylistCode();
displayTrackInfo();
}
void playCurrentTrack()
{
if (bNoTrack || !bDrvOkay)
return;
if (nCurrentTrack < 0)
nCurrentTrack = nTrackCnt - 1;
else if (nCurrentTrack >= nTrackCnt)
nCurrentTrack = 0;
sendPlaylistCode();
displayTrackInfo();
}
// switch section if playlist has
void selectNextSect()
{
if (bNoTrack || bNoSect)
return;
nCurrentSect++;
if (nCurrentSect > nSectCnt)
nCurrentSect = 1;
nCurrentTrack = 0;
nTrackCnt = playlist[0][nCurrentSect].code;
displaySectInfo();
}
void selectPreviousSect()
{
if (bNoTrack || bNoSect || !bDrvOkay) return;
nCurrentSect--;
if (nCurrentSect < 1) {
nCurrentSect = nSectCnt;
}
nCurrentTrack = 0;
nTrackCnt = playlist[0][nCurrentSect].code;
displaySectInfo();
}
void setCurrentSect()
{
if (bNoTrack || bNoSect || !bDrvOkay) return;
if (nCurrentSect > nSectCnt) {
nCurrentSect = 1;
}
else if (nCurrentSect < 1) {
nCurrentSect = nSectCnt;
}
nCurrentTrack = 0;
nTrackCnt = playlist[0][nCurrentSect].code;
}
// ==> parse sound.dat, ported from caname
static inline int atohex(char* s)
{
int res = 0;
while (*s) {
res *= 0x10;
if ((*s >= 'A' && *s <= 'F')
|| (*s >= 'a' && *s <= 'f')) {
res += (toupper(*s) - 'A') + 10;
} else {
res += *s - '0';
}
s++;
}
return res;
}
static int parseSoundData()
{
FILE* fp = NULL;
char name[MAX_PATH];
char setname[MAX_PATH];
char tmpbuf[MAX_PATH], tmpnum[5] = { 0, 0, 0, 0, 0 };
UINT16 tmpcode;
size_t i, j;
size_t name_length;
int item, playlist_format;
memset(&playlist, 0, sizeof(playlist_t) * MAX_PLAYLIST_SECT * MAX_PLAYLIST_ITEM);
sprintf(name, "config\\sound.dat");
strcpy(setname, BurnDrvGetTextA(DRV_NAME));
loading:
name_length = strlen(setname);
fp = fopen(name, "r");
if (fp == NULL)
return 0; // cannot open file
playlist_format = 2;
playlist[0][0].code = 0;
item = 0;
/* Ex.: kof98:0721:Opening */
/* Ex.: kof98:sect:BGM */
while (1) {
if (!fgets(tmpbuf, sizearray(tmpbuf), fp)) {
break;
}
if (tmpbuf[0] == ';' || (tmpbuf[0] == '/' && tmpbuf[1] == '/'))
continue; // skip comment
if (tmpbuf[name_length] != ':') continue;
if (strncmp(tmpbuf, setname, name_length) != 0) {
if (playlist_format == 2) {
continue;
} else {
if (playlist_format)
playlist[0][0].code = item;
break;
}
}
for (i = 0 , j = name_length + 1; i <= 3; i++, j++) {
tmpnum[i] = tmpbuf[j];
}
if (playlist_format == 2) {
if (strncmp(tmpnum, "secs", 3) == 0) {
bNoSect = false;
playlist_format = 0;
} else {
playlist_format = 1;
nSectCnt = 1;
}
}
if (strncmp(tmpnum, "sect", 3) == 0) {
if (playlist_format)
continue;
if (nSectCnt > 0)
playlist[0][nSectCnt].code = item;
item = 0;
if (tmpnum[3] == 'e') {
playlist[0][0].code = nSectCnt;
break;
}
i = 0;
j = name_length + 6;
while (tmpbuf[j] != '\n') {
playlist[0][nSectCnt].desc[i] = tmpbuf[j];
i++;
j++;
}
// playlist[0][item].desc[++i] = '\n';
nSectCnt++;
playlist[0][0].code = nSectCnt;
if (nSectCnt >= MAX_PLAYLIST_SECT)
break;
continue;
}
// clone set
if (strncmp(tmpnum, "name", 4) == 0) {
i = 0;
j = name_length + 6;
while (tmpbuf[j] != '\n') {
setname[i] = tmpbuf[j];
i++;
j++;
}
setname[i] = '\0';
fclose(fp);
goto loading;
}
tmpcode = atohex(tmpnum);
if (tmpcode == 0 && item) {
if (playlist_format) {
playlist[0][0].code = item;
break;
} else {
continue;
}
}
if (item >= MAX_PLAYLIST_ITEM) {
if (playlist_format) {
playlist[0][0].code = item;
break;
} else {
continue;
}
}
// notes code
if (tmpcode == 0xffff) {
i = 0;
j = name_length + 6;
while (tmpbuf[j] != '\n') {
playlist[nSectCnt][item - 1].notes[i] = tmpbuf[j];
i++;
j++;
}
} else {
playlist[nSectCnt][item].code = tmpcode;
i = 0;
j = name_length + 6;
while (tmpbuf[j] != '\n') {
playlist[nSectCnt][item].desc[i] = tmpbuf[j];
i++;
j++;
}
// playlist[nSectCnt][item].desc[++i] = '\n';
item++;
}
}
fclose(fp);
return playlist[0][0].code;
}
// <== parse sound.dat
int parseTracklist()
{
resetTracklist();
if (parseSoundData() == 0) {
return 1;
}
nCurrentSect = 1;
if (bNoSect) {
nTrackCnt = playlist[0][0].code;
} else {
nTrackCnt = playlist[0][nCurrentSect].code;
}
bNoTrack = false;
return 0; // success
}
void resetTracklist()
{
nTrackCnt = nSectCnt = 0;
nCurrentTrack = nCurrentSect = 0;
bNoSect = true;
bNoTrack = true;
}
#endif
|
[
"[email protected]"
] |
[
[
[
1,
408
]
]
] |
7be19f921fd4a6445ae4d04fe4f8110d29b487a2
|
6712f8313dd77ae820aaf400a5836a36af003075
|
/diffPBM.cpp
|
51ea0372848ad168c455e84fea1080b5c10638c6
|
[] |
no_license
|
AdamTT1/bdScript
|
d83c7c63c2c992e516dca118cfeb34af65955c14
|
5483f239935ec02ad082666021077cbc74d1790c
|
refs/heads/master
| 2021-12-02T22:57:35.846198 | 2010-08-08T22:32:02 | 2010-08-08T22:32:02 | null | 0 | 0 | null | null | null | null |
UTF-8
|
C++
| false | false | 3,687 |
cpp
|
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <unistd.h>
#include <ctype.h>
static bool readLine(FILE *f, char *buf, unsigned max) {
bool inComment = false ;
unsigned len = 0 ;
while( len < max ) {
char c ;
if( 1 == fread(&c,1,1,f) ) {
if( '\n' == c ) {
break;
} else if ('#' == c ) {
inComment = true ;
} else {
if( !inComment )
buf[len++] = c ;
}
}
else
return false ;
}
if( len < max ) {
buf[len] = '\0' ;
return true ;
}
else
return false ;
}
static bool readHeader(FILE *f, unsigned &width, unsigned &height) {
enum state_e {
WANTFMT = 0,
WANTSIZE = 1,
WANTMAX = 2,
DATA
} state = WANTFMT ;
while( state < DATA ) {
char inBuf[256];
if( readLine(f,inBuf,sizeof(inBuf)-1) ) {
switch(state){
case WANTFMT: {
if('P' == inBuf[0])
state = WANTSIZE ;
else if( inBuf[0] ){
fprintf(stderr, "Invalid data %s in state %d\n", inBuf, state );
return false ;
}
break;
}
case WANTSIZE: {
if( isdigit(inBuf[0]) ) {
if( 2 == sscanf(inBuf,"%u %u", &width,&height) ) {
state= WANTMAX ;
} else {
fprintf(stderr, "Invalid PBM size <%s>\n", inBuf);
return false ;
}
}
else if( inBuf[0] ){
fprintf(stderr, "Invalid data %s in state %d\n", inBuf, state );
return false ;
}
break;
}
case WANTMAX: {
if( isdigit(inBuf[0]) ) {
unsigned max ;
if( 1 == sscanf(inBuf,"%u", &max) ) {
state= DATA ;
} else {
fprintf(stderr, "Invalid PBM max <%s>\n", inBuf);
return false ;
}
}
else if( inBuf[0] ){
fprintf(stderr, "Invalid data %s in state %d\n", inBuf, state );
return false ;
}
break;
}
default:
fprintf(stderr, "Weird state %d\n", state );
return false ;
}
}
else
return false ;
}
return (DATA == state);
}
int main(int argc, char const * const argv[])
{
int rval = -1 ;
if( 4 == argc ) {
unsigned lwidth, lheight ;
FILE *fLeft = fopen(argv[1],"rb");
if( 0 == fLeft ){
perror(argv[1]);
return -1 ;
}
if( !readHeader(fLeft,lwidth,lheight) ){
fprintf(stderr, "Error reading header from %s\n", argv[1]);
return -1 ;
}
FILE *fRight = fopen(argv[2],"rb");
if( 0 == fRight ){
perror(argv[2]);
return -1 ;
}
unsigned rwidth, rheight ;
if( !readHeader(fRight,rwidth,rheight) ){
fprintf(stderr, "Error reading header from %s\n", argv[2]);
return -1 ;
}
if( (lwidth != rwidth) || (lheight != rheight) ){
fprintf(stderr, "mismatched widths (%u.%u) or heights (%u.%u)\n", lwidth,rwidth,lheight,rheight);
return -1 ;
}
printf( "compare %ux%u pixels\n", lwidth, lheight );
unsigned imgSize= lwidth*lheight*3 ;
unsigned char * const left = new unsigned char [imgSize];
unsigned char * const right = new unsigned char [imgSize];
unsigned char * const diff = new unsigned char [imgSize];
if( imgSize != fread(left,1,imgSize,fLeft) ) {
perror( "read(left)" );
return -1 ;
}
if( imgSize != fread(right,1,imgSize,fRight) ) {
perror( "read(right)" );
return -1 ;
}
for( unsigned i = 0 ; i < imgSize ; i++ ){
diff[i] = ~(left[i]^right[i]);
}
FILE *fOut = fopen(argv[3],"wb");
if( fOut ){
fprintf(fOut,"P6\n%u %u\n255\n", lwidth,lheight);
fwrite(diff,1,imgSize,fOut);
fclose(fOut);
rval = 0 ;
}
else
perror(argv[3]);
} else
fprintf(stderr, "Usage: %s left.pbm right.pbm diff.pbm\n", argv[0] );
return rval ;
}
|
[
"ericn@ericsony.(none)"
] |
[
[
[
1,
153
]
]
] |
fd86307e724e1797df8a3bf20655d9fd8699542a
|
813c53dc1661e4b07863ef2ab3860dd2b0aa09ef
|
/river/layout/flow.hpp
|
8bf0c4e45b2517be7d7ae63972d13e5d17cbbef2
|
[] |
no_license
|
Zoxc/scaled
|
1ae7233fee575a8b1c80fd495b7d014779a781f4
|
9b7cab7efcb43892115912dc4a2847795b91668d
|
refs/heads/master
| 2021-01-01T20:12:04.572185 | 2011-03-20T21:21:46 | 2011-03-20T21:21:46 | 755,820 | 0 | 0 | null | null | null | null |
UTF-8
|
C++
| false | false | 178 |
hpp
|
#pragma once
#include "container.hpp"
namespace River
{
class Flow:
public Container
{
public:
void layout(int available_width, int available_height);
};
};
|
[
"[email protected]"
] |
[
[
[
1,
12
]
]
] |
00a03881481cb0fa457e48238c8fa4bdba0f45d3
|
2900ae9af8bc7581ec9e6b655f90074df5c4b394
|
/AnalisadorSintaticoLL/src/Tabela.h
|
45ba4ce57d41e7a9cf5ccf2916d8033d3c0694a9
|
[] |
no_license
|
teresafernandes/analisador-sintatico-recursivo
|
3f38e763d1962b179f663e402727522469069d3a
|
9883d272ca552640684b74875454a741f38a5b9b
|
refs/heads/master
| 2021-01-16T19:31:25.636723 | 2011-10-24T05:11:17 | 2011-10-24T05:11:17 | null | 0 | 0 | null | null | null | null |
UTF-8
|
C++
| false | false | 2,397 |
h
|
/*
* Tabela.h
*
* Created on: 23/10/2011
* Author: Claudio
*/
#ifndef TABELA_H_
#define TABELA_H_
#define SIZE 135
#include <iostream>
#include <map>
#include <vector>
using namespace std;
enum {
DOLLAR,
STRING_,
REAL_NUMBER_,
INTEGER_NUMBER_,
IDENTIFIER_,
SET_,
OF_,
RECORD_,
END_,
LIST_,
ARRAY_,
IN_,
NOT_,
NIL_,
CASE_,
ELSE_,
THEN_,
IF_,
DO_,
DOWNTO_,
TO_,
FOR_,
WHILE_,
BEGIN_,
ASSIGNMENT_,
VAR_,
DIV_,
MOD_,
AND_,
OR_,
FUNCTION_,
PROCEDURE_,
TYPE_,
CONST_,
PROGRAM_,
COMMA_,
DOT_,
UPARROW_,
COLON_,
SEMI_COLON_,
DOTDOT_,
LBRAC_,
RBRAC_,
LPAREN_,
RPAREN_,
ARROBA_,
LBRAC_BAR_,
RBRAC_BAR_,
CONS_,
OP_MULT_,
OP_DIV_,
EQUAL_,
NOTEQUAL_,
LT_,
LE_,
GT_,
GE_,
SIGN_,
program,
program_heading,
block,
declaration_part,
constant_definition_part,
constant_definition,
type_definition_part,
type_definition,
variable_declaration_part,
variable_declaration,
procedure_and_function_declaration_part,
procedure_declaration,
function_declaration,
statement_part,
procedure_heading,
function_heading,
formal_parameter_list,
formal_parameter_section,
value_parameter_section,
variable_parameter_section,
parameter_type,
array_schema,
bound_specification,
statement_sequence,
statement,
simple_statement,
assignment_statement,
procedure_statement,
structured_statement,
compound_statement,
repetitive_statement,
while_statement,
for_statement,
conditional_statement,
if_statement,
case_statement,
case_limb,
case_label_list,
actual_parameter_list,
expression,
simple_expression,
term,
factor,
factor_aux,
relational_operator,
addition_operator,
multiplication_operator,
variable,
variable_aux,
component_variable,
indexed_variable,
field_designator,
list,
list_aux,
set,
element_list,
type,
simple_type,
simple_type_aux,
enumerated_type,
subrange_type,
subrange_type_aux,
consant_aux,
structured_type,
array_type,
list_type,
record_type,
set_type,
pointer_type,
field_list,
fixed_part,
record_section,
identifier_list,
expression_list,
number,
sign,
constant};
class Tabela {
public:
Tabela();
virtual ~Tabela();
int * tabela[SIZE][SIZE];
void buildTabela();
};
#endif /* TABELA_H_ */
|
[
"[email protected]@07a0d547-dbc2-1e0f-f32a-8f814e00f0f4"
] |
[
[
[
1,
166
]
]
] |
c21fbc6548b5b918962eb44976f107952f53bb07
|
4aadb120c23f44519fbd5254e56fc91c0eb3772c
|
/Source/opensteer/include/OpenSteer/AbstractVehicle.h
|
37232883273107646d7acab8b62c35f5700e596f
|
[
"MIT"
] |
permissive
|
janfietz/edunetgames
|
d06cfb021d8f24cdcf3848a59cab694fbfd9c0ba
|
04d787b0afca7c99b0f4c0692002b4abb8eea410
|
refs/heads/master
| 2016-09-10T19:24:04.051842 | 2011-04-17T11:00:09 | 2011-04-17T11:00:09 | 33,568,741 | 0 | 0 | null | null | null | null |
UTF-8
|
C++
| false | false | 6,056 |
h
|
//-----------------------------------------------------------------------------
//
//
//! OpenSteer -- Steering Behaviors for Autonomous Characters
//
//! Copyright (c) 2002-2005, Sony Computer Entertainment America
//! Original author: Craig Reynolds <[email protected]>
//
//! Permission is hereby granted, free of charge, to any person obtaining a
//! copy of this software and associated documentation files (the "Software"),
//! to deal in the Software without restriction, including without limitation
//! the rights to use, copy, modify, merge, publish, distribute, sublicense,
//! and/or sell copies of the Software, and to permit persons to whom the
//! Software is furnished to do so, subject to the following conditions:
//
//! The above copyright notice and this permission notice shall be included in
//! all copies or substantial portions of the Software.
//
//! THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
//! IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
//! FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
//! THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
//! LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
//! FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
//! DEALINGS IN THE SOFTWARE.
//
//
//-----------------------------------------------------------------------------
//
//
//! AbstractVehicle: pure virtual base class for generic steerable vehicles
//
//! 10-04-04 bk: put everything into the OpenSteer namespace
//! 01-30-03 cwr: created
//
//
//-----------------------------------------------------------------------------
#ifndef OPENSTEER_ABSTRACTVEHICLE_H
#define OPENSTEER_ABSTRACTVEHICLE_H
#include "OpenSteer/LocalSpace.h"
#include "OpenSteer/AbstractRenderable.h"
#include "OpenSteer/Proximity.h"
//! STL vector containers
#include <vector>
//-----------------------------------------------------------------------------
namespace OpenSteer {
//-------------------------------------------------------------------------
enum ESerializeDataType
{
ESerializeDataType_Position,
ESerializeDataType_Forward,
ESerializeDataType_Side,
ESerializeDataType_Up,
ESerializeDataType_Force,
ESerializeDataType_Radius,
ESerializeDataType_Speed,
ESerializeDataType_Orientation,
ESerializeDataType_CompressedOrientation1,
ESerializeDataType_CompressedOrientation2,
ESerializeDataType_CompressedForce,
ESerializeDataType_AngularVelocity,
ESerializeDataType_LinearVelocity,
ESerializeDataType_UpdateTicks,
ESerializeDataType_ControllerAction,
ESerializeDataType_Count,
};
class AbstractVehicle;
typedef OpenSteer::AbstractProximityDatabase<AbstractVehicle*> ProximityDatabase;
typedef OpenSteer::AbstractTokenForProximityDatabase<AbstractVehicle*> ProximityToken;
typedef AbstractRenderMixin<AbstractEntityUpdatedLocalSpace> AbstractRenderableEntityUpdatedLocalSpace;
class AbstractVehicle : public AbstractRenderableEntityUpdatedLocalSpace
{
public:
virtual ~AbstractVehicle() { /* Nothing to do. */ }
//! mass (defaults to unity so acceleration=force)
virtual float mass (void) const OS_ABSTRACT;
virtual float setMass (float) OS_ABSTRACT;
//! size of bounding sphere, for obstacle avoidance, etc.
virtual float radius (void) const OS_ABSTRACT;
virtual float setRadius (float) OS_ABSTRACT;
//! speed of vehicle (may be faster than taking magnitude of velocity)
virtual float speed (void) const OS_ABSTRACT;
virtual float setSpeed (float) OS_ABSTRACT;
//! groups of (pointers to) abstract vehicles, and iterators over them
typedef std::vector<AbstractVehicle*> group;
typedef group::const_iterator iterator;
//-----------------------------------------------------------------------
//! XXX this vehicle-model-specific functionality functionality seems out
//! XXX of place on the abstract base class, but for now it is expedient
//! the maximum steering force this vehicle can apply
virtual float maxForce (void) const OS_ABSTRACT;
virtual float setMaxForce (float) OS_ABSTRACT;
//! the maximum speed this vehicle is allowed to move
virtual float maxSpeed (void) const OS_ABSTRACT;
virtual float setMaxSpeed (float) OS_ABSTRACT;
virtual float relativeSpeed (void) const OS_ABSTRACT;
//! dp - added to support heterogeneous flocks
// virtual void update(const float currentTime, const float elapsedTime) OS_ABSTRACT;
//! CP ++
virtual void reset( void ) OS_ABSTRACT;
virtual void allocateProximityToken( ProximityDatabase* pd ) OS_ABSTRACT;
virtual void regenerateLocalSpace( const Vec3& newForward,
const float elapsedTime) OS_ABSTRACT;
virtual void applySteeringForce (const Vec3& force,
const float elapsedTime) OS_ABSTRACT;
virtual Vec3 determineCombinedSteering (const float elapsedTime) OS_ABSTRACT;
//! adjust the steering force passed to applySteeringForce.
//! allows a specific vehicle class to redefine this adjustment.
//! default is to disallow backward-facing steering at low speed.
virtual Vec3 adjustRawSteeringForce (const Vec3& force,
const float deltaTime) const OS_ABSTRACT;
virtual bool movesPlanar( void ) const OS_ABSTRACT;
//! CP --
};
//! more convenient short names for AbstractVehicle group and iterator
typedef AbstractVehicle::group AVGroup;
typedef AbstractVehicle::iterator AVIterator;
} //! namespace OpenSteer
//-----------------------------------------------------------------------------
#endif //! OPENSTEER_ABSTRACTVEHICLE_H
|
[
"janfietz@localhost"
] |
[
[
[
1,
151
]
]
] |
311858491eec1443269baf04685ebc8d6c5782bd
|
d37a1d5e50105d82427e8bf3642ba6f3e56e06b8
|
/DVR/HaohanITPlayer/public/Common/SysUtils/Windows/DMACheck.h
|
e672db44f7ada8125b6d5e1723ffa4b4cad9aa00
|
[] |
no_license
|
080278/dvrmd-filter
|
176f4406dbb437fb5e67159b6cdce8c0f48fe0ca
|
b9461f3bf4a07b4c16e337e9c1d5683193498227
|
refs/heads/master
| 2016-09-10T21:14:44.669128 | 2011-10-17T09:18:09 | 2011-10-17T09:18:09 | 32,274,136 | 0 | 0 | null | null | null | null |
UTF-8
|
C++
| false | false | 819 |
h
|
//-----------------------------------------------------------------------------
// DMACheck.h
// Copyright (c) 1991 - 2004, Haohanit. All rights reserved.
//-----------------------------------------------------------------------------
//SR FS: Reviewed [wwt 20040914]
//SR FS: Reviewed [DDT 20040928] Second pass.
//SR FS: Reviewed [JAW 20040928]
#if defined (_WIN32)
#ifndef __DMACHECK__
#define __DMACHECK__
#define Win95 1 //Windows 95
#define Win98 2 //Windows 98
#define Win98SE 3 //Windows 98 SE
#define WinMe 4 //Windows ME
#define WinNT4 5 //Windows NT 4.0
#define Win2K 6 //Windows 2000
#define WinXP 7 //Windows XP
extern bool CheckDMAStatus(bool& dmaDisabled, std::vector<std::string>& list);
extern SInt32 GetVersionOS();
#endif __DMACHECK__
#endif
|
[
"[email protected]@27769579-7047-b306-4d6f-d36f87483bb3"
] |
[
[
[
1,
31
]
]
] |
324d6d1bffe799caf83bf27ba6c99464e15c92bd
|
b8fe0ddfa6869de08ba9cd434e3cf11e57d59085
|
/ouan-tests/TestGrass/GrassParticle.h
|
5edff8c1db7ca26b1ec8f6c69cf4825644d1b5b0
|
[] |
no_license
|
juanjmostazo/ouan-tests
|
c89933891ed4f6ad48f48d03df1f22ba0f3ff392
|
eaa73fb482b264d555071f3726510ed73bef22ea
|
refs/heads/master
| 2021-01-10T20:18:35.918470 | 2010-06-20T15:45:00 | 2010-06-20T15:45:00 | 38,101,212 | 0 | 0 | null | null | null | null |
UTF-8
|
C++
| false | false | 855 |
h
|
#ifndef _INCLUDED_GRASS_PARTICLE_H
#define _INCLUDED_GRASS_PARTICLE_H
#include "Ogre.h"
class GrassParticle
{
public:
GrassParticle(void);
// Constraint control
void EnableStepping(void);
void DisableStepping(void);
void SetPosition(const Ogre::Vector3 &pos);
void GetPosition(Ogre::Vector3 &dest) const;
void SetPositionOnly(const Ogre::Vector3 &pos) { m_Position = pos; }
void ClearForce(void);
void Integrate(float t);
friend class GrassParticleField;
private:
// Current position
Ogre::Vector3 m_Position;
// Old position
Ogre::Vector3 m_OPosition;
// Acceleration
Ogre::Vector3 m_Acceleration;
// Current force affecting this particle
Ogre::Vector3 m_Force;
float m_Mass;
// Does this particle need stepping?
bool m_Step;
};
#endif /* _INCLUDED_GRASS_PARTICLE_H */
|
[
"juanj.mostazo@6899d1ce-2719-11df-8847-f3d5e5ef3dde"
] |
[
[
[
1,
48
]
]
] |
3fce6980956b3ce3871ac9c9baa4c16ca8a419d5
|
51e1cf5dc3b99e8eecffcf5790ada07b2f03f39c
|
/SMC/src/animation.cpp
|
ecf04dc022e220d4e6db7d1894b5b350664c1b84
|
[] |
no_license
|
jdek/jim-pspware
|
c3e043b59a69cf5c28daf62dc9d8dca5daf87589
|
fd779e1148caac2da4c590844db7235357b47f7e
|
refs/heads/master
| 2021-05-31T06:45:03.953631 | 2007-06-25T22:45:26 | 2007-06-25T22:45:26 | 56,973,047 | 2 | 1 | null | null | null | null |
UTF-8
|
C++
| false | false | 7,420 |
cpp
|
/***************************************************************************
animation.cpp - Animation class
-------------------
copyright : (C) 2003-2005 by FluXy
***************************************************************************/
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#include "include/globals.h"
/* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
cAnimation :: cAnimation( double posx, double posy, double nfading_speed ) : cSprite( NULL, posx, posy )
{
array = ARRAY_ANIM;
type = TYPE_ACTIVESPRITE;
spawned = 1;
fading_speed = nfading_speed;
counter = 0;
massive = 0;
}
cAnimation :: ~cAnimation( void )
{
images.clear();
}
void cAnimation :: Update( void )
{
// virtual
}
/* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
cAnimation_1 :: cAnimation_1( double posx, double posy, double nfading_speed /* = 1 */, unsigned int height /* = 40 */, unsigned int width /* = 20 */ ) : cAnimation( posx, posy, nfading_speed )
{
animtype = WHITE_BLINKING_POINTS;
images.push_back( GetImage( "animation/light_1/1.png" ) );
images.push_back( GetImage( "animation/light_1/2.png" ) );
images.push_back( GetImage( "animation/light_1/3.png" ) );
for( unsigned int i = 0; i < 4; i++ )
{
SDL_Rect rect;
rect.x = (Sint16)rand() % ( width );
rect.y = (Sint16)rand() % ( height );
rect.w = 0;
rect.h = 0;
rects.push_back( rect );
}
}
cAnimation_1 :: ~cAnimation_1( void )
{
rects.clear();
}
void cAnimation_1 :: Update( void )
{
if( !visible )
{
return;
}
counter += Framerate.speedfactor * fading_speed;
// Update the fixed points
for( unsigned int i = 0; i < 4; i++ )
{
switch( i )
{
case 0:
{
if( counter < 3 )
{
SetImage( NULL );
}
else if( counter < 6 )
{
SetImage( images[0] );
}
else if( counter < 9 )
{
SetImage( images[1] );
}
else if( counter < 12 )
{
SetImage( images[0] );
}
break;
}
case 1:
{
if( counter < 3 )
{
SetImage( images[0] );
}
else if( counter < 6 )
{
SetImage( images[1] );
}
else if( counter < 9 )
{
SetImage( images[2] );
}
else if( counter < 12 )
{
SetImage( images[1] );
}
break;
}
case 2:
{
if( counter < 3 )
{
SetImage( images[1] );
}
else if( counter < 6 )
{
SetImage( images[2] );
}
else if( counter < 9 )
{
SetImage( images[0] );
}
else if( counter < 12 )
{
SetImage( NULL );
}
break;
}
case 3:
{
if( counter < 3 )
{
SetImage( images[0] );
}
else if( counter < 6 )
{
SetImage( images[1] );
}
else if( counter < 9 )
{
SetImage( images[0] );
}
else if( counter < 12 )
{
SetImage( images[0] );
}
break;
}
default:
{
break;
}
}
if( image )
{
SDL_Rect r = rects[i];
r.x -= (Sint16)( cameraposx - posx );
r.y -= (Sint16)( cameraposy - posy );
r.w = image->w;
r.h = image->h;
SDL_BlitSurface( image, NULL, screen, &r );
}
if( counter > 11 || counter < 0 )
{
visible = 0;
}
}
}
cAnimation_2 :: cAnimation_2( double posx, double posy, double nfading_speed /* = 1 */, unsigned int power /* = 5 */ ) : cAnimation( posx, posy, nfading_speed )
{
animtype = RED_FIRE_EXPLOSION;
images.push_back( GetImage( "animation/fire_1/4.png" ) );
images.push_back( GetImage( "animation/fire_1/3.png" ) );
images.push_back( GetImage( "animation/fire_1/2.png" ) );
images.push_back( GetImage( "animation/fire_1/1.png" ) );
for( unsigned int i = 0; i < power; i++ )
{
tAnimation_2_item temp;
temp.posx = 0;
temp.posy = 0;
temp.speed_x = ( (double)( rand() % ( 50 ) - 25 ) ) / 10;
temp.speed_y = ( (double)( rand() % ( 50 ) - 25 ) ) / 10;
temp.counter = 8 + rand() % ( 5 );
Objects.push_back( temp );
}
}
cAnimation_2 :: ~cAnimation_2( void )
{
Objects.clear();
}
void cAnimation_2 :: Update( void )
{
if( !visible )
{
return;
}
counter += Framerate.speedfactor * fading_speed;
for( unsigned int i = 0; i < Objects.size(); i++ )
{
Objects[i].posx += Objects[i].speed_x;
Objects[i].posy += Objects[i].speed_y;
if( Objects[i].counter > 8 )
{
SetImage( images[0] );
}
else if( Objects[i].counter > 5 )
{
SetImage( images[1] );
}
else if( Objects[i].counter > 3 )
{
SetImage( images[2] );
}
else if( Objects[i].counter > 0 )
{
SetImage( images[3] );
}
if( image )
{
SDL_Rect r;
r.x = (Sint16)( Objects[i].posx - ( cameraposx - posx ) );
r.y = (Sint16)( Objects[i].posy - ( cameraposy - posy ) );
r.w = rect.w;
r.h = rect.h;
SDL_BlitSurface( image, NULL, screen, &r );
}
Objects[i].counter -= Framerate.speedfactor * fading_speed;
}
if( counter > 11 || counter < 0 )
{
visible = 0;
}
}
/* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
cAnimationManager :: cAnimationManager( void )
{
Objects.clear();
}
cAnimationManager ::~cAnimationManager( void )
{
DeleteAll();
}
void cAnimationManager :: Update( void )
{
for( unsigned int i = 0; i < Get_Size(); i++ )
{
if( !Objects[i] )
{
continue;
}
Objects[i]->Update();
if( !Objects[i]->visible ) // if animation has ended delete the animation spite
{
Delete( i );
}
}
}
void cAnimationManager :: Add( double posx, double posy, double fading_speed /* = 1 */, AnimationEffect animtype /* = WHITE_BLINKING_POINTS */ )
{
cAnimation *temp = NULL;
if( animtype == WHITE_BLINKING_POINTS )
{
temp = new cAnimation_1( posx, posy, fading_speed );
}
else if( animtype == RED_FIRE_EXPLOSION )
{
temp = new cAnimation_2( posx, posy, fading_speed );
}
else
{
printf( "Invalid Animation Type : %d\n", animtype );
return;
}
Add( temp );
}
void cAnimationManager :: Add( cAnimation *AnimationObject )
{
if( !AnimationObject )
{
return;
}
Objects.push_back( AnimationObject );
}
void cAnimationManager :: Delete( unsigned int num )
{
if( num > Get_Size() )
{
return;
}
delete Objects[num];
Objects[num] = NULL;
Objects.erase( Objects.begin() + num );
}
void cAnimationManager :: DeleteAll( void )
{
if( !Get_Size() )
{
return;
}
for( unsigned int i = 0; i < Get_Size(); i++ )
{
if( Objects[i] )
{
delete Objects[i];
Objects[i] = NULL;
}
}
Objects.clear();
}
unsigned int cAnimationManager :: Get_Size( void )
{
return Objects.size();
}
|
[
"rinco@ff2c0c17-07fa-0310-a4bd-d48831021cb5"
] |
[
[
[
1,
369
]
]
] |
9f5e3b33f4839076c974a7cedc8a4bc0a7efd9dc
|
447a1817531f5eff55925709ff1cdde37033cf79
|
/src/core/ilogholder.h
|
b783bfb9a966350435c003e444ce16c2cd51fa1d
|
[] |
no_license
|
Kazade/kazengine
|
63276feef92f7daae5ac10563589bb5b87233644
|
0723eb6f22e651f9ea2d110b00b3f4c5d94465d5
|
refs/heads/master
| 2020-03-31T12:12:58.501020 | 2008-08-14T20:14:44 | 2008-08-14T20:14:44 | 32,983 | 4 | 1 | null | null | null | null |
UTF-8
|
C++
| false | false | 404 |
h
|
#ifndef ILOGHOLDER_H_INCLUDED
#define ILOGHOLDER_H_INCLUDED
#include <tr1/memory>
#include "utilities/logger.h"
using std::tr1::shared_ptr;
class ILogHolder {
public:
virtual ~ILogHolder() {}
void setLog(shared_ptr<Logger> log) { m_Logger = log; }
private:
shared_ptr<Logger> m_Logger;
protected:
shared_ptr<Logger> getLog() { return m_Logger; }
};
#endif // ILOGHOLDER_H_INCLUDED
|
[
"luke@helium.(none)"
] |
[
[
[
1,
21
]
]
] |
f2ba69cb7a417da5ac62b7aae7f7709b0bdf6bb7
|
ea12fed4c32e9c7992956419eb3e2bace91f063a
|
/zombie/code/renaissance/rnsgameplay/src/ncpopulatorarea/ncpopulatorarea.cc
|
117ac1368b2d399e7a8955c94a3e0c9dc97724f4
|
[] |
no_license
|
ugozapad/TheZombieEngine
|
832492930df28c28cd349673f79f3609b1fe7190
|
8e8c3e6225c2ed93e07287356def9fbdeacf3d6a
|
refs/heads/master
| 2020-04-30T11:35:36.258363 | 2011-02-24T14:18:43 | 2011-02-24T14:18:43 | null | 0 | 0 | null | null | null | null |
UTF-8
|
C++
| false | false | 6,051 |
cc
|
#include "precompiled/pchrnsgameplay.h"
//------------------------------------------------------------------------------
// ncpopulatorarea.cc
// (C) Conjurer Services, S.A. 2006
//------------------------------------------------------------------------------
#include "ncpopulatorarea/ncpopulatorarea.h"
#include "mathlib/polygon.h"
#include "nspatial/nspatialserver.h"
#include "zombieentity/nctransform.h"
//------------------------------------------------------------------------------
nNebulaComponentObject(ncPopulatorArea,nComponentObject);
//------------------------------------------------------------------------------
/**
Constructor
*/
ncPopulatorArea::ncPopulatorArea() :
area(0),
spawner(0),
maxInhabitants(10),
maxRadius(0.f)
{
// empty
}
//------------------------------------------------------------------------------
/**
Destructor
*/
ncPopulatorArea::~ncPopulatorArea()
{
this->ReleaseArea();
this->ReleaseTable();
}
//------------------------------------------------------------------------------
/**
InitInstance
*/
void
ncPopulatorArea::InitInstance(nObject::InitInstanceMsg /*initType*/)
{
this->CalculateMaxRadius();
}
//------------------------------------------------------------------------------
/**
SetArea
*/
void
ncPopulatorArea::SetArea (const polygon* poly)
{
this->ReleaseArea();
this->area = n_new (polygon);
this->area->Copy (*poly);
this->CalculateMaxRadius();
}
//------------------------------------------------------------------------------
/**
ReleaseArea
*/
void
ncPopulatorArea::ReleaseArea()
{
n_delete (this->area);
this->area = 0;
}
//------------------------------------------------------------------------------
/**
ReleaseTable
*/
void
ncPopulatorArea::ReleaseTable()
{
for ( int i=0; i<this->spawnTable.Size(); i++ )
{
nSpawnItem* item = this->spawnTable[i];
n_delete (item);
item = 0;
}
this->spawnTable.Clear();
}
//------------------------------------------------------------------------------
/**
IsInside
*/
bool
ncPopulatorArea::IsInside (const vector3& point) const
{
n_assert(this->area);
vector3 aux(point);
aux.y = 0.f;
return this->area && this->area->IsPointInside (aux);
}
//------------------------------------------------------------------------------
/**
CalculateMaxRadius
*/
void
ncPopulatorArea::CalculateMaxRadius()
{
if ( this->area )
{
// First, get the max distance from the center to every single vertex
vector3 center = this->area->Midpoint();
float max = 0.f;
for ( int i=0; i<this->area->GetNumVertices(); i++ )
{
vector3 vertex = this->area->GetVertex(i);
float distance = (vertex - center).len();
if ( distance > max )
{
max = distance;
}
}
this->maxRadius = max;
}
}
//------------------------------------------------------------------------------
/**
AddSpawnItem
*/
bool
ncPopulatorArea::AddSpawnItem (const nString& breed, int needed)
{
nSpawnItem* item = this->FindSpawnItem (breed);
bool added = item != 0;
if ( item != 0 )
{
item = n_new (nSpawnItem);
item->name = breed;
item->needed = needed;
item->totals = needed;
this->spawnTable.Append (item);
}
return added;
}
//------------------------------------------------------------------------------
/**
ChangeSpawnItem
*/
bool
ncPopulatorArea::ChangeSpawnItem (const nString& breed, int needed)
{
nSpawnItem* item = this->FindSpawnItem (breed);
bool exists = item != 0;
if ( exists )
{
item->needed = needed;
item->totals = needed;
}
return exists;
}
//------------------------------------------------------------------------------
/**
RemoveSpawnItem
*/
bool
ncPopulatorArea::RemoveSpawnItem (const nString& breed)
{
bool done = false;
for ( int i=0; i<this->spawnTable.Size() && !done; i++ )
{
nSpawnItem* item = this->spawnTable[i];
if ( item->name == breed )
{
this->spawnTable.Erase(i);
n_delete (item);
}
}
return done;
}
//------------------------------------------------------------------------------
/**
FindSpawnItem
*/
ncPopulatorArea::nSpawnItem*
ncPopulatorArea::FindSpawnItem (const nString& breed) const
{
nSpawnItem* item = 0;
for ( int i=0; i<this->spawnTable.Size() && !item; i++ )
{
nSpawnItem* elem = this->spawnTable[i];
if ( elem->name == breed )
{
item = elem;
}
}
return item;
}
//------------------------------------------------------------------------------
/**
GetNumberIndividuals
*/
int
ncPopulatorArea::GetNumberIndividuals (const nString& breed) const
{
n_assert(this->area);
int numEntities = 0;
if ( this->area )
{
// Search all entities inside the area
nArray<nEntityObject*> entities;
vector3 pos = this->area->Midpoint();
sphere sph (pos, this->maxRadius);
nSpatialServer::Instance()->GetEntitiesByPos (sph, &entities);
for ( int i=0; i<entities.Size(); i++ )
{
nEntityObject* entity = entities[i];
if ( entity && entity->IsA (breed.Get()) )
{
ncTransform* transform = entity->GetComponentSafe <ncTransform>();
n_assert(transform);
if ( transform )
{
vector3 pos = transform->GetPosition();
pos.y = 0.f;
if ( this->area->IsPointInside(pos) )
{
numEntities++;
}
} // if ( transform )
}
} // for ( int i...)
}
return numEntities;
}
//------------------------------------------------------------------------------
/**
GetBreeds
*/
void
ncPopulatorArea::GetBreeds (nArray<nSpawnItem*>& breeds) const
{
breeds.Reset();
for ( int i=0; i<this->spawnTable.Size(); i++ )
{
nSpawnItem* spawnItem = this->spawnTable[i];
breeds.Append (spawnItem);
}
}
//------------------------------------------------------------------------------
// EOF
//------------------------------------------------------------------------------
|
[
"magarcias@c1fa4281-9647-0410-8f2c-f027dd5e0a91"
] |
[
[
[
1,
285
]
]
] |
e95226dbdd16cdd762c732c761771c8e73550e7c
|
155c4955c117f0a37bb9481cd1456b392d0e9a77
|
/Tessa/TessaInstructions/ArrayGetElementInstruction.h
|
14e16317589f4a2cc7c0e31272d4d30daf13c8fc
|
[] |
no_license
|
zwetan/tessa
|
605720899aa2eb4207632700abe7e2ca157d19e6
|
940404b580054c47f3ced7cf8995794901cf0aaa
|
refs/heads/master
| 2021-01-19T19:54:00.236268 | 2011-08-31T00:18:24 | 2011-08-31T00:18:24 | null | 0 | 0 | null | null | null | null |
UTF-8
|
C++
| false | false | 219 |
h
|
namespace TessaInstructions {
class ArrayGetElementInstruction : public ArrayAccessInstruction {
private:
public:
ArrayGetElementInstruction(TessaInstruction* receiverObject, TessaInstruction* index);
};
}
|
[
"[email protected]"
] |
[
[
[
1,
7
]
]
] |
422ec2cd882651ac63a972ba41b9c01951a1e77b
|
dfcf7977788155f84636248baf190c58673035ef
|
/demo/CppStub_demo.cpp
|
d994cce5961925614d374175a91191453d460085
|
[] |
no_license
|
sinojelly/cppstub
|
9f2de17322ef9d0e9e3e5b3cb1fb92d4f4fe3fed
|
909845b826d24baab64c7a806935b76139268020
|
refs/heads/master
| 2020-05-27T10:52:14.116335 | 2009-09-25T06:21:24 | 2009-09-25T06:21:24 | 33,052,342 | 1 | 0 | null | null | null | null |
WINDOWS-1252
|
C++
| false | false | 692 |
cpp
|
#include <iostream.h>
#include "ICppStub.h"
#pragma comment(lib, "..\\lib\\Debug\\CppStub.lib")
void Test()
{
cout<<"In Test \n";
}
void Test_stub()
{
cout<<"In Test_stub \n";
}
int memcpy_stub()
{
cout << "in memcpy_stub \n";
return 0;
}
int main()
{
cout << "Before SET_STUB: \n";
Test();
cout << "\nSET_STUB ... \n";
SET_STUB(Test, Test_stub);
SET_STUB(memcpy, memcpy_stub);
cout << "\nAfter SET_STUB: \n";
Test();
memcpy((void *)0, (const void *)0, 0);
// ͉˕
cout << "\nCLR_ALL_STUB ... \n";
CLR_ALL_STUB();
cout << "\nAfter CLR_ALL_STUB: \n";
Test();
//memcpy((void *)0, (const void *)0, 0);
return 0;
}
|
[
"chenguodong@localhost"
] |
[
[
[
1,
46
]
]
] |
ee11825350e6338079650f70bc933baafe7fae00
|
16d8b25d0d1c0f957c92f8b0d967f71abff1896d
|
/FakeClient/FakeChunkHandler.cpp
|
49d94b9d540b02433feef7344c6addfca73c5e14
|
[] |
no_license
|
wlasser/oonline
|
51973b5ffec0b60407b63b010d0e4e1622cf69b6
|
fd37ee6985f1de082cbc9f8625d1d9307e8801a6
|
refs/heads/master
| 2021-05-28T23:39:16.792763 | 2010-05-12T22:35:20 | 2010-05-12T22:35:20 | null | 0 | 0 | null | null | null | null |
UTF-8
|
C++
| false | false | 2,496 |
cpp
|
///*
//Copyright 2008 Julian Bangert aka masterfreek64
//This file is part of OblivionOnline.
//
//OblivionOnline is free software; you can redistribute it and/or modify
//it under the terms of the GNU General Public License as published by
//the Free Software Foundation; either version 3 of the License, or
//(at your option) any later version.
//
//OblivionOnline is distributed in the hope that it will be useful,
//but WITHOUT ANY WARRANTY; without even the implied warranty of
//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
//GNU General Public License for more details.
//
//You should have received a copy of the GNU General Public License
//along with this program. If not, see <http://www.gnu.org/licenses/>.
//*/
#include "FakeClient.h"
#if 0
size_t ChunkHandler::HandleChatChunk(IOStream &IOStream::Instance(),EntityManager *entities,InPacket *packet, BYTE* chunkdata,size_t len ,UINT32 FormID,BYTE Status)
{
(&IOStream::Instance()) << Chat << (char *)(chunkdata +2 + sizeof(unsigned short));
return (sizeof(unsigned short)+ sizeof(unsigned short) + sizeof(unsigned short) + (len < *(unsigned short *)(chunkdata +2) ) ? (len) : *(unsigned short *)(chunkdata +2));
}
size_t ChunkHandler::HandlePlayerIDChunk(IOStream &IOStream::Instance(),EntityManager*entities,InPacket *pkg, BYTE* chunkdata,size_t len ,UINT32 FormID,BYTE Status)
{
g_fake->SetPlayerID(*(UINT32 *)(chunkdata + 2));
&IOStream::Instance() << GameMessage << "Player No " << *(UINT32 *)(chunkdata + 2) << endl;
//NetSendName(outnet.GetPacket(),gClient->GetLocalPlayer(),STATUS_PLAYER,(BYTE *)(*g_thePlayer)->GetName(),strlen((*g_thePlayer)->GetName()));
return GetMinChunkSize(PlayerID) + sizeof(unsigned short);
}
size_t ChunkHandler::HandleClientTypeChunk(IOStream &IOStream::Instance(),EntityManager*entities,InPacket *pkg, BYTE* chunkdata,size_t len ,UINT32 FormID,BYTE Status)
{
if((chunkdata + 2) > 0)
{
g_fake->SetIsMasterClient(true);
g_fake->GetIO() << BootMessage << " Received Master Client" <<endl;
}
else
{
g_fake->SetIsMasterClient(false);
g_fake->GetIO() << BootMessage << " Received Passive Client" <<endl;
}
return GetMinChunkSize(ClientType) + sizeof(unsigned short);
}
size_t ChunkHandler::HandleVersionChunk(IOStream &IOStream::Instance(),EntityManager*entities,InPacket *pkg,BYTE* chunkdata,size_t len ,UINT32 FormID,BYTE Status)
{
return GetMinChunkSize(PkgChunk::Version) + sizeof(unsigned short);
}
#endif
|
[
"obliviononline@2644d07b-d655-0410-af38-4bee65694944"
] |
[
[
[
1,
50
]
]
] |
878523f77c15034f1a1d6b1c2c5dc898297ec263
|
d81bbe5a784c804f59f643fcbf84be769abf2bc9
|
/Gosling/include/GosUtil.h
|
20bd0062e17a20427cda8a37e37b3141e372ae73
|
[] |
no_license
|
songuke/goslingviz
|
9d071691640996ee88171d36f7ca8c6c86b64156
|
f4b7f71e31429e32b41d7a20e0c151be30634e4f
|
refs/heads/master
| 2021-01-10T03:36:25.995930 | 2010-04-16T08:49:27 | 2010-04-16T08:49:27 | 36,341,765 | 0 | 0 | null | null | null | null |
UTF-8
|
C++
| false | false | 2,083 |
h
|
#ifndef _GOS_UTIL_
#define _GOS_UTIL_
#include <stdlib.h>
#include <math.h>
#include <boost/thread.hpp>
#include <stdio.h>
#include <stdarg.h>
namespace Gos
{
#define RENZODERER_API
#define mmax(a, b) a > b ? a : b
#define mmin(a, b) a < b ? a : b
#define safeFree(x) if(x) { free(x); x = 0; }
#define safeDel(x) if(x) { delete x; x = 0; }
#define safeDelArray(x) if(x) { delete [] x; x = 0; }
// constant
const double from255to1 = 0.003921568627450980392156862745098;
// integer swap
#define SWAP(x, y) (x ^= y ^= x ^= y)
// image
struct Size {
int width;
int height;
};
enum PixelFormat {
rzRGB8,
rzRGBA8,
rzRGB16,
rzRGBA16,
rzRGB32,
rzRGBA32
};
extern "C" {
void rzInfo(const char*, ...);
void rzWarning(const char*, ...);
void rzError(const char*, ...);
void rzSevere(int exitCode, const char*, ...);
RENZODERER_API inline void rzSevere(int exitCode, const char* str, ...) {
String msg;
msg.append("SEVERE: ");
msg.append(str);
va_list ap;
va_start(ap, str);
//Log::instance()->write(msg.c_str(), ap);
vfprintf(stderr, msg.c_str(), ap);
va_end(ap);
exit(exitCode);
}
/* rzAssert */
#define EXIT_ASSERT 10
#ifdef NDEBUG
#define rzAssert(expr) ((void)0)
#else
#define rzAssert(expr) \
((expr) ? (void)0 : rzSevere(EXIT_ASSERT, "Assertion " #expr " failed in %s, line %d", __FILE__, __LINE__))
#endif
};
inline double random(double _min, double _max) {
//double val = (1.0 * rand() / RAND_MAX) * (_max - _min) + _min;
//printf("%f\n", val);
//return val;
return (1.0 * rand() / RAND_MAX) * (_max - _min) + _min;
}
inline int randomInteger(int _min, int _max) {
return rand() % (_max - _min + 1) + _min;
}
inline double log2(double x) {
return log(x) / log(2.0);
}
inline void sleepMiliseconds(int milis) {
boost::system_time time = boost::get_system_time();
time += boost::posix_time::millisec(milis);
boost::thread::sleep(time);
}
}
#endif
|
[
"songuke@00dcdb3d-b287-7056-8bd8-84a1afe327dc"
] |
[
[
[
1,
94
]
]
] |
8a455f73ff1fbe8766e1f0077dc2475dba8786c7
|
d609fb08e21c8583e5ad1453df04a70573fdd531
|
/trunk/OpenXP/系统组件/dllmain.cpp
|
5019306a60294011d12f1b24a10f7b04a989db9f
|
[] |
no_license
|
svn2github/openxp
|
d68b991301eaddb7582b8a5efd30bc40e87f2ac3
|
56db08136bcf6be6c4f199f4ac2a0850cd9c7327
|
refs/heads/master
| 2021-01-19T10:29:42.455818 | 2011-09-17T10:27:15 | 2011-09-17T10:27:15 | 21,675,919 | 0 | 1 | null | null | null | null |
GB18030
|
C++
| false | false | 1,543 |
cpp
|
// dllmain.cpp : 定义 DLL 的初始化例程。
//
#include "stdafx.h"
#include <afxwin.h>
#include <afxdllx.h>
#ifdef _DEBUG
#define new DEBUG_NEW
#endif
static AFX_EXTENSION_MODULE SystemModuleDLL = { NULL, NULL };
HINSTANCE g_hInstance = NULL; //DLL实例句柄
extern "C" int APIENTRY
DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID lpReserved)
{
// 如果使用 lpReserved,请将此移除
UNREFERENCED_PARAMETER(lpReserved);
if (dwReason == DLL_PROCESS_ATTACH)
{
TRACE0("SystemModule.DLL 正在初始化!\n");
// 扩展 DLL 一次性初始化
if (!AfxInitExtensionModule(SystemModuleDLL, hInstance))
return 0;
// 将此 DLL 插入到资源链中
// 注意: 如果此扩展 DLL 由
// MFC 规则 DLL (如 ActiveX 控件)隐式链接到,
// 而不是由 MFC 应用程序链接到,则需要
// 将此行从 DllMain 中移除并将其放置在一个
// 从此扩展 DLL 导出的单独的函数中。使用此扩展 DLL 的
// 规则 DLL 然后应显式
// 调用该函数以初始化此扩展 DLL。否则,
// CDynLinkLibrary 对象不会附加到
// 规则 DLL 的资源链,并将导致严重的
// 问题。
new CDynLinkLibrary(SystemModuleDLL);
if (g_hInstance == NULL)
g_hInstance = hInstance;
}
else if (dwReason == DLL_PROCESS_DETACH)
{
TRACE0("SystemModule.DLL 正在终止!\n");
// 在调用析构函数之前终止该库
AfxTermExtensionModule(SystemModuleDLL);
}
return 1; // 确定
}
|
[
"[email protected]@f92b348d-55a1-4afa-8193-148a6675784b"
] |
[
[
[
1,
54
]
]
] |
36e42e6bf5304e7fe4d7b49b786e64780a101f9d
|
55196303f36aa20da255031a8f115b6af83e7d11
|
/include/bikini/flash/renderer.hpp
|
3b9c0fff35736eed81ba1a95f61a62b3a5a1c201
|
[] |
no_license
|
Heartbroken/bikini
|
3f5447647d39587ffe15a7ae5badab3300d2a2ff
|
fe74f51a3a5d281c671d303632ff38be84d23dd7
|
refs/heads/master
| 2021-01-10T19:48:40.851837 | 2010-05-25T19:58:52 | 2010-05-25T19:58:52 | 37,190,932 | 0 | 0 | null | null | null | null |
UTF-8
|
C++
| false | false | 1,831 |
hpp
|
/*---------------------------------------------------------------------------------------------*//*
Binary Kinematics 3 - C++ Game Programming Library
Copyright (C) 2008-2010 Viktor Reutskyy
[email protected]
*//*---------------------------------------------------------------------------------------------*/
#pragma once
struct renderer
{
inline uint viewport_ID() const { m_viewport_ID; }
inline void set_viewport_ID(uint _viewport_ID) { m_viewport_ID = _viewport_ID; }
renderer(video &_video);
~renderer();
bool create();
void destroy();
uint create_texture(uint _format, pointer _data, uint _width, uint _height, uint _pitch);
void destroy_texture(uint _ID);
uint create_mesh(const short2 _points[], uint _count);
void destroy_mesh(uint _ID);
bool begin_render(const color &_background, const rect &_viewport);
void set_xform(const xform &_xform);
void set_color(const color &_color);
void set_texture(uint _ID, const xform &_txform);
void draw_tristrip(const short2* _points, uint _count);
void draw_mesh(uint _ID);
void end_render();
private:
video &m_video;
uint m_viewport_ID;
vo::vformat::info m_vformat;
uint m_vformat_ID;
vo::memreader::info m_memreader;
uint m_memreader_ID;
vo::vbuffer::info m_vbuffer;
uint m_vbuffer_ID;
vo::vshader::info m_vshader;
uint m_vshader_ID;
vo::pshader::info m_pshader;
uint m_pshader_ID;
vo::vbufset::info m_vbufset;
uint m_vbufset_ID;
vo::states::info m_states;
uint m_states_ID;
vo::texture::info m_texture;
vo::texset::info m_texset;
struct texture { uint width, height, texture_ID, memreader_ID, texset_ID; };
pool_<texture> m_textures;
uint m_texset_ID;
uint m_deftexset_ID;
struct mesh { uint size, vbuffer_ID, memreader_ID, vbufset_ID; };
pool_<mesh> m_meshes;
};
|
[
"[email protected]",
"viktor.reutskyy@68c2588f-494f-0410-aecb-65da31d84587"
] |
[
[
[
1,
3
],
[
6,
10
],
[
58,
58
]
],
[
[
4,
5
],
[
11,
57
]
]
] |
979eb2c5b4d07f785b06a5fcbea8a599dcd6563b
|
2112057af069a78e75adfd244a3f5b224fbab321
|
/branches/ref1/src-root/src/ireon_ws/world/ws_world.cpp
|
a6421254e0334719209cd7101913138cd2d3d14d
|
[] |
no_license
|
blockspacer/ireon
|
120bde79e39fb107c961697985a1fe4cb309bd81
|
a89fa30b369a0b21661c992da2c4ec1087aac312
|
refs/heads/master
| 2023-04-15T00:22:02.905112 | 2010-01-07T20:31:07 | 2010-01-07T20:31:07 | null | 0 | 0 | null | null | null | null |
UTF-8
|
C++
| false | false | 17,766 |
cpp
|
/* Copyright (C) 2005 ireon.org developers council
* $Id: world.cpp 529 2006-03-13 18:00:24Z llyeli $
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA.
*/
/**
* @file world.cpp
* World manager
*/
#include "stdafx.h"
#include "config.h"
#include "world_app.h"
#include "world/ws_world.h"
#include "world/world_char_player.h"
#include "world/world_char_mob.h"
#include "db/world_mob_prototype.h"
#include "resource/resource_manager.h"
#include "resource/image.h"
CWorld* CWorld::m_singleton = 0;
int64 CWorld::m_pulse = 0;
bool CWorld::m_mobMovePulse;
bool CWorld::m_playerMovePulse;
bool CWorld::m_regenPulse;
bool CWorld::m_processOutputPulse;
bool CWorld::m_repopPulse;
uint WorldPage::m_size = 1;
float WorldPage::m_scale = 1;
WorldPage::WorldPage(uint x, uint z):
m_x(x),
m_z(z),
m_heightData(NULL),
m_normalData(NULL)
{
}
WorldPage::WorldPage(const WorldPage &p):
m_heightData(NULL),
m_normalData(NULL)
{
*this = p;
};
WorldPage::~WorldPage()
{
if( m_heightData )
delete[] m_heightData;
if( m_normalData )
delete[] m_normalData;
};
WorldPage& WorldPage::operator=(const WorldPage& p)
{
if( m_heightData )
delete[] m_heightData;
if( m_normalData )
delete[] m_normalData;
m_x = p.m_x;
m_z = p.m_z;
if( p.m_heightData )
{
m_heightData = new float[m_size*m_size];
memcpy(m_heightData,p.m_heightData,m_size*m_size*sizeof(float));
};
if( p.m_normalData )
{
m_normalData = new Vector3[m_size*m_size*2];
memcpy(m_normalData,p.m_normalData,m_size*m_size*sizeof(Vector3));
};
return *this;
};
float WorldPage::heightAt(const float& x, const float& z) const
{
const float localXf = x / m_scale;
const float localZf = z / m_scale;
const int localX = static_cast<int>(localXf);
const int localZ = static_cast<int>(localZf);
assert( !(localX < 0 || localX >= m_size-1 || localZ < 0 || localZ >= m_size-1));
// find the 4 heights around the point
const float bottom_right_y = m_heightData[localX + localZ * m_size];
const float bottom_left_y = m_heightData[localX + 1 + localZ * m_size];
const float top_right_y = m_heightData[localX + (localZ + 1) * m_size];
const float top_left_y = m_heightData[localX + 1 + (localZ + 1) * m_size];
const float z_pct = (localZf - localZ);
float x_pct = (localXf - localX);
// TL-----TR 1.0
// | / |
// | / | .
// | / | .
// | / | . ^
// | / | |
// BL-----BR 0.0 z
// 1.0 ... 0.0
//
// < - x
if (x_pct > 1 - z_pct)
{
// This point is on the upper-left tri
const float y1 = bottom_left_y * (1-z_pct) + top_left_y * z_pct;
const float y2 = bottom_left_y * (1-z_pct) + top_right_y * z_pct;
if (z_pct > 0)
x_pct = (x_pct - (1-z_pct)) / z_pct;
return y1 * x_pct + y2 * (1-x_pct);
} // if (x_pct > 1 - z_pct)
else
{
// This point is on the lower-right tri
const float y1 = bottom_left_y * (1-z_pct) + top_right_y * z_pct;
const float y2 = bottom_right_y * (1-z_pct) + top_right_y * z_pct;
if (z_pct < 1)
x_pct = x_pct / (1-z_pct);
return y1 * x_pct + y2 * (1-x_pct);
}
};
const Vector3& WorldPage::normalAt(const uint& x, const uint& z, bool upperTriangle) const
{
assert( !(x >= m_size || z >= m_size) );
return m_normalData[(x + z * m_size) * 2 + (upperTriangle ? 1 : 0)];
};
float WorldPage::vertexHeightAt(const uint& x, const uint& z) const
{
assert( !(x > m_size || x > m_size));
assert(m_heightData);
return m_heightData[x + z * m_size];
};
void WorldPage::computeNormals()
{
/// Computing of normals taken from PagingLandScapeSceneManager
if( !m_normalData )
m_normalData = new Vector3[m_size*m_size*2];
const float divider = 1.0f / m_scale;
//const float divider = static_cast <float> (m_size - 1) / CWorld::instance()->getMaxHeight();
uint x,z;
/// Upper triangle
for( x = 0; x < m_size; ++x )
for( z = 0; z < m_size; ++z )
{
float h1,h2,h3;
WorldPage* page;
bool addX = false, addZ = false;
if( x == m_size - 1 )
addX = true;
if( z == m_size - 1 )
addZ = true;
page = CWorld::instance()->getPage(m_x + (addX ? 1 : 0), m_z + (addZ ? 1 : 0) );
if( addZ )
{
h1 = page ? page->vertexHeightAt(x,0) : 0;
if( addX )
h3 = page ? page->vertexHeightAt(0,0) : 0;
else
h3 = page ? page->vertexHeightAt(x+1,0) : 0;
}
else
{
h1 = vertexHeightAt(x,z + 1);
if( addX )
h3 = page ? page->vertexHeightAt(0,z+1) : 0;
else
h3 = page ? page->vertexHeightAt(x+1,z+1) : 0;
}
if( addX )
h2 = page ? page->vertexHeightAt(0,z) : 0;
else
h2 = vertexHeightAt(x+1,z);
Vector3 result((h1 - h3) * divider,
1.0f,
(h2 - h3) * divider);
result.normalise ();
m_normalData[(x + z * m_size) * 2 + 1] = result;
}
/// Bottom triangle
for( x = 0; x < m_size; ++x )
for( z = 0; z < m_size; ++z )
{
float h1,h2,h3;
WorldPage* page;
bool addX = false, addZ = false;
if( x == m_size - 1 )
addX = true;
if( z == m_size - 1 )
addZ = true;
page = CWorld::instance()->getPage(m_x + (addX ? 1 : 0), m_z + (addZ ? 1 : 0) );
if( addZ )
h2 = page ? page->vertexHeightAt(x,0) : 0;
else
h2 = vertexHeightAt(x,z + 1);
if( addX )
h1 = page ? page->vertexHeightAt(0,z) : 0;
else
h1 = vertexHeightAt(x+1,z);
h3 = vertexHeightAt(x,z);
Vector3 result((h3 - h1) * divider,
1.0f,
(h3 - h2) * divider);
result.normalise ();
m_normalData[(x + z * m_size) * 2] = result;
}
};
void WorldPage::insertCharacter(const CharacterPtr& ch)
{
removeCharacter(ch);
m_players.push_back(ch);
};
void WorldPage::removeCharacter(const CharacterPtr& ch)
{
std::list<CharacterPtr>::iterator it;
for( it = m_players.begin(); it != m_players.end(); ++it)
if( *it == ch )
{
m_players.erase(it);
break;
};
};
CWorld::CWorld()
{
};
CWorld::~CWorld()
{
};
bool CWorld::init()
{
if( !loadTerrain( CWorldApp::instance()->getSetting("/config/WorldCfg")) )
return false;
if( !loadMobPrototypes() )
return false;
CharMobPtr mob(new CWorldCharMob);
mob->m_id = 1 | MOB_ID_FLAG;
mob->m_startPos = Vector2(-20,-60);
mob->m_prototype = getMobPrototype(1);
insertCharMob(mob);
mob.reset(new CWorldCharMob);
mob->m_id = 2 | MOB_ID_FLAG;
mob->m_startPos = Vector2(-20,-120);
mob->m_prototype = getMobPrototype(2);
insertCharMob(mob);
mob.reset(new CWorldCharMob);
mob->m_id = 3 | MOB_ID_FLAG;
mob->m_startPos = Vector2(-50,-50);
mob->m_prototype = getMobPrototype(3);
insertCharMob(mob);
mob.reset(new CWorldCharMob);
mob->m_id = 4 | MOB_ID_FLAG;
mob->m_startPos = Vector2(-20,-70);
mob->m_prototype = getMobPrototype(4);
insertCharMob(mob);
mob.reset(new CWorldCharMob);
mob->m_id = 5 | MOB_ID_FLAG;
mob->m_startPos = Vector2(30,-80);
mob->m_prototype = getMobPrototype(5);
insertCharMob(mob);
return true;
};
bool CWorld::loadTerrain(const String& file)
{
CConfig cf;
cf.load(file);
m_width = StringConverter::parseInt(cf.getSetting("Width"));
m_height = StringConverter::parseInt(cf.getSetting("Height"));
m_pageSize = StringConverter::parseInt(cf.getSetting("PageSize"));
WorldPage::m_size = m_pageSize;
m_pageSize--; /// pages overlap
String name = cf.getSetting("LandScapeFileName");
String ext = cf.getSetting("LandScapeExtension");
float scaleX = StringConverter::parseReal(cf.getSetting("ScaleX"));
m_maxHeight = StringConverter::parseReal(cf.getSetting("ScaleY"));
float scaleZ = StringConverter::parseReal(cf.getSetting("ScaleZ"));
if( scaleX != scaleZ )
{
CLog::instance()->log(CLog::msgLvlError,_("Landcape page isn't square.\n"));
return false;
};
if( !m_width || !m_height || !scaleX || !m_maxHeight || name == "" || ext == "" || !m_pageSize )
{
CLog::instance()->log(CLog::msgLvlError,_("Not enough options in terrain config. Must be:\n Width, Height, PageSize, ScaleX, ScaleY, ScaleZ, LandScapeFileName, LandScapeExtension.\n"));
return false;
};
m_scale = (float)scaleZ / m_pageSize;
WorldPage::m_scale = m_scale;
m_invScale = (float)1/m_scale;
m_scaledPage = m_scale * m_pageSize;
m_maxUnscaledX = m_width * m_pageSize * 0.5f;
m_maxScaledX = m_maxUnscaledX * m_scale;
m_maxUnscaledZ = m_height * m_pageSize * 0.5f;
m_maxScaledZ = m_maxUnscaledZ * m_scale;
float scale = m_maxHeight / 256; /// It must be 255, but in plsm it's 256
CImage img;
for( uint x = 0; x < m_width; ++x )
for( uint z = 0; z < m_height; ++z )
{
WorldPage page(x,z);
String filename = name + "." + StringConverter::toString(x)
+ "." + StringConverter::toString(z) + "." + ext;
img.load(filename);
if( !img.getData() )
return false;
if( !img.getPixelSize() == 1 )
{
CLog::instance()->log(CLog::msgLvlError,_("Image format isn't 8 bit grayscale. File: '%s'.\n"),filename.c_str());
return false;
};
if( (img.getWidth() != (m_pageSize + 1)) || (img.getHeight() != (m_pageSize + 1)) )
{
CLog::instance()->log(CLog::msgLvlError,_("Terrain page must be %dx%d pixels. File: '%s'.\n"),m_pageSize + 1, m_pageSize + 1,filename.c_str());
return false;
};
page.m_heightData = new float[WorldPage::m_size * WorldPage::m_size];
for( uint i = 0; i < WorldPage::m_size; i++ )
for( uint j = 0; j < WorldPage::m_size; j++ )
page.m_heightData[i + j * WorldPage::m_size] = (float)img.getData()[i + j * WorldPage::m_size] * scale;
m_pages.insert(page);
};
computeNormals();
return true;
};
void CWorld::computeNormals()
{
std::set<WorldPage>::iterator it;
for( it = m_pages.begin(); it != m_pages.end(); ++it )
(const_cast<WorldPage&>(*it)).computeNormals();
};
bool CWorld::loadMobPrototypes()
{
CConfig cf;
cf.load("mobs.ini");
StringVector vec = cf.getMultiSetting("Prototype");
for( StringVector::iterator it = vec.begin(); it != vec.end(); ++it )
{
WorldMobProtPtr prot(new CWorldMobPrototype);
if( prot->load(*it) )
{
if( m_mobPrototypes.find(prot->getId()) != m_mobPrototypes.end() )
{
CLog::instance()->log(CLog::msgFlagResources,CLog::msgLvlError,"Double mob prototype identifier %d!\n",prot->getId());
continue;
}
m_mobPrototypes.insert(std::pair<uint,WorldMobProtPtr>(prot->getId(),prot));
CLog::instance()->log(CLog::msgFlagResources,CLog::msgLvlInfo,"Added mob prototype with id %d.\n",prot->getId());
}
}
return true;
};
WorldPage* CWorld::getPageByCoords(const float& x, const float& z)
{
return getPage((uint)(x + m_maxScaledX) / m_scaledPage,(uint)(z + m_maxScaledZ) / m_scaledPage);
}
WorldPage* CWorld::getPage(const uint x, const uint z)
{
WorldPage finder(0,0);
finder.m_x = x;
finder.m_z = z;
std::set<WorldPage>::iterator it = m_pages.find(finder);
if( it != m_pages.end() )
return const_cast<WorldPage*>(&(*it));
return NULL;
};
float CWorld::heightAt(const float& x, const float& z) const
{
WorldPage finder(0,0);
if( x + m_maxScaledX < 0 || z + m_maxScaledZ < 0 )
return 0.0;
finder.m_x = (uint)((x + m_maxScaledX) / m_scaledPage);
finder.m_z = (uint)((z + m_maxScaledZ) / m_scaledPage);
std::set<WorldPage>::const_iterator it = m_pages.find(finder);
if( it != m_pages.end() )
return (*it).heightAt(x + m_maxScaledX - (*it).m_x * m_scaledPage,z + m_maxScaledZ - (*it).m_z * m_scaledPage );
return 0.0;
};
const Vector3& CWorld::normalAt(const float& x, const float& z) const
{
WorldPage finder(0,0);
if( x + m_maxScaledX < 0 || z + m_maxScaledZ < 0 )
return Vector3::UNIT_Y;
finder.m_x = (uint)((x + m_maxScaledX) / m_scaledPage);
finder.m_z = (uint)((z + m_maxScaledZ) / m_scaledPage);
std::set<WorldPage>::const_iterator it = m_pages.find(finder);
if( it == m_pages.end() )
return Vector3::UNIT_Y;
float localX = x / m_scale;
float localZ = z / m_scale;
// adjust x and z to be local to page
localX -= (float)finder.m_x*m_pageSize - m_maxUnscaledX;
localZ -= (float)finder.m_z*m_pageSize - m_maxUnscaledZ;
// make sure x and z do not go outside the world boundaries
if (localX < 0)
localX = 0;
else if (localX >= m_pageSize)
localX = m_pageSize - 1;
if (localZ < 0)
localZ = 0;
else if (localZ >= m_pageSize)
localZ = m_pageSize - 1;
uint iX = static_cast<uint>(localX);
uint iZ = static_cast<uint>(localZ);
if( localX - iX > 1 - (localZ - iZ) )
return (*it).normalAt(iX, iZ, true); /// Upper triangle
else
return (*it).normalAt(iX, iZ, false);/// Bottom triangle
};
void CWorld::getPageIndices(const float& x, const float& z, uint& ix, uint& iz) const
{
ix = (x + m_maxScaledX) / m_scaledPage;
iz = (z + m_maxScaledZ) / m_scaledPage;
};
void CWorld::insertCharacter(const CharacterPtr &ch)
{
ch->m_ptr = ch;
ch->m_inWorld = true;
ch->onEnterWorld();
};
void CWorld::insertCharPlayer(const CharPlayerPtr& ch)
{
CLog::instance()->log(CLog::msgLvlInfo,"Insert player with id %d to world.\n",ch->getId());
m_players.insert(std::pair<uint,CharPlayerPtr>(ch->getId(),ch));
insertCharacter(ch);
};
void CWorld::insertCharMob(const CharMobPtr& mob)
{
CLog::instance()->log(CLog::msgLvlInfo,"Insert mob with id %d to world.\n",mob->getId());
m_mobs.insert(std::pair<uint,CharMobPtr>(mob->getId(),mob));
insertCharacter(mob);
};
void CWorld::removeCharPlayer(const CharPlayerPtr& ch)
{
removeCharPlayer(ch->getId());
};
void CWorld::removeCharPlayer(uint id)
{
CLog::instance()->log(CLog::msgLvlInfo,"Removing character with id %d from world.\n",id);
std::map<uint,CharPlayerPtr>::iterator it = m_players.find(id);
if( it != m_players.end() )
{
(*it).second->onLeaveWorld();
(*it).second->m_inWorld = false;
(*it).second->m_ptr.reset();
if( !m_walkingPlayers )
m_players.erase(it);
else
m_removePlayers.insert(id);
}
};
void CWorld::removeCharMob(const CharMobPtr& mob)
{
removeCharMob(mob->getId());
};
void CWorld::removeCharMob(uint id)
{
CLog::instance()->log(CLog::msgLvlInfo,"Removing mob with id %d from world.\n",id);
std::map<uint,CharMobPtr>::iterator it = m_mobs.find(id);
if( it != m_mobs.end() )
{
(*it).second->onLeaveWorld();
(*it).second->m_inWorld = false;
(*it).second->m_ptr.reset();
if( !m_walkingMobs )
m_mobs.erase(it);
else
m_removeMobs.insert(id);
}
};
CharacterPtr CWorld::findCharacter(uint id)
{
if (id & MOB_ID_FLAG)
return findCharMob(id);
else
return findCharPlayer(id);
}
CharPlayerPtr CWorld::findCharPlayer(uint id)
{
std::map<uint,CharPlayerPtr>::iterator it = m_players.find(id);
if( it != m_players.end() )
return (*it).second;
return CharPlayerPtr();
};
CharMobPtr CWorld::findCharMob(uint id)
{
std::map<uint,CharMobPtr>::iterator it = m_mobs.find(id);
if( it != m_mobs.end() )
return (*it).second;
return CharMobPtr();
};
void CWorld::update(int64 pulse)
{
if( m_pulse % 5 == 0 )
{
m_mobMovePulse = true;
m_repopPulse = true;
}
else
{
m_repopPulse = false;
m_mobMovePulse = false;
}
if( m_pulse % 5 == 1 )
m_playerMovePulse = true;
else
m_playerMovePulse = false;
if( m_pulse % 5 == 2 )
m_processOutputPulse = true;
else
m_processOutputPulse = false;
if( m_pulse % 50 == 0 )
m_regenPulse = true;
else
m_regenPulse = false;
m_walkingPlayers = true;
std::map<uint,CharPlayerPtr>::iterator it;
for( it = m_players.begin(); it != m_players.end(); ++it)
{
/// Update only if character is in world
if( (*it).second->m_ptr )
(*it).second->update(PULSE_TIME);
}
m_walkingPlayers = false;
std::set<uint>::iterator setIt;
for( setIt = m_removePlayers.begin(); setIt != m_removePlayers.end(); ++setIt )
m_players.erase(*setIt);
m_removePlayers.clear();
m_walkingMobs = true;
std::map<uint,CharMobPtr>::iterator mobIt;
for( mobIt = m_mobs.begin(); mobIt != m_mobs.end(); ++mobIt )
(*mobIt).second->update(PULSE_TIME);
m_walkingMobs = false;
for( setIt = m_removeMobs.begin(); setIt != m_removeMobs.end(); ++setIt )
m_mobs.erase(*setIt);
m_removeMobs.clear();
if( m_repopPulse )
{
std::multimap<int64,CharMobPtr>::iterator repop, next;
for( repop = m_repop.begin(); repop != m_repop.end(); repop = next )
{
next = repop;
++next;
if( (*repop).first <= m_pulse )
{
(*repop).second->repop();
insertCharMob((*repop).second);
m_repop.erase(repop);
}
}
}
};
void CWorld::addMobRepop(int64 pulse, const CharMobPtr &mob)
{
m_repop.insert(std::pair<int64,CharMobPtr>(pulse,mob));
};
WorldMobProtPtr CWorld::getMobPrototype(uint id)
{
std::map<uint,WorldMobProtPtr>::iterator it = m_mobPrototypes.find(id);
if( it != m_mobPrototypes.end() )
return (*it).second;
return WorldMobProtPtr();
};
|
[
"[email protected]"
] |
[
[
[
1,
648
]
]
] |
56e5dd57023adae93102613858c8584691bbbade
|
8fb9ccf49a324a586256bb08c22edc92e23affcf
|
/src/Engine/OscTriangle.h
|
3d2a6013d3e84ec15373d513045d53ba72c746b6
|
[] |
no_license
|
eriser/tal-noisemak3r
|
76468c98db61dfa28315284b4a5b1acfeb9c1ff6
|
1043c8f237741ea7beb89b5bd26243f8891cb037
|
refs/heads/master
| 2021-01-18T18:29:56.446225 | 2010-08-05T20:51:35 | 2010-08-05T20:51:35 | 62,891,642 | 1 | 0 | null | null | null | null |
UTF-8
|
C++
| false | false | 5,776 |
h
|
/*
==============================================================================
This file is part of Tal-NoiseMaker by Patrick Kunz.
Copyright(c) 2005-2010 Patrick Kunz, TAL
Togu Audio Line, Inc.
http://kunz.corrupt.ch
This file may be licensed under the terms of of the
GNU General Public License Version 2 (the ``GPL'').
Software distributed under the License is distributed
on an ``AS IS'' basis, WITHOUT WARRANTY OF ANY KIND, either
express or implied. See the GPL for the specific language
governing rights and limitations.
You should have received a copy of the GPL along with this
program. If not, go to http://www.gnu.org/licenses/gpl.html
or write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
==============================================================================
*/
#ifndef OscTriangle_H
#define OscTriangle_H
#include "BlepData.h"
class OscTriangle
{
public:
const float *sincBlep;
const float *minBlep;
const float sampleRate;
float sampleRateInv;
const float oversampling;
const int n;
float *integratedBlep;
float *buffer;
float *bufferSync;
int bufferPos;
int bufferPosSync;
float x;
float phaseFM;
float pi;
float pi2;
float sign;
float currentValue;
int countDelayBlep;
float delay1;
float delay2;
float delay3;
float delay4;
float delay5;
float delay6;
float delay7;
float delay8;
float delay9;
float delay10;
float delay11;
float delay12;
float delay13;
float delay14;
float delay15;
OscTriangle(float sampleRate, int oversampling):
sampleRate(sampleRate),
sampleRateInv(1.0f / sampleRate),
oversampling(128.0f / oversampling),
n(32 * (int)oversampling)
{
buffer= new float[n];
bufferSync= new float[n];
BlepData *blepData= new BlepData();
//minBlep = blepData->getBlep();
sincBlep = blepData->getSinc();
minBlep = blepData->getBlep();
resetOsc(0.0f);
pi= 3.1415926535897932384626433832795f;
pi2= 2.0f * pi;
sign = 1.0f;
currentValue = 0.0f;
countDelayBlep = 100;
resetOsc(0.0f);
}
~OscTriangle()
{
delete[] buffer;
delete[] minBlep;
}
void resetOsc(float phase)
{
x = phase;
phaseFM = 0.0f;
bufferPos = 0;
countDelayBlep = 0;
sign = 1.0f;
for (int i = 0; i < n; i++)
{
buffer[i]= 0.0f;
}
bufferPosSync = 0;
for (int i = 0; i < n; i++)
{
bufferSync[i]= 0.0f;
}
delay1 = 0.0f;
delay2 = 0.0f;
delay3 = 0.0f;
delay4 = 0.0f;
delay5 = 0.0f;
delay6 = 0.0f;
delay7 = 0.0f;
delay8 = 0.0f;
delay9 = 0.0f;
delay10 = 0.0f;
delay11 = 0.0f;
delay12 = 0.0f;
delay13 = 0.0f;
delay14 = 0.0f;
delay15 = 0.0f;
}
inline float getNextSample(float freq, float fm, float fmFreq, bool reset, float resetFrac, float masterFreq)
{
if (fm > 0.0f)
{
phaseFM += fmFreq / sampleRate;
freq += fm * 10.0f * fmFreq * (1.0f + sinf(phaseFM * pi2));
if (phaseFM > 1.0f) phaseFM -= 1.0f;
}
if (freq > 22000.0f) freq = 22000.0f;
if (freq > sampleRate * 0.45f) freq = sampleRate * 0.45f;
float fs = freq * sampleRateInv * 2.0f;
x += fs;
countDelayBlep++;
if (x >= 1.0f)
{
if (sign == 1.0f)
{
sign = -1.0f;
}
else
{
sign = 1.0f;
}
x -= 1.0f;
// mixInSinc(x / fs, sign * n / (1.0f / fs));
mixInSinc(x / fs, sign * n * fs);
countDelayBlep = 0;
}
if (reset)
{
float tmp = masterFreq / sampleRate;
float fracMaster = (fs * resetFrac) / tmp;
if (countDelayBlep != 16)
{
if (sign == 1.0f)
{
sign = 1.0f;
mixInBlepSync(resetFrac / tmp, x - fracMaster);
}
else
{
//sign = 1.0f;
//mixInBlepSync(resetFrac / tmp, 1.0f - (x - fracMaster));
sign = -1.0f;
mixInBlepSync(resetFrac / tmp, sign * (x - fracMaster));
}
}
x = fracMaster;
}
if (sign == 1.0f)
{
currentValue = x;
}
else
{
currentValue = 1.0f - x;
}
float value = delay15;
delay15 = delay14;
delay14 = delay13;
delay13 = delay12;
delay12 = delay11;
delay11 = delay10;
delay10 = delay9;
delay9 = delay8;
delay8 = delay7;
delay7 = delay6;
delay6 = delay5;
delay5 = delay4;
delay4 = delay3;
delay3 = delay2;
delay2 = delay1;
delay1 = currentValue - 0.5f + getNextBlepSync();
return getNextBlep() + value;
}
inline float getNextBlep()
{
buffer[bufferPos]= 0.0f;
bufferPos++;
// Wrap pos
if (bufferPos>=n)
{
bufferPos -= n;
}
return buffer[bufferPos];
}
#define LERP(A,B,F) ((B-A)*F+A)
inline void mixInSinc(float offset, float scale)
{
int lpIn = (int)(oversampling * offset);
float frac = fmod(oversampling * offset, 1.0f);
for (int i = 0; i < n; i++, lpIn += (int)oversampling)
{
buffer[(bufferPos + i)&(n-1)] += LERP(sincBlep[lpIn], sincBlep[lpIn+1], frac) * scale;
}
}
inline float getNextBlepSync()
{
bufferSync[bufferPosSync] = 0.0f;
bufferPosSync++;
// Wrap pos
if (bufferPosSync >= n)
{
bufferPosSync -= n;
}
return bufferSync[bufferPosSync];
}
inline void mixInBlepSync(float offset, float scale)
{
int lpIn = (int)(oversampling * 0.5f * offset);
float frac = fmod(offset * oversampling * 0.5f, 1.0f);
for (int i = 0; i < n; i++, lpIn += (int)(oversampling * 0.5f))
{
bufferSync[(bufferPosSync + i)&(n-1)] += scale - LERP(minBlep[lpIn], minBlep[lpIn+1], frac) * scale;
}
}
};
#endif
|
[
"patrickkunzch@1672e8fc-9579-4a43-9460-95afed9bdb0b"
] |
[
[
[
1,
272
]
]
] |
8868febfabecd4b746f95f86921f402b131c0307
|
c95a83e1a741b8c0eb810dd018d91060e5872dd8
|
/Game/ClientShellDLL/ClientShellShared/HUDPopup.cpp
|
6544fe19023b6c8ada229a64ca37446101e84b21
|
[] |
no_license
|
rickyharis39/nolf2
|
ba0b56e2abb076e60d97fc7a2a8ee7be4394266c
|
0da0603dc961e73ac734ff365bfbfb8abb9b9b04
|
refs/heads/master
| 2021-01-01T17:21:00.678517 | 2011-07-23T12:11:19 | 2011-07-23T12:11:19 | 38,495,312 | 1 | 0 | null | null | null | null |
UTF-8
|
C++
| false | false | 4,269 |
cpp
|
// ----------------------------------------------------------------------- //
//
// MODULE : HUDPopup.cpp
//
// PURPOSE : Implementation of CHUDPopup to display popups
//
// (c) 2001 Monolith Productions, Inc. All Rights Reserved
//
// ----------------------------------------------------------------------- //
//
// Includes...
//
#include "stdafx.h"
#include "HUDMgr.h"
#include "InterfaceResMgr.h"
#include "PopupMgr.h"
#include "HUDPopup.h"
// ----------------------------------------------------------------------- //
//
// ROUTINE: CHUDPopup::CHUDPopup
//
// PURPOSE: Constructor
//
// ----------------------------------------------------------------------- //
CHUDPopup::CHUDPopup()
: CHUDItem ( )
{
m_UpdateFlags = kHUDFrame;
m_bVisible = LTFALSE;
m_bColorOverride = LTFALSE;
}
// ----------------------------------------------------------------------- //
//
// ROUTINE: CHUDPopup::Init
//
// PURPOSE: Initialize the popup...
//
// ----------------------------------------------------------------------- //
LTBOOL CHUDPopup::Init()
{
m_Text.Create(" ",0,0,g_pInterfaceResMgr->GetFont(0),8,LTNULL);
m_Frame.Create(g_pInterfaceResMgr->GetTexture("interface\\menu\\sprtex\\frame.dtx"),200,320,LTTRUE);
return LTTRUE;
}
// ----------------------------------------------------------------------- //
//
// ROUTINE: CHUDPopup::Term
//
// PURPOSE: Destroy thyself...
//
// ----------------------------------------------------------------------- //
void CHUDPopup::Term()
{
m_Frame.Destroy();
m_Text.Destroy();
}
// ----------------------------------------------------------------------- //
//
// ROUTINE: CHUDPopup::Hide
//
// PURPOSE: NONE
//
// ----------------------------------------------------------------------- //
void CHUDPopup::Hide( )
{
m_bVisible = LTFALSE;
}
// ----------------------------------------------------------------------- //
//
// ROUTINE: CHUDPopup::Render
//
// PURPOSE: Draw the popup...
//
// ----------------------------------------------------------------------- //
void CHUDPopup::Render()
{
if (!m_bVisible) return;
m_Frame.Render();
m_Text.Render();
}
// ----------------------------------------------------------------------- //
//
// ROUTINE: CHUDPopup::Update
//
// PURPOSE: Update the popup...
//
// ----------------------------------------------------------------------- //
void CHUDPopup::Update()
{
// Sanity checks...
if( !IsVisible() ) return;
if( m_fScale != g_pInterfaceResMgr->GetXRatio() )
SetScale( g_pInterfaceResMgr->GetXRatio() );
}
// ----------------------------------------------------------------------- //
//
// ROUTINE: CHUDPopup::SetScale
//
// PURPOSE: Set the items scale...
//
// ----------------------------------------------------------------------- //
void CHUDPopup::SetScale(float fScale)
{
m_Frame.SetScale( fScale );
m_Text.SetScale( fScale );
m_fScale = fScale;
}
// ----------------------------------------------------------------------- //
//
// ROUTINE: CHUDPopup::Show
//
// PURPOSE: Display the popup with the passed in text...
//
// ----------------------------------------------------------------------- //
void CHUDPopup::Show( uint8 nPopupID, const char *pText )
{
POPUP* pPopup = g_pPopupMgr->GetPopup(nPopupID);
if (!pPopup) return;
CUIFont *pFont = g_pInterfaceResMgr->GetFont(pPopup->nFont);
LTIntPt pos( (640 - pPopup->sSize.x) / 2, (480 - pPopup->sSize.y) / 2 );
m_Frame.SetFrame(g_pInterfaceResMgr->GetTexture(pPopup->szFrame));
m_Frame.SetSize(pPopup->sSize.x,pPopup->sSize.y);
m_Frame.SetBasePos(pos);
m_Frame.SetScale(g_pInterfaceResMgr->GetXRatio());
pos.x += pPopup->sTextOffset.x;
pos.y += pPopup->sTextOffset.y;
m_Text.SetScale(1.0f);
m_Text.SetString( (pText ? pText : "") );
m_Text.SetFont(pFont,pPopup->nFontSize);
if( !m_bColorOverride )
m_Text.SetColors(pPopup->argbTextColor,pPopup->argbTextColor,pPopup->argbTextColor);
m_bColorOverride = LTFALSE;
m_Text.SetFixedWidth(pPopup->nTextWidth);
m_Text.SetBasePos(pos);
m_Text.SetScale(g_pInterfaceResMgr->GetXRatio());
m_bVisible = LTTRUE;
}
|
[
"[email protected]"
] |
[
[
[
1,
177
]
]
] |
33d6ec35e37c86e002aba36d1457adb734d8b50a
|
a9cf0c2a8904e42a206c3575b244f8b0850dd7af
|
/gui/console/scroller.h
|
a4be637151ed24ca590c2cfb3e4f2cb6467c5596
|
[] |
no_license
|
jayrulez/ourlib
|
3a38751ccb6a38785d4df6f508daeff35ccfd09f
|
e4727d638f2d69ea29114dc82b9687ea1fd17a2d
|
refs/heads/master
| 2020-04-22T15:42:00.891099 | 2010-01-06T20:00:17 | 2010-01-06T20:00:17 | 40,554,487 | 0 | 0 | null | null | null | null |
UTF-8
|
C++
| false | false | 748 |
h
|
/*
@Group: BSC2D
@Group Members:
<ul>
<li>Robert Campbell: 0701334</li>
<li>Audley Gordon: 0802218</li>
<li>Dale McFarlane: 0801042</li>
<li>Dyonne Duberry: 0802189</li>
<li>Xavier Lowe: 0802488</li>
</ul>
@
*/
#ifndef SCROLLER_H
#define SCROLLER_H
#include "frame.h"
class scroller
{
private:
int item_code;
int itemX;
int itemY;
int lenght;
/*frame will be used to make the scroller*/
frame frameScroller;
console consoleScroller;
public:
scroller();
~scroller();
bool setScroller(int,int,int);
/*used to put the scroller in motion*/
void scroll();
/*kill/erases the scroller's trace on the screen*/
void killScroll();
};
#endif // SCROLLER_H
|
[
"[email protected]"
] |
[
[
[
1,
35
]
]
] |
396f165ce9d4e3c2604c2e1d579f58817e34a188
|
1bbd5854d4a2efff9ee040e3febe3f846ed3ecef
|
/src/scrview/mousedatacollector.cpp
|
3b4be3eec932171ddc822f61867319cbf327017d
|
[] |
no_license
|
amanuelg3/screenviewer
|
2b896452a05cb135eb7b9eb919424fe6c1ce8dd7
|
7fc4bb61060e785aa65922551f0e3ff8423eccb6
|
refs/heads/master
| 2021-01-01T18:54:06.167154 | 2011-12-21T02:19:10 | 2011-12-21T02:19:10 | 37,343,569 | 0 | 0 | null | null | null | null |
UTF-8
|
C++
| false | false | 616 |
cpp
|
#include "mousedatacollector.h"
#include "server.h"
MouseDataCollector::MouseDataCollector(QMutex* mutex, Server *server) {
this->mutex = mutex;
this->server = server;
stoped = false;
}
void MouseDataCollector::run() {
stoped = false;
mutex->lock();
while(!stoped) {
mutex->lock();
//new data
qDebug() << "Gavom peles: " << (quint32)data->x << " " << data->y;
mutex->unlock();
mutex->lock();
}
mutex->unlock();
}
void MouseDataCollector::newData(MouseData* data) {
delete this->data;
this->data = data;
}
|
[
"j.salkevicius@localhost"
] |
[
[
[
1,
27
]
]
] |
19a60964573b1936c665f3cda010ec513fea12c3
|
957ab5f93616fe5f1dc37431f04b47aef4e37978
|
/projekte/lc-display/LCD4Bit/LCD4Bit.h
|
b3b2879d716d453693c80ca88e93759fe7c99f05
|
[] |
no_license
|
neingeist/arduinisten
|
30f221cd58ff2d64a4c268e9801718029d6d2ca3
|
dc60a0ee010ffe20be8054ec2934227314017842
|
refs/heads/master
| 2021-01-01T17:51:59.692825 | 2010-09-23T19:19:44 | 2010-09-23T19:19:44 | null | 0 | 0 | null | null | null | null |
UTF-8
|
C++
| false | false | 606 |
h
|
#ifndef LCD4Bit_h
#define LCD4Bit_h
#include <inttypes.h>
class LCD4Bit {
public:
LCD4Bit(int num_lines);
void commandWrite(int value);
void init();
void print(int value);
void printIn(char value[]);
void clear();
//non-core---------------
void cursorTo(int line_num, int x);
void leftScroll(int chars, int delay_time);
//end of non-core--------
//4bit only, therefore ideally private but may be needed by user
void commandWriteNibble(int nibble);
void pushByte(int value);
private:
void pulseEnablePin();
void pushNibble(int nibble);
};
#endif
|
[
"[email protected]"
] |
[
[
[
1,
27
]
]
] |
fe4a7c83e65ca928bd9bc7fa05a1772b9daeff64
|
ea12fed4c32e9c7992956419eb3e2bace91f063a
|
/zombie/code/nebula2/src/resource/nresourceserver_main.cc
|
3d7960a5425e4d64d22c23ae41eb1206e1f1642c
|
[] |
no_license
|
ugozapad/TheZombieEngine
|
832492930df28c28cd349673f79f3609b1fe7190
|
8e8c3e6225c2ed93e07287356def9fbdeacf3d6a
|
refs/heads/master
| 2020-04-30T11:35:36.258363 | 2011-02-24T14:18:43 | 2011-02-24T14:18:43 | null | 0 | 0 | null | null | null | null |
UTF-8
|
C++
| false | false | 18,384 |
cc
|
#include "precompiled/pchnnebula.h"
//------------------------------------------------------------------------------
// nresourceserver_main.cc
// (C) 2002 RadonLabs GmbH
//------------------------------------------------------------------------------
#include "precompiled/pchnnebula.h"
#include "resource/nresourceserver.h"
#include "resource/nresource.h"
#include "kernel/nprofiler.h"
nNebulaScriptClass(nResourceServer, "nroot");
nResourceServer* nResourceServer::Singleton = 0;
nProfiler nResourceServer::profAsyncIO;
//------------------------------------------------------------------------------
NSIGNAL_DEFINE(nResourceServer, ResourceReloaded);
//------------------------------------------------------------------------------
/**
*/
nResourceServer::nResourceServer() :
meshPool("/sys/share/rsrc/mesh"),
texPool("/sys/share/rsrc/tex"),
shdPool("/sys/share/rsrc/shd"),
animPool("/sys/share/rsrc/anim"),
sndResPool("/sys/share/rsrc/sndrsrc"),
sndInstPool("/sys/share/rsrc/sndinst"),
fontPool("/sys/share/rsrc/font"),
bundlePool("/sys/share/rsrc/bundle"),
otherPool("/sys/share/rsrc/other"),
uniqueId(0),
loaderThread(0)
{
n_assert(0 == Singleton);
Singleton = this;
if (!profAsyncIO.IsValid())
{
profAsyncIO.Initialize("profAsyncIO", true);
}
this->resourceClass = kernelServer->FindClass("nresource");
n_assert(this->resourceClass);
#ifndef __NEBULA_NO_THREADS__
this->StartLoaderThread();
#endif
}
//------------------------------------------------------------------------------
/**
*/
nResourceServer::~nResourceServer()
{
n_assert(Singleton);
Singleton = 0;
#ifndef __NEBULA_NO_THREADS__
this->ShutdownLoaderThread();
#endif
this->UnloadResources(nResource::AllResourceTypes);
}
//------------------------------------------------------------------------------
/**
Create a resource id from a resource name. The resource name is usually
just the filename of the resource file. The method strips off the last
32 characters from the resource name, and replaces any invalid characters
with underscores. It is valid to provide a 0-rsrcName for unshared resources.
A unique rsrc identifier string will then be created.
@param rsrcName pointer to a resource name (usually a file path), or 0
@param buf pointer to a char buffer
@param bufSize size of char buffer
@return a pointer to buf, which contains the result
*/
char*
nResourceServer::GetResourceId(const char* rsrcName, char* buf, int N_IFDEF_ASSERTS(bufSize) )
{
n_assert(buf);
n_assert(bufSize >= N_MAXNAMELEN);
if (!rsrcName)
{
sprintf(buf, "unique%d", this->uniqueId++);
}
else
{
int len = static_cast<int>( strlen(rsrcName) + 1 );
int offset = len - N_MAXNAMELEN;
if (offset < 0)
{
offset = 0;
}
// copy string and replace illegal characters, this also copies the terminating 0
char c;
const char* from = rsrcName;//&(rsrcName[offset]);
char* to = buf;
while ( 0 != (c = *from++))
{
if (('.' == c) || (c == '/') || (c == ':') || (c == '\\'))
{
*to++ = '_';
}
else
{
*to++ = c;
}
}
*to = 0;
}
return buf;
}
//------------------------------------------------------------------------------
/**
Find the right resource root object for a given resource type.
@param rsrcType the resource type
@return the root object
*/
nResourcePool*
nResourceServer::GetResourcePool(nResource::Type rsrcType)
{
switch (rsrcType)
{
case nResource::Mesh: return &this->meshPool;
case nResource::Texture: return &this->texPool;
case nResource::Shader: return &this->shdPool;
case nResource::Animation: return &this->animPool;
case nResource::SoundResource: return &this->sndResPool;
case nResource::SoundInstance: return &this->sndInstPool;
case nResource::Font: return &this->fontPool;
case nResource::Bundle: return &this->bundlePool;
case nResource::Other: return &this->otherPool;
default:
// can't happen
n_assert_always();
}
return 0;
}
//------------------------------------------------------------------------------
/**
Find a resource object by resource type and name.
@param rsrcName the rsrc name
@param rsrcType resource type
@return pointer to resource object, or 0 if not found
*/
nResource*
nResourceServer::FindResource(const char* rsrcName, nResource::Type rsrcType)
{
n_assert(rsrcName);
n_assert(nResource::InvalidResourceType != rsrcType);
nResourcePool* rsrcPool = this->GetResourcePool(rsrcType);
n_assert(rsrcPool);
return rsrcPool->Find(rsrcName);
}
//------------------------------------------------------------------------------
/**
Find a resource object by resource filename.
@param rsrcName the rsrc filename
@return pointer to resource object, or 0 if not found
*/
nResource*
nResourceServer::FindResourceByFileName(const char* fileName)
{
nFileServer2 *fileServer = nKernelServer::Instance()->GetFileServer();
nString strFilename(fileServer->ManglePath(fileName));
#ifdef __WIN32__
strFilename.ToLower();
#endif
int i;
for (i = 1; i < nResource::InvalidResourceType; i <<= 1)
{
if (0 != (nResource::AllResourceTypes & i))
{
nResourcePool* rsrcPool = this->GetResourcePool((nResource::Type) i);
n_assert(rsrcPool);
nResource* rsrc;
for (rsrc = (nResource*) rsrcPool->GetHead(); rsrc; rsrc = (nResource*) rsrc->GetSucc())
{
nString curFilename(fileServer->ManglePath(rsrc->GetFilename().Get()));
#ifdef __WIN32__
curFilename.ToLower();
#endif
if (curFilename == strFilename)
{
return rsrc;
}
}
}
}
return 0;
}
//------------------------------------------------------------------------------
/**
*/
bool
nResourceServer::ReloadResource(const char* rsrcName, nResource::Type rsrcType)
{
nResource* resource = this->FindResource(rsrcName, rsrcType);
if (resource)
{
if (resource->IsValid())
{
resource->Unload();
if (resource->Load())
{
#ifndef N_GAME
this->SignalResourceReloaded(this, resource);
#endif
return true;
}
return false;
}
}
return true;
}
//------------------------------------------------------------------------------
/**
*/
bool
nResourceServer::ReloadResourceByFileName(const char* fileName)
{
nResource* resource = this->FindResourceByFileName(fileName);
if (resource)
{
if (resource->IsValid())
{
if (resource->GetReloadOnChange())
{
resource->Unload();
if (resource->Load())
{
#ifndef N_GAME
this->SignalResourceReloaded(this, resource);
#endif
return true;
}
return false;
}
else
{
resource->SetReloadOnChange(true);
}
}
}
return true;
}
//------------------------------------------------------------------------------
/**
Create a new possible shared resource object. Bumps refcount on an
existing resource object. Pass a zero rsrcName if a (non-shared) resource
should be created.
@param className the Nebula class name
@param rsrcName the rsrc name (for resource sharing), can be 0
@param rsrcType resource type
@return pointer to resource object
*/
nResource*
nResourceServer::NewResource(const char* className, const char* rsrcName, nResource::Type rsrcType)
{
n_assert(className);
n_assert(nResource::InvalidResourceType != rsrcType);
nResourcePool* rsrcPool = this->GetResourcePool(rsrcType);
n_assert(rsrcPool);
nResource* obj = rsrcPool->NewResource(className, rsrcName);
n_assert(obj);
return obj;
}
//------------------------------------------------------------------------------
/**
Unload all resources matching the given resource type mask.
@param rsrcTypeMask a mask of nResource::Type values
*/
void
nResourceServer::UnloadResources(int rsrcTypeMask)
{
// also unload bundles?
if (0 != (rsrcTypeMask & (nResource::Mesh | nResource::Animation | nResource::Texture)))
{
rsrcTypeMask |= nResource::Bundle;
}
int i;
for (i = 1; i < nResource::InvalidResourceType; i <<= 1)
{
if (0 != (rsrcTypeMask & i))
{
nResourcePool* rsrcPool = this->GetResourcePool((nResource::Type) i);
n_assert(rsrcPool);
nResource* rsrc;
for (rsrc = (nResource*) rsrcPool->GetHead(); rsrc; rsrc = (nResource*) rsrc->GetSucc())
{
rsrc->Unload();
}
}
}
}
//------------------------------------------------------------------------------
/**
Load all resources matching the given resource type mask. Returns false
if any of the resources didn't load correctly.
IMPLEMENTATION NOTE: since the Bundle resource type is defined
before all other resource types, it is guaranteed that bundled
resources are loaded before all others.
@param rsrcTypeMask a resource type
@return true if all resources loaded correctly
*/
bool
nResourceServer::LoadResources(int rsrcTypeMask)
{
// also reload bundles?
if (0 != (rsrcTypeMask & (nResource::Mesh | nResource::Animation | nResource::Texture)))
{
rsrcTypeMask |= nResource::Bundle;
}
int i;
bool retval = true;
for (i = 1; i < nResource::InvalidResourceType; i <<= 1)
{
if (0 != (rsrcTypeMask & i))
{
nResourcePool* rsrcPool = this->GetResourcePool((nResource::Type) i);
n_assert(rsrcPool);
nResource* rsrc;
for (rsrc = (nResource*) rsrcPool->GetHead(); rsrc; rsrc = (nResource*) rsrc->GetSucc())
{
// NOTE: if the resource is bundled, it could've been loaded already
// (if this is the actual resource object which has been created by the
// bundle, thus we check if the resource has already been loaded)
if (!rsrc->IsLoaded())
{
retval &= rsrc->Load();
}
}
}
}
return retval;
}
//------------------------------------------------------------------------------
/**
Calls nResource::OnLost() on all resources defined in the resource
type mask.
@param rsrcTypeMask a mask of nResource::Type values
*/
void
nResourceServer::OnLost(int rsrcTypeMask)
{
int i;
for (i = 1; i < nResource::InvalidResourceType; i <<= 1)
{
if (0 != (rsrcTypeMask & i))
{
nResourcePool* rsrcPool = this->GetResourcePool((nResource::Type) i);
n_assert(rsrcPool);
nResource* rsrc;
for (rsrc = (nResource*) rsrcPool->GetHead(); rsrc; rsrc = (nResource*) rsrc->GetSucc())
{
NLOGCOND(resource, rsrc->IsLost(), (0, "Resource already lost name=%s filename=%s", rsrc->GetName(), rsrc->GetFilename().Get()));
if (!rsrc->IsLost())
{
rsrc->OnLost();
}
}
}
}
}
//------------------------------------------------------------------------------
/**
Calls nResource::OnRestored() on all resources defined in the resource
type mask.
@param rsrcTypeMask a resource type
*/
void
nResourceServer::OnRestored(int rsrcTypeMask)
{
int i;
for (i = 1; i < nResource::InvalidResourceType; i <<= 1)
{
if (0 != (rsrcTypeMask & i))
{
nResourcePool* rsrcPool = this->GetResourcePool((nResource::Type) i);
n_assert(rsrcPool);
nResource* rsrc;
for (rsrc = (nResource*) rsrcPool->GetHead(); rsrc; rsrc = (nResource*) rsrc->GetSucc())
{
if (rsrc->IsLost())
{
rsrc->OnRestored();
}
}
}
}
}
//------------------------------------------------------------------------------
/**
Wakeup the loader thread. This will simply signal the jobList.
*/
void
nResourceServer::ThreadWakeupFunc(nThread* thread)
{
nResourceServer* self = (nResourceServer*) thread->LockUserData();
thread->UnlockUserData();
self->jobList.SignalEvent();
}
//------------------------------------------------------------------------------
/**
The background loader thread func. This will sit on the jobList until
it is signaled (when new jobs arrive), and for each job in the job
list, it will invoke the LoadResource() method of the resource object
and remove the resource object from the job list.
*/
int
N_THREADPROC
nResourceServer::LoaderThreadFunc(nThread* thread)
{
nProfiler profLoadOp;
// tell thread object that we have started
thread->ThreadStarted();
// get pointer to thread server object
nResourceServer* self = (nResourceServer*) thread->LockUserData();
thread->UnlockUserData();
// sit on the jobList signal until new jobs arrive
do
{
// do nothing until job list becomes signalled
self->jobList.WaitEvent();
// does our boss want us to shut down?
if (!thread->ThreadStopRequested())
{
profAsyncIO.StartAccum();
// get all pending jobs
while (self->jobList.GetHead())
{
// keep the job object from joblist
self->jobList.Lock();
nNode* jobNode = self->jobList.RemHead();
nResource* res = (nResource*) jobNode->GetPtr();
// take the resource's mutex and lock the resource,
// this prevents the resource to be deleted
res->LockMutex();
self->jobList.Unlock();
profLoadOp.ResetAccum();
profLoadOp.StartAccum();
res->LoadResource();
profLoadOp.StopAccum();
NLOG(resource, (nResource::NLOG_ASYNCIO, "loaded time=%3.1f ms resource %s file %s ", profLoadOp.GetAccumTime(), res->GetName(), res->GetFilename().Get()));
res->UnlockMutex();
// proceed to next job
}
profAsyncIO.StopAccum();
}
}
while (!thread->ThreadStopRequested());
// tell thread object that we are done
thread->ThreadHarakiri();
return 0;
}
//------------------------------------------------------------------------------
/**
Start the loader thread.
*/
void
nResourceServer::StartLoaderThread()
{
n_assert(0 == this->loaderThread);
// give the thread sufficient stack size (2.5 MB) and a below
// normal priority (the purpose of the thread is to guarantee
// a smooth framerate despite dynamic resource loading after all)
this->loaderThread = n_new(nThread(LoaderThreadFunc, nThread::Low, 2500000, ThreadWakeupFunc, 0, this));
}
//------------------------------------------------------------------------------
/**
Shutdown the loader thread.
*/
void
nResourceServer::ShutdownLoaderThread()
{
n_assert(this->loaderThread);
n_delete(this->loaderThread);
this->loaderThread = 0;
// clear the job list
this->jobList.Lock();
while (this->jobList.RemHead());
this->jobList.Unlock();
}
//------------------------------------------------------------------------------
/**
Add a resource to the job list for asynchronous loading.
*/
void
nResourceServer::AddLoaderJob(nResource* res)
{
n_assert(res);
n_assert(!res->IsPending());
n_assert(!res->IsLoaded());
this->jobList.Lock();
this->jobList.AddTail(&(res->jobNode));
this->jobList.Unlock();
this->jobList.SignalEvent();
}
//------------------------------------------------------------------------------
/**
Remove a resource from the job list for asynchronous loading.
*/
void
nResourceServer::RemLoaderJob(nResource* res)
{
n_assert(res);
this->jobList.Lock();
if (res->IsPending())
{
res->jobNode.Remove();
}
this->jobList.Unlock();
}
//------------------------------------------------------------------------------
/**
Count the number of resources of a given type.
*/
int
nResourceServer::GetNumResources(nResource::Type rsrcType)
{
nResourcePool* rsrcPool = this->GetResourcePool(rsrcType);
n_assert(rsrcPool);
return rsrcPool->GetNumResources();
}
//------------------------------------------------------------------------------
/**
Returns the number of bytes a resource type occupies in RAM.
*/
int
nResourceServer::GetResourceByteSize(nResource::Type rsrcType)
{
nResourcePool* rsrcPool = this->GetResourcePool(rsrcType);
n_assert(rsrcPool);
nRoot* cur;
int size = 0;
for (cur = rsrcPool->GetHead(); cur; cur = cur->GetSucc())
{
n_assert(cur->IsA(this->resourceClass));
nResource* res = (nResource*) cur;
size += res->GetByteSize();
}
return size;
}
|
[
"magarcias@c1fa4281-9647-0410-8f2c-f027dd5e0a91"
] |
[
[
[
1,
595
]
]
] |
0f812f8b67cec098618f9187ca6bfdc68d632407
|
97b7853d2eb3481f9fb091c5e61cb8d9ba052a50
|
/src/tehDJ_wdr.cpp
|
bbfcb3c36fe47071a963f2d258e3dbc9d5957c07
|
[] |
no_license
|
mentat/tehDJ
|
dad7826f7bca57603d57120267ef0711d2572859
|
ee1f782374897bf5e00102827194b89614029eed
|
refs/heads/master
| 2021-01-25T03:54:58.836751 | 2011-03-23T22:27:09 | 2011-03-23T22:27:09 | 1,518,542 | 0 | 0 | null | null | null | null |
UTF-8
|
C++
| false | false | 18,861 |
cpp
|
//------------------------------------------------------------------------------
// Source code generated by wxDesigner from file: tehDJ.wdr
// Do not modify this file, all changes will be lost!
//------------------------------------------------------------------------------
#ifdef __GNUG__
#pragma implementation "tehDJ_wdr.cpp"
#endif
// For compilers that support precompilation
#include "wx/wxprec.h"
#ifdef __BORLANDC__
#pragma hdrstop
#endif
// Include private header
#include "tehDJ_wdr.h"
// Implement window functions
wxSizer *djMain( wxWindow *parent, bool call_fit, bool set_sizer )
{
wxFlexGridSizer *item0 = new wxFlexGridSizer( 1, 0, 0 );
item0->AddGrowableCol( 0 );
wxFlexGridSizer *item1 = new wxFlexGridSizer( 2, 0, 0 );
item1->AddGrowableCol( 0 );
wxTextCtrl *item2 = new wxTextCtrl( parent, ID_FILENAME, "", wxDefaultPosition, wxSize(80,-1), wxTE_READONLY );
item1->Add( item2, 0, wxGROW|wxALIGN_CENTER_VERTICAL|wxALL, 5 );
wxButton *item3 = new wxButton( parent, ID_LOAD, "Load File", wxDefaultPosition, wxDefaultSize, 0 );
item1->Add( item3, 0, wxALIGN_CENTRE|wxALL, 5 );
item0->Add( item1, 0, wxGROW|wxALIGN_CENTER_VERTICAL|wxALL, 5 );
wxStaticBox *item5 = new wxStaticBox( parent, -1, "Location" );
wxStaticBoxSizer *item4 = new wxStaticBoxSizer( item5, wxVERTICAL );
wxSlider *item6 = new wxSlider( parent, ID_LOCATION, 0, 0, 1000, wxDefaultPosition, wxSize(100,-1), wxSL_HORIZONTAL );
item4->Add( item6, 0, wxGROW|wxALIGN_CENTER_VERTICAL, 5 );
item0->Add( item4, 0, wxGROW|wxALIGN_CENTER_VERTICAL|wxALL, 5 );
wxFlexGridSizer *item7 = new wxFlexGridSizer( 2, 0, 0 );
item7->AddGrowableCol( 1 );
item7->AddGrowableRow( 0 );
wxWindow *item8 = parent->FindWindow( ID_SPINBIT );
wxASSERT( item8 );
item7->Add( item8, 0, wxALIGN_CENTRE|wxALL, 5 );
wxTextCtrl *item9 = new wxTextCtrl( parent, ID_TEXTCTRL, "", wxDefaultPosition, wxSize(80,120), wxTE_MULTILINE );
item7->Add( item9, 0, wxGROW|wxALIGN_CENTER_HORIZONTAL|wxALL, 5 );
item0->Add( item7, 0, wxGROW|wxALIGN_CENTER_VERTICAL|wxALL, 5 );
wxFlexGridSizer *item10 = new wxFlexGridSizer( 2, 0, 0 );
wxButton *item11 = new wxButton( parent, ID_START, "Start", wxDefaultPosition, wxDefaultSize, 0 );
item10->Add( item11, 0, wxALIGN_CENTRE|wxALL, 5 );
wxButton *item12 = new wxButton( parent, ID_STOP, "Stop", wxDefaultPosition, wxDefaultSize, 0 );
item10->Add( item12, 0, wxALIGN_CENTRE|wxALL, 5 );
item0->Add( item10, 0, wxGROW|wxALIGN_CENTER_VERTICAL|wxALL, 5 );
if (set_sizer)
{
parent->SetAutoLayout( TRUE );
parent->SetSizer( item0 );
if (call_fit)
{
item0->Fit( parent );
item0->SetSizeHints( parent );
}
}
return item0;
}
wxSizer *djPrefsAudio( wxWindow *parent, bool call_fit, bool set_sizer )
{
wxFlexGridSizer *item0 = new wxFlexGridSizer( 1, 0, 0 );
item0->AddGrowableCol( 0 );
wxFlexGridSizer *item1 = new wxFlexGridSizer( 2, 0, 0 );
item1->AddGrowableCol( 1 );
wxStaticText *item2 = new wxStaticText( parent, ID_TEXT, "Device:", wxDefaultPosition, wxDefaultSize, 0 );
item1->Add( item2, 0, wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL|wxALL, 5 );
wxString strs3[] =
{
"ComboItem"
};
wxComboBox *item3 = new wxComboBox( parent, ID_PREF_AUDIO_DEVICE, "", wxDefaultPosition, wxSize(100,-1), 1, strs3, wxCB_DROPDOWN|wxCB_READONLY );
item1->Add( item3, 0, wxGROW|wxALIGN_CENTER_VERTICAL|wxALL, 5 );
item0->Add( item1, 0, wxGROW|wxALIGN_CENTER_VERTICAL|wxALL, 5 );
wxFlexGridSizer *item4 = new wxFlexGridSizer( 2, 0, 0 );
item4->AddGrowableCol( 1 );
wxStaticText *item5 = new wxStaticText( parent, ID_TEXT, "Sampling Rate:", wxDefaultPosition, wxDefaultSize, 0 );
item4->Add( item5, 0, wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL|wxALL, 5 );
wxString strs6[] =
{
"ComboItem"
};
wxComboBox *item6 = new wxComboBox( parent, ID_PREF_AUDIO_RATE, "", wxDefaultPosition, wxSize(100,-1), 1, strs6, wxCB_DROPDOWN );
item4->Add( item6, 0, wxGROW|wxALIGN_CENTER_VERTICAL|wxALL, 5 );
item0->Add( item4, 0, wxGROW|wxALIGN_CENTER_VERTICAL|wxALL, 5 );
wxFlexGridSizer *item7 = new wxFlexGridSizer( 3, 0, 0 );
wxCheckBox *item8 = new wxCheckBox( parent, ID_PREF_AUDIO_ASIO, "Use ASIO", wxDefaultPosition, wxDefaultSize, 0 );
item7->Add( item8, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5 );
wxString strs9[] =
{
"Stereo",
"Mono"
};
wxRadioBox *item9 = new wxRadioBox( parent, ID_PREF_AUDIO_STEREO, "Channels", wxDefaultPosition, wxDefaultSize, 2, strs9, 1, wxRA_SPECIFY_COLS );
item7->Add( item9, 0, wxLEFT|wxRIGHT|wxBOTTOM, 5 );
wxStaticBox *item11 = new wxStaticBox( parent, -1, "Bit Resolution" );
wxStaticBoxSizer *item10 = new wxStaticBoxSizer( item11, wxVERTICAL );
wxString strs12[] =
{
"8/sample",
"16/sample",
"24/sample",
"32/sample"
};
wxComboBox *item12 = new wxComboBox( parent, ID_PREF_AUDIO_BITS, "", wxDefaultPosition, wxSize(100,-1), 4, strs12, wxCB_DROPDOWN|wxCB_READONLY );
item10->Add( item12, 0, wxALIGN_CENTRE|wxALL, 5 );
item7->Add( item10, 0, wxALIGN_CENTER_HORIZONTAL|wxLEFT|wxRIGHT|wxBOTTOM, 5 );
item0->Add( item7, 0, wxGROW|wxALIGN_CENTER_VERTICAL|wxALL, 5 );
wxStaticBox *item14 = new wxStaticBox( parent, -1, "Buffers" );
wxStaticBoxSizer *item13 = new wxStaticBoxSizer( item14, wxVERTICAL );
wxFlexGridSizer *item15 = new wxFlexGridSizer( 2, 0, 0 );
item15->AddGrowableCol( 0 );
wxSlider *item16 = new wxSlider( parent, ID_PREF_AUDIO_BUFFERS, 4, 1, 200, wxDefaultPosition, wxSize(100,-1), wxSL_HORIZONTAL );
item15->Add( item16, 0, wxGROW|wxALIGN_CENTER_VERTICAL, 5 );
wxTextCtrl *item17 = new wxTextCtrl( parent, ID_PREF_AUDIO_BUFFERS_CTRL, "", wxDefaultPosition, wxSize(80,-1), 0 );
item15->Add( item17, 0, wxALIGN_CENTRE|wxALL, 5 );
item13->Add( item15, 0, wxGROW|wxALIGN_CENTER_VERTICAL|wxALL, 5 );
item0->Add( item13, 0, wxGROW|wxALIGN_CENTER_VERTICAL|wxALL, 5 );
wxFlexGridSizer *item18 = new wxFlexGridSizer( 3, 0, 0 );
wxStaticBox *item20 = new wxStaticBox( parent, -1, "Samples per buffer" );
wxStaticBoxSizer *item19 = new wxStaticBoxSizer( item20, wxVERTICAL );
wxSpinCtrl *item21 = new wxSpinCtrl( parent, ID_PREF_AUDIO_SAMPLES, "0", wxDefaultPosition, wxSize(100,-1), wxSP_WRAP, 1, 10000, 0 );
item19->Add( item21, 0, wxALIGN_CENTRE|wxALL, 5 );
item18->Add( item19, 0, wxALIGN_CENTRE|wxRIGHT|wxTOP|wxBOTTOM, 5 );
wxStaticText *item22 = new wxStaticText( parent, ID_TEXT, "Nominal latency:", wxDefaultPosition, wxDefaultSize, 0 );
item18->Add( item22, 0, wxALIGN_CENTRE|wxALL, 5 );
wxTextCtrl *item23 = new wxTextCtrl( parent, ID_PREF_AUDIO_LATENCY, "10ms", wxDefaultPosition, wxSize(80,-1), wxTE_READONLY );
item18->Add( item23, 0, wxALIGN_CENTRE|wxALL, 5 );
item0->Add( item18, 0, wxGROW|wxALIGN_CENTER_VERTICAL|wxALL, 5 );
if (set_sizer)
{
parent->SetAutoLayout( TRUE );
parent->SetSizer( item0 );
if (call_fit)
{
item0->Fit( parent );
item0->SetSizeHints( parent );
}
}
return item0;
}
wxSizer *EQ( wxWindow *parent, bool call_fit, bool set_sizer )
{
wxFlexGridSizer *item0 = new wxFlexGridSizer( 9, 0, 0 );
item0->AddGrowableRow( 1 );
wxStaticText *item1 = new wxStaticText( parent, ID_TEXT, "60", wxDefaultPosition, wxDefaultSize, 0 );
item0->Add( item1, 0, wxALIGN_CENTRE|wxALL, 5 );
wxStaticText *item2 = new wxStaticText( parent, ID_TEXT, "170", wxDefaultPosition, wxDefaultSize, 0 );
item0->Add( item2, 0, wxALIGN_CENTRE|wxALL, 5 );
wxStaticText *item3 = new wxStaticText( parent, ID_TEXT, "310", wxDefaultPosition, wxDefaultSize, 0 );
item0->Add( item3, 0, wxALIGN_CENTRE|wxALL, 5 );
wxStaticText *item4 = new wxStaticText( parent, ID_TEXT, "600", wxDefaultPosition, wxDefaultSize, 0 );
item0->Add( item4, 0, wxALIGN_CENTRE|wxALL, 5 );
wxStaticText *item5 = new wxStaticText( parent, ID_TEXT, "1K", wxDefaultPosition, wxDefaultSize, 0 );
item0->Add( item5, 0, wxALIGN_CENTRE|wxALL, 5 );
wxStaticText *item6 = new wxStaticText( parent, ID_TEXT, "3K", wxDefaultPosition, wxDefaultSize, 0 );
item0->Add( item6, 0, wxALIGN_CENTRE|wxALL, 5 );
wxStaticText *item7 = new wxStaticText( parent, ID_TEXT, "6K", wxDefaultPosition, wxDefaultSize, 0 );
item0->Add( item7, 0, wxALIGN_CENTRE|wxALL, 5 );
wxStaticText *item8 = new wxStaticText( parent, ID_TEXT, "12K", wxDefaultPosition, wxDefaultSize, 0 );
item0->Add( item8, 0, wxALIGN_CENTRE|wxALL, 5 );
wxStaticText *item9 = new wxStaticText( parent, ID_TEXT, "16K", wxDefaultPosition, wxDefaultSize, 0 );
item0->Add( item9, 0, wxALIGN_CENTRE|wxALL, 5 );
wxSlider *item10 = new wxSlider( parent, ID_BAND0, 50, 0, 100, wxDefaultPosition, wxDefaultSize, wxSL_VERTICAL );
item0->Add( item10, 0, wxGROW|wxALIGN_CENTER_HORIZONTAL|wxALL, 5 );
wxSlider *item11 = new wxSlider( parent, ID_BAND1, 50, 0, 100, wxDefaultPosition, wxDefaultSize, wxSL_VERTICAL );
item0->Add( item11, 0, wxGROW|wxALIGN_CENTER_HORIZONTAL|wxALL, 5 );
wxSlider *item12 = new wxSlider( parent, ID_BAND2, 50, 0, 100, wxDefaultPosition, wxDefaultSize, wxSL_VERTICAL );
item0->Add( item12, 0, wxGROW|wxALIGN_CENTER_HORIZONTAL|wxALL, 5 );
wxSlider *item13 = new wxSlider( parent, ID_BAND3, 50, 0, 100, wxDefaultPosition, wxDefaultSize, wxSL_VERTICAL );
item0->Add( item13, 0, wxGROW|wxALIGN_CENTER_HORIZONTAL|wxALL, 5 );
wxSlider *item14 = new wxSlider( parent, ID_BAND4, 50, 0, 100, wxDefaultPosition, wxDefaultSize, wxSL_VERTICAL );
item0->Add( item14, 0, wxGROW|wxALIGN_CENTER_HORIZONTAL|wxALL, 5 );
wxSlider *item15 = new wxSlider( parent, ID_BAND5, 50, 0, 100, wxDefaultPosition, wxDefaultSize, wxSL_VERTICAL );
item0->Add( item15, 0, wxGROW|wxALIGN_CENTER_HORIZONTAL|wxALL, 5 );
wxSlider *item16 = new wxSlider( parent, ID_BAND6, 50, 0, 100, wxDefaultPosition, wxDefaultSize, wxSL_VERTICAL );
item0->Add( item16, 0, wxGROW|wxALIGN_CENTER_HORIZONTAL|wxALL, 5 );
wxSlider *item17 = new wxSlider( parent, ID_BAND7, 50, 0, 100, wxDefaultPosition, wxDefaultSize, wxSL_VERTICAL );
item0->Add( item17, 0, wxGROW|wxALIGN_CENTER_HORIZONTAL|wxALL, 5 );
wxSlider *item18 = new wxSlider( parent, ID_BAND8, 50, 0, 100, wxDefaultPosition, wxDefaultSize, wxSL_VERTICAL );
item0->Add( item18, 0, wxGROW|wxALIGN_CENTER_HORIZONTAL|wxALL, 5 );
if (set_sizer)
{
parent->SetAutoLayout( TRUE );
parent->SetSizer( item0 );
if (call_fit)
{
item0->Fit( parent );
item0->SetSizeHints( parent );
}
}
return item0;
}
wxSizer *djMainSmall( wxWindow *parent, bool call_fit, bool set_sizer )
{
wxFlexGridSizer *item0 = new wxFlexGridSizer( 1, 0, 0 );
wxFlexGridSizer *item1 = new wxFlexGridSizer( 2, 0, 0 );
item1->AddGrowableCol( 1 );
wxTextCtrl *item2 = new wxTextCtrl( parent, ID_SONGTIME, "", wxDefaultPosition, wxSize(60,-1), wxTE_READONLY );
item1->Add( item2, 0, wxALIGN_CENTRE|wxLEFT|wxRIGHT|wxTOP, 5 );
wxTextCtrl *item3 = new wxTextCtrl( parent, ID_SONGNAME, "", wxDefaultPosition, wxSize(100,-1), wxTE_READONLY );
item1->Add( item3, 0, wxGROW|wxALIGN_CENTER_VERTICAL|wxLEFT|wxRIGHT|wxTOP, 5 );
item0->Add( item1, 0, wxGROW|wxALIGN_CENTER_VERTICAL, 5 );
wxFlexGridSizer *item4 = new wxFlexGridSizer( 3, 0, 0 );
wxWindow *item5 = parent->FindWindow( ID_VISUAL );
wxASSERT( item5 );
item4->Add( item5, 0, wxALIGN_CENTRE|wxLEFT, 5 );
wxSlider *item6 = new wxSlider( parent, ID_VOLUME, 70, 0, 100, wxDefaultPosition, wxSize(70,-1), wxSL_HORIZONTAL );
item4->Add( item6, 0, wxALIGN_CENTRE, 5 );
wxButton *item7 = new wxButton( parent, ID_EQ_BUTT, "EQ", wxDefaultPosition, wxSize(20,20), 0 );
item7->SetFont( wxFont( 8, wxROMAN, wxNORMAL, wxNORMAL ) );
item4->Add( item7, 0, wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL, 5 );
item0->Add( item4, 0, wxGROW|wxALIGN_CENTER_VERTICAL, 5 );
wxSlider *item8 = new wxSlider( parent, ID_LOCATION, 0, 0, 1000, wxDefaultPosition, wxSize(100,-1), wxSL_HORIZONTAL );
item0->Add( item8, 0, wxGROW|wxALIGN_CENTER_VERTICAL, 5 );
wxFlexGridSizer *item9 = new wxFlexGridSizer( 7, 0, 0 );
wxButton *item10 = new wxButton( parent, ID_BACK, "|<", wxDefaultPosition, wxSize(20,-1), 0 );
item9->Add( item10, 0, wxALIGN_CENTRE, 5 );
wxButton *item11 = new wxButton( parent, ID_START, ">", wxDefaultPosition, wxSize(20,-1), 0 );
item9->Add( item11, 0, wxALIGN_CENTRE, 5 );
wxButton *item12 = new wxButton( parent, ID_PAUSE, "||", wxDefaultPosition, wxSize(20,-1), 0 );
item9->Add( item12, 0, wxALIGN_CENTRE, 5 );
wxButton *item13 = new wxButton( parent, ID_STOP, "[]", wxDefaultPosition, wxSize(20,-1), 0 );
item9->Add( item13, 0, wxALIGN_CENTRE, 5 );
wxButton *item14 = new wxButton( parent, ID_FORWARD, ">|", wxDefaultPosition, wxSize(20,-1), 0 );
item9->Add( item14, 0, wxALIGN_CENTRE, 5 );
wxButton *item15 = new wxButton( parent, ID_LOAD, "/\\", wxDefaultPosition, wxSize(20,-1), 0 );
item9->Add( item15, 0, wxALIGN_CENTRE|wxLEFT|wxRIGHT, 5 );
wxGauge *item16 = new wxGauge( parent, ID_BUFF_LEVEL, 100, wxDefaultPosition, wxSize(-1,20), 0 );
item9->Add( item16, 0, wxALIGN_CENTRE, 5 );
item0->Add( item9, 0, wxGROW|wxALIGN_CENTER_VERTICAL|wxLEFT|wxRIGHT|wxBOTTOM, 5 );
if (set_sizer)
{
parent->SetAutoLayout( TRUE );
parent->SetSizer( item0 );
if (call_fit)
{
item0->Fit( parent );
item0->SetSizeHints( parent );
}
}
return item0;
}
wxSizer *EQView( wxWindow *parent, bool call_fit, bool set_sizer )
{
wxFlexGridSizer *item0 = new wxFlexGridSizer( 9, 0, 0 );
item0->AddGrowableRow( 0 );
wxGauge *item1 = new wxGauge( parent, ID_GAUGE0, 100, wxDefaultPosition, wxSize(-1,20), 0 );
item0->Add( item1, 0, wxGROW|wxALIGN_CENTER_HORIZONTAL|wxALL, 5 );
wxGauge *item2 = new wxGauge( parent, ID_GAUGE1, 100, wxDefaultPosition, wxSize(-1,20), 0 );
item0->Add( item2, 0, wxGROW|wxALIGN_CENTER_HORIZONTAL|wxALL, 5 );
wxGauge *item3 = new wxGauge( parent, ID_GAUGE2, 100, wxDefaultPosition, wxSize(-1,20), 0 );
item0->Add( item3, 0, wxGROW|wxALIGN_CENTER_HORIZONTAL|wxALL, 5 );
wxGauge *item4 = new wxGauge( parent, ID_GAUGE3, 100, wxDefaultPosition, wxSize(-1,20), 0 );
item0->Add( item4, 0, wxGROW|wxALIGN_CENTER_HORIZONTAL|wxALL, 5 );
wxGauge *item5 = new wxGauge( parent, ID_GAUGE4, 100, wxDefaultPosition, wxSize(-1,20), 0 );
item0->Add( item5, 0, wxGROW|wxALIGN_CENTER_HORIZONTAL|wxALL, 5 );
wxGauge *item6 = new wxGauge( parent, ID_GAUGE5, 100, wxDefaultPosition, wxSize(-1,20), 0 );
item0->Add( item6, 0, wxGROW|wxALIGN_CENTER_HORIZONTAL|wxALL, 5 );
wxGauge *item7 = new wxGauge( parent, ID_GAUGE6, 100, wxDefaultPosition, wxSize(-1,20), 0 );
item0->Add( item7, 0, wxGROW|wxALIGN_CENTER_HORIZONTAL|wxALL, 5 );
wxGauge *item8 = new wxGauge( parent, ID_GAUGE7, 100, wxDefaultPosition, wxSize(-1,20), 0 );
item0->Add( item8, 0, wxGROW|wxALIGN_CENTER_HORIZONTAL|wxALL, 5 );
if (set_sizer)
{
parent->SetAutoLayout( TRUE );
parent->SetSizer( item0 );
if (call_fit)
{
item0->Fit( parent );
item0->SetSizeHints( parent );
}
}
return item0;
}
wxSizer *djPrefsMP3( wxWindow *parent, bool call_fit, bool set_sizer )
{
wxFlexGridSizer *item0 = new wxFlexGridSizer( 2, 0, 0 );
wxStaticText *item1 = new wxStaticText( parent, ID_TEXT, "Decoding Engine:", wxDefaultPosition, wxDefaultSize, 0 );
item0->Add( item1, 0, wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL|wxALL, 5 );
wxString strs2[] =
{
"MAD 0.14.2 BETA"
};
wxChoice *item2 = new wxChoice( parent, ID_PREF_MP3_ENGINE, wxDefaultPosition, wxSize(100,-1), 1, strs2, 0 );
item0->Add( item2, 0, wxALIGN_CENTRE|wxALL, 5 );
wxStaticText *item3 = new wxStaticText( parent, ID_TEXT, "Thread Priority:", wxDefaultPosition, wxDefaultSize, 0 );
item0->Add( item3, 0, wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL|wxALL, 5 );
wxString strs4[] =
{
"Normal",
"High",
"Low"
};
wxChoice *item4 = new wxChoice( parent, ID_PREF_MP3_THREAD, wxDefaultPosition, wxSize(100,-1), 3, strs4, 0 );
item0->Add( item4, 0, wxALIGN_CENTRE|wxALL, 5 );
wxStaticText *item5 = new wxStaticText( parent, ID_TEXT, "Dithering Technique:", wxDefaultPosition, wxDefaultSize, 0 );
item0->Add( item5, 0, wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL|wxALL, 5 );
wxString strs6[] =
{
"Linear"
};
wxChoice *item6 = new wxChoice( parent, ID_PREF_MP3_DITHER, wxDefaultPosition, wxSize(100,-1), 1, strs6, 0 );
item0->Add( item6, 0, wxALIGN_CENTRE|wxALL, 5 );
if (set_sizer)
{
parent->SetAutoLayout( TRUE );
parent->SetSizer( item0 );
if (call_fit)
{
item0->Fit( parent );
item0->SetSizeHints( parent );
}
}
return item0;
}
wxSizer *djPrefs( wxWindow *parent, bool call_fit, bool set_sizer )
{
wxFlexGridSizer *item0 = new wxFlexGridSizer( 1, 0, 0 );
item0->AddGrowableCol( 0 );
item0->AddGrowableRow( 0 );
wxNotebook *item2 = new wxNotebook( parent, ID_NOTEBOOK, wxDefaultPosition, wxSize(200,160), wxNB_LEFT );
wxNotebookSizer *item1 = new wxNotebookSizer( item2 );
wxPanel *item3 = new wxPanel( item2, -1 );
djPrefsAudio( item3, FALSE );
item2->AddPage( item3, "Audio" );
wxPanel *item4 = new wxPanel( item2, -1 );
djPrefsMP3( item4, FALSE );
item2->AddPage( item4, "Layer III" );
item0->Add( item1, 0, wxALIGN_CENTRE|wxALL, 5 );
if (set_sizer)
{
parent->SetAutoLayout( TRUE );
parent->SetSizer( item0 );
if (call_fit)
{
item0->Fit( parent );
item0->SetSizeHints( parent );
}
}
return item0;
}
// Implement menubar functions
// Implement toolbar functions
// Implement bitmap functions
// End of generated file
|
[
"[email protected]"
] |
[
[
[
1,
475
]
]
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.