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
|
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
0b10a3e311a8bd01927f2cead8b961e6b48df931 | cd3cb866cf33bdd9584d08f4d5904123c7d93da6 | /tmxwindow.h | 61f13c04116adbbfddeb45360c74bb672c68004c | []
| no_license | benkopolis/conflict-resolver | d910aa0e771be2a1108203a3fd6da06ebdca5680 | d4185a15e5c2ac42034931913ca97714b21a977c | refs/heads/master | 2021-01-01T17:16:59.418070 | 2011-01-29T17:49:27 | 2011-01-29T17:49:27 | 32,231,168 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 612 | h | #ifndef TMXWINDOW_H
#define TMXWINDOW_H
#include <QMainWindow>
#include "files/tmxfile.h"
#include "records/tmxrecord.h"
namespace Ui {
class TMXWindow;
}
class TMXWindow : public QMainWindow {
Q_OBJECT
public:
TMXWindow(QWidget *parent = 0);
~TMXWindow();
public slots:
bool saveFiles(QString base);
Error addFile(QString filename);
protected:
void changeEvent(QEvent *e);
QList<TMXFile* > _files;
private:
Ui::TMXWindow *ui;
private slots:
void on__save_clicked();
void on__chooseDir_clicked();
};
#endif // TMXWINDOW_H
| [
"benkopolis@ce349ab3-abbd-076b-ff20-4646c42d6692"
]
| [
[
[
1,
36
]
]
]
|
1a2e596f046b221ec8f09490cf5ff25bf7aaa317 | ed6f03c2780226a28113ba535d3e438ee5d70266 | /src/eljimage.cpp | 03b6d2366f02fe7975c9b66c1a586c55102cb7fb | []
| no_license | snmsts/wxc | f06c0306d0ff55f0634e5a372b3a71f56325c647 | 19663c56e4ae2c79ccf647d687a9a1d42ca8cb61 | refs/heads/master | 2021-01-01T05:41:20.607789 | 2009-04-08T09:12:08 | 2009-04-08T09:12:08 | 170,876 | 4 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 5,714 | cpp | #include "wrapper.h"
extern "C"
{
EWXWEXPORT(wxImage*,wxImage_CreateDefault)()
{
return new wxImage();
}
EWXWEXPORT(wxImage*,wxImage_CreateSized)(int width,int height)
{
return new wxImage(width, height);
}
EWXWEXPORT(wxImage*,wxImage_CreateFromByteString)(char* data,size_t length,int type)
{
wxMemoryInputStream in(data,length);
return new wxImage(in, type);
}
EWXWEXPORT(wxImage*,wxImage_CreateFromLazyByteString)(char* data,size_t length,int type)
{
wxMemoryInputStream in(data,length);
return new wxImage(in, type);
}
EWXWEXPORT(size_t,wxImage_ConvertToByteString)(wxImage* self,int type,char* data)
{
wxMemoryOutputStream out;
self->SaveFile(out, type);
size_t len = out.GetLength();
return out.CopyTo(data, len);
}
EWXWEXPORT(size_t,wxImage_ConvertToLazyByteString)(wxImage* self,int type,char* data)
{
wxMemoryOutputStream out;
self->SaveFile(out, type);
size_t len = out.GetLength();
return out.CopyTo(data, len);
}
EWXWEXPORT(wxImage*,wxImage_CreateFromData)(int width,int height,void* data)
{
return new wxImage(width, height, (unsigned char*)data, true);
}
EWXWEXPORT(wxImage*,wxImage_CreateFromFile)(wxString* name)
{
return new wxImage(*name);
}
EWXWEXPORT(wxImage*,wxImage_CreateFromBitmap)(wxBitmap* bitmap)
{
return new wxImage(bitmap->ConvertToImage());
}
EWXWEXPORT(void,wxImage_ConvertToBitmap)(wxImage* self,wxBitmap* bitmap)
{
wxBitmap tmp(*self);
*bitmap = tmp;
}
EWXWEXPORT(void,wxImage_Initialize)(wxImage* self,int width,int height)
{
self->Create(width, height);
}
EWXWEXPORT(void,wxImage_InitializeFromData)(wxImage* self,int width,int height,void* data)
{
self->Create(width, height, (unsigned char*)data, true);
}
EWXWEXPORT(void,wxImage_Destroy)(wxImage* self)
{
self->Destroy();
}
EWXWEXPORT(void,wxImage_GetSubImage)(wxImage* self,int x,int y,int w,int h,wxImage* image)
{
*image = self->GetSubImage(wxRect(x, y, w, h));
}
EWXWEXPORT(void,wxImage_Paste)(wxImage* self,wxImage* image,int x,int y)
{
self->Paste(*image, x, y);
}
EWXWEXPORT(void,wxImage_Scale)(wxImage* self,int width,int height,wxImage* image)
{
*image = self->Scale(width, height);
}
EWXWEXPORT(void,wxImage_Rescale)(wxImage* self,int width,int height)
{
self->Rescale(width, height);
}
EWXWEXPORT(void,wxImage_Rotate)(wxImage* self,double angle,int c_x,int c_y,bool interpolating,void* offset_after_rotation,wxImage* image)
{
*image = self->Rotate(angle, wxPoint(c_x, c_y), interpolating, (wxPoint*)offset_after_rotation);
}
EWXWEXPORT(void,wxImage_Rotate90)(wxImage* self,bool clockwise,wxImage* image)
{
*image = self->Rotate90(clockwise);
}
EWXWEXPORT(void,wxImage_Mirror)(wxImage* self,bool horizontally,wxImage* image)
{
*image = self->Mirror(horizontally);
}
EWXWEXPORT(void,wxImage_Replace)(wxImage* self,wxUint8 r1,wxUint8 g1,wxUint8 b1,wxUint8 r2,wxUint8 g2,wxUint8 b2)
{
self->Replace(r1, g1, b1, r2, g2, b2);
}
EWXWEXPORT(void,wxImage_SetRGB)(wxImage* self,int x,int y,wxUint8 r,wxUint8 g,wxUint8 b)
{
self->SetRGB(x, y, r, g, b);
}
EWXWEXPORT(wxUint8,wxImage_GetRed)(wxImage* self,int x,int y)
{
return self->GetRed(x, y);
}
EWXWEXPORT(wxUint8,wxImage_GetGreen)(wxImage* self,int x,int y)
{
return self->GetGreen(x, y);
}
EWXWEXPORT(wxUint8,wxImage_GetBlue)(wxImage* self,int x,int y)
{
return self->GetBlue(x, y);
}
EWXWEXPORT(bool,wxImage_CanRead)(wxString* name)
{
return wxImage::CanRead(*name);
}
EWXWEXPORT(bool,wxImage_LoadFile)(wxImage* self,wxString* name,int type)
{
return self->LoadFile(*name, (long)type);
}
EWXWEXPORT(bool,wxImage_SaveFile)(wxImage* self,wxString* name,int type)
{
return self->SaveFile(*name, (long)type);
}
EWXWEXPORT(bool,wxImage_IsOk)(wxImage* self)
{
return self->IsOk();
}
EWXWEXPORT(int,wxImage_GetWidth)(wxImage* self)
{
return self->GetWidth();
}
EWXWEXPORT(int,wxImage_GetHeight)(wxImage* self)
{
return self->GetHeight();
}
EWXWEXPORT(void*,wxImage_GetData)(wxImage* self)
{
return (void*)self->GetData();
}
EWXWEXPORT(void,wxImage_SetData)(wxImage* self,void* data)
{
self->SetData((unsigned char*)data);
}
EWXWEXPORT(void,wxImage_SetDataAndSize)(wxImage* self,char* data,int new_width,int new_height)
{
self->SetData((unsigned char*)data, new_width, new_height);
}
EWXWEXPORT(void,wxImage_SetMaskColour)(wxImage* self,wxUint8 r,wxUint8 g,wxUint8 b)
{
self->SetMaskColour(r, g, b);
}
EWXWEXPORT(wxUint8,wxImage_GetMaskRed)(wxImage* self)
{
return self->GetMaskRed();
}
EWXWEXPORT(wxUint8,wxImage_GetMaskGreen)(wxImage* self)
{
return self->GetMaskGreen();
}
EWXWEXPORT(wxUint8,wxImage_GetMaskBlue)(wxImage* self)
{
return self->GetMaskBlue();
}
EWXWEXPORT(void,wxImage_SetMask)(wxImage* self,bool mask)
{
self->SetMask(mask);
}
EWXWEXPORT(bool,wxImage_HasMask)(wxImage* self)
{
return self->HasMask();
}
EWXWEXPORT(int,wxImage_CountColours)(wxImage* self,int stopafter)
{
return self->CountColours((long)stopafter);
}
EWXWEXPORT (wxString*,wxImage_GetOption)(wxImage* self,wxString* key)
{
return new wxString(self->GetOption(*key));
}
EWXWEXPORT (int,wxImage_GetOptionInt)(wxImage* self,wxString* key)
{
return self->GetOptionInt(*key);
}
EWXWEXPORT(void,wxImage_SetOption)(wxImage* self,wxString* key,wxString* value)
{
self->SetOption(*key,*value);
}
EWXWEXPORT(void,wxImage_SetOptionInt)(wxImage* self,wxString* key,int value)
{
self->SetOption(*key, value);
}
EWXWEXPORT(int,wxImage_HasOption)(wxImage* self,wxString* key)
{
return self->HasOption(*key);
}
}
| [
"[email protected]"
]
| [
[
[
1,
245
]
]
]
|
7f36e2a4520ba04d6fb61883817b765ebd27c283 | 8342f87cc7e048aa812910975c68babc6fb6c5d8 | /server/UDPConnection.cpp | 146f46ec905c8858932386fd3ab3e50d2e4cd29b | []
| no_license | espes/hoverrace | 1955c00961af4bb4f5c846f20e65ec9312719c08 | 7d5fd39ba688e2c537f35f7c723dedced983a98c | refs/heads/master | 2021-01-23T13:23:03.710443 | 2010-12-19T22:26:12 | 2010-12-19T22:26:12 | 2,005,364 | 0 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 1,779 | cpp | // GrokkSoft HoverRace SourceCode License v1.0, November 29, 2008
//
// Redistribution and use in source and binary forms, with or without modification,
// are permitted provided that the following conditions are met:
//
// - Redistributions in source code must retain the accompanying copyright notice,
// this list of conditions, and the following disclaimer.
// - Redistributions in binary form must reproduce the accompanying copyright
// notice, this list of conditions, and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// - Names of the copyright holders (Richard Langlois and Grokksoft inc.) must not
// be used to endorse or promote products derived from this software without
// prior written permission from the copyright holders.
// - This software, or its derivates must not be used for commercial activities
// without prior written permission from the copyright holders.
// - If any files are modified, you must cause the modified files to carry
// prominent notices stating that you changed the files and the date of any
// change.
//
// Disclaimer:
// The author makes no representations about the suitability of this software for
// any purpose. It is provided "AS IS", WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied.
//
/***
* UDPConnection.h
* Implementation of UDPConnection class, which abstracts away communication via
* UDP.
*
* @author Ryan Curtin
*/
#include "UDPConnection.h"
using namespace boost::asio;
using namespace boost::asio::ip;
UDPConnection::UDPConnection() { /* nothing to do */
void UDPConnection::setEndpoint(udp::endpoint &endpoint)
{
this->endpoint = endpoint;
}
| [
"ryan@7d5085ce-8879-48fc-b0cc-67565f2357fd"
]
| [
[
[
1,
43
]
]
]
|
dd7125fe05dc4c0a9eb5b008eca0ea267b4a8e42 | c440e6c62e060ee70b82fc07dfb9a93e4cc13370 | /src/gui2/moduleguiwindow.cpp | e9ee70f4934b0c475a91e4ec76cd2696be96b2e7 | []
| no_license | BackupTheBerlios/pgrtsound-svn | 2a3f2ae2afa4482f9eba906f932c30853c6fe771 | d7cefe2129d20ec50a9e18943a850d0bb26852e1 | refs/heads/master | 2020-05-21T01:01:41.354611 | 2005-10-02T13:09:13 | 2005-10-02T13:09:13 | 40,748,578 | 0 | 0 | null | null | null | null | WINDOWS-1250 | C++ | false | false | 1,215 | cpp | #include "moduleguiwindow.h"
#include "guimodule.h"
using namespace std;
ModuleGuiWindow::ModuleGuiWindow( GuiModule* guiModule ) :
parentGuiModule( guiModule )
{
nameLabel.set_text( Glib::locale_to_utf8("Nazwa: ") );
nameButton.set_label( Glib::locale_to_utf8("Zmień nazwę") );
nameBox.set_border_width( 2 );
nameBox.set_spacing( 5 );
nameBox.add( nameEntry );
nameBox.add( nameButton );
mainBox.set_spacing( 5 );
mainBox.add( nameBox );
add( mainBox );
resize( 200, get_height() );
nameButton.signal_clicked().connect( sigc::mem_fun( parentGuiModule, &GuiModule::ChangeName ) );
if( parentGuiModule->GetModule()->GetName() == "AudioPortIn"
|| parentGuiModule->GetModule()->GetName() == "AudioPortOut" ) {
nameEntry.set_sensitive( false );
nameButton.set_sensitive( false );
}
}
ModuleGuiWindow::~ModuleGuiWindow() {
//cout << "Zamykam okno GUI" << endl;
}
void ModuleGuiWindow::AddGui( Gtk::Widget *gui ) {
mainBox.add( separator );
mainBox.add( *gui );
}
const Glib::ustring ModuleGuiWindow::GetName() {
return nameEntry.get_text();
}
void ModuleGuiWindow::SetName( const Glib::ustring& str ) {
nameEntry.set_text( str );
}
| [
"ad4m@fa088095-53e8-0310-8a07-f9518708c3e6"
]
| [
[
[
1,
46
]
]
]
|
b650f2898d898e2852cb9d2ade54d253794ba4ee | 6131815bf1b62accfc529c2bc9db21194c7ba545 | /FrameworkApp/PrintQueue.cpp | 695986bbb28350b3006aab7bd658e9bbc01009eb | []
| no_license | dconefourseven/honoursproject | b2ee664ccfc880c008f29d89aad03d9458480fc8 | f26b967fda8eb6937f574fd6f3eb76c8fecf072a | refs/heads/master | 2021-05-29T07:14:35.261586 | 2011-05-15T18:27:49 | 2011-05-15T18:27:49 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,793 | cpp | #include "PrintQueue.h"
PrintQueue::PrintQueue(HANDLE mutex, queue<MyPacket_t>* send, queue<MyPacket_t>* receive)
{
mutexHandle = mutex;
SendQ = send;
ReceiveQ = receive;
}
bool PrintQueue::LoadThread(HANDLE mutex, queue<MyPacket_t>* send, queue<MyPacket_t>* receive, queue<ModelPacket>* sendUDP, queue<ModelPacket>* receiveUDP)
{
//Load the variables
mutexHandle = mutex;
SendQ = send;
ReceiveQ = receive;
SendQUDP = sendUDP;
ReceiveQUDP = receiveUDP;
// Print a quick statement so we know our thread started
std::cout << "Print thread Started\n\n";
//Class has loaded correctly
return true;
}
void PrintQueue::threadProc()
{
//WaitForSingleObject(mutexHandle, INFINITE);
// Print any data on the print receive queue
if (!ReceiveQ->empty())
{
//if(strcmp(ReceiveQ->front().Buffer, "quit"))
{
std::cout << "CPrintQueue: Received -> " << ReceiveQ->front().Buffer << " " << "ID=" << ReceiveQ->front().ID << std::endl;
/*cout << "Position.x = " << ReceiveQ->front().Position.x << endl;
cout << "Position.y = " << ReceiveQ->front().Position.y << endl;
cout << "Position.z = " << ReceiveQ->front().Position.z << endl;
cout << "Velocity.x = " << ReceiveQ->front().Velocity.x << endl;
cout << "Velocity.y = " << ReceiveQ->front().Velocity.y << endl;
cout << "Velocity.z = " << ReceiveQ->front().Velocity.z << endl;
cout << "Angular Velocity = " << ReceiveQ->front().AngularVelocity << endl;*/
ReceiveQ->pop();
}
}
//if( !ReceiveQUDP->empty())
//{
// cout << "UDP CPrintQueue: Received -> " << ReceiveQUDP->front().Buffer << " " << "ID=" << ReceiveQUDP->front().ID << endl;
// printf("Position.x = %f\n", ReceiveQUDP->front().Position.x);
// printf("Position.y = %f\n", ReceiveQUDP->front().Position.y);
// printf("Position.z = %f\n", ReceiveQUDP->front().Position.z);
// printf("Velocity.x = %f\n", ReceiveQUDP->front().Velocity.x);
// printf("Velocity.y = %f\n", ReceiveQUDP->front().Velocity.y);
// printf("Velocity.z = %f\n", ReceiveQUDP->front().Velocity.z);
// printf("Angle = %f\n", ReceiveQUDP->front().Angle);
// printf("Angular Velocity = %f\n", ReceiveQUDP->front().AngularVelocity);
//
// //ReceiveQUDP->pop();
//}
//// Print any data on the print receive queue
//if (!SendQ->empty())
//{
// cout << "CPrintQueue: Sent -> " << SendQ->front().Buffer << " " << "ID=" << SendQ->front().ID << endl;
// SendQ->pop();
//}
//ReleaseMutex(mutexHandle);
// Sleep a little bit so we can observe our thread working
//Sleep(1000);
//// Print a quick note so we know our thread ended
//cout << "PrintQueue Thread Exiting\n";
}
void PrintQueue::end()
{
}
void PrintQueue::begin()
{
} | [
"davidclarke1990@fa56ba20-0011-6cdf-49b4-5b20436119f6"
]
| [
[
[
1,
84
]
]
]
|
552f2d17e037ba2dfae89b5bb580a068ec23c982 | 968aa9bac548662b49af4e2b873b61873ba6f680 | /imgtools/romtools/readimage/inc/e32_image_reader.h | 8840553e944d4f39028a72b7941112ca75b5101a | []
| no_license | anagovitsyn/oss.FCL.sftools.dev.build | b3401a1ee3fb3c8f3d5caae6e5018ad7851963f3 | f458a4ce83f74d603362fe6b71eaa647ccc62fee | refs/heads/master | 2021-12-11T09:37:34.633852 | 2010-12-01T08:05:36 | 2010-12-01T08:05:36 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 938 | h | /*
* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
* All rights reserved.
* This component and the accompanying materials are made available
* under the terms of the License "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:
* @internalComponent
* @released
*
*/
#ifndef __E32_IMAGE_READER__
#define __E32_IMAGE_READER__
#include "image_reader.h"
class E32ImageReader : public ImageReader
{
public:
E32ImageReader();
E32ImageReader(const char* aFile);
~E32ImageReader();
void ReadImage();
void ProcessImage();
void Validate();
void Dump();
static void DumpE32Attributes(E32ImageFile& aE32Image);
E32ImageFile *iE32Image;
};
#endif //__E32_IMAGE_READER__
| [
"none@none"
]
| [
[
[
1,
43
]
]
]
|
192462265721fe9cd8d75252e94bb5f8616e7e97 | a1e5c0a674084927ef5b050ebe61a89cd0731bc6 | /OpenGL_SceneGraph_Stussman/Code/Aufgabe4/include/nodes/lightnode.h | b2506fabf1479f1cfd353949038d7cb9dd6dfcd5 | []
| no_license | danielkummer/scenegraph | 55d516dc512e1b707b6d75ec2741f48809d8797f | 6c67c41a38946ac413333a84c76340c91b87dc96 | refs/heads/master | 2016-09-01T17:36:02.995636 | 2008-06-05T09:45:24 | 2008-06-05T09:45:24 | 32,327,185 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,113 | h | #ifndef _H_LIGHTNODE
#define _H_LIGHTNODE
#ifdef WIN32
#include <windows.h>
#else
#include <GL/glx.h>
#include <stdarg.h>
#endif
#include <GL/gl.h>
#include <GL/glu.h>
//#include "nodes/abstractnode.h"
#include "nodes/togglenode.h"
class LightNode:public ToggleNode{
public:
LightNode(GLenum aLightNr);
LightNode(GLenum aLightNr,
float posX,
float posY,
float posZ,
float posW,
float ambA,
float ambB,
float ambC,
float ambD,
float diffA,
float diffB,
float diffC,
float diffD);
virtual ~LightNode();
void setParam(GLenum aParamType, float aA, float aB, float aC, float aD);
virtual void accept(AbstractVisitor &aVisitor);
void setPos();
void on();
void off();
bool toggle();
private:
GLenum mLightNr;
float* mPos;
};
#endif // _H_LIGHTNODE
| [
"dr0iddr0id@fe886383-234b-0410-a1ab-e127868e2f45",
"[email protected]@fe886383-234b-0410-a1ab-e127868e2f45"
]
| [
[
[
1,
19
],
[
21,
47
]
],
[
[
20,
20
]
]
]
|
8fe8ba632000bdb8cd9cadc20f32544d205b51e0 | 463c3b62132d215e245a097a921859ecb498f723 | /lib/dlib/matrix/matrix_default_mul.h | 77c1ca01a3b269f93c1d1801ade878404797c5cf | [
"LicenseRef-scancode-unknown-license-reference",
"BSL-1.0"
]
| permissive | athulan/cppagent | 58f078cee55b68c08297acdf04a5424c2308cfdc | 9027ec4e32647e10c38276e12bcfed526a7e27dd | refs/heads/master | 2021-01-18T23:34:34.691846 | 2009-05-05T00:19:54 | 2009-05-05T00:19:54 | 197,038 | 4 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 4,902 | h | // Copyright (C) 2008 Davis E. King ([email protected])
// License: Boost Software License See LICENSE.txt for the full license.
#ifndef DLIB_MATRIx_DEFAULT_MULTIPLY_
#define DLIB_MATRIx_DEFAULT_MULTIPLY_
#include "../geometry.h"
#include "matrix.h"
#include "matrix_utilities.h"
#include "../enable_if.h"
namespace dlib
{
// ------------------------------------------------------------------------------------
namespace ma
{
template < typename EXP, typename enable = void >
struct matrix_is_vector { static const bool value = false; };
template < typename EXP >
struct matrix_is_vector<EXP, typename enable_if_c<EXP::NR==1 || EXP::NC==1>::type > { static const bool value = true; };
}
// ------------------------------------------------------------------------------------
/*! This file defines the default_matrix_multiply() function. It is a function
that conforms to the following definition:
template <
typename matrix_dest_type,
typename EXP1,
typename EXP2
>
void default_matrix_multiply (
matrix_dest_type& dest,
const EXP1& lhs,
const EXP2& rhs
);
requires
- (lhs*rhs).destructively_aliases(dest) == false
- dest.nr() == (lhs*rhs).nr()
- dest.nc() == (lhs*rhs).nc()
ensures
- #dest == dest + lhs*rhs
!*/
// ------------------------------------------------------------------------------------
template <
typename matrix_dest_type,
typename EXP1,
typename EXP2
>
typename enable_if_c<ma::matrix_is_vector<EXP1>::value == true || ma::matrix_is_vector<EXP2>::value == true>::type
default_matrix_multiply (
matrix_dest_type& dest,
const EXP1& lhs,
const EXP2& rhs
)
{
matrix_assign_default(dest, lhs*rhs, 1, true);
}
// ------------------------------------------------------------------------------------
template <
typename matrix_dest_type,
typename EXP1,
typename EXP2
>
typename enable_if_c<ma::matrix_is_vector<EXP1>::value == false && ma::matrix_is_vector<EXP2>::value == false>::type
default_matrix_multiply (
matrix_dest_type& dest,
const EXP1& lhs,
const EXP2& rhs
)
{
const long bs = 90;
// if the matrices are small enough then just use the simple multiply algorithm
if (lhs.nc() <= 2 || rhs.nc() <= 2 || lhs.nr() <= 2 || rhs.nr() <= 2 || (lhs.size() <= bs*10 && rhs.size() <= bs*10) )
{
matrix_assign_default(dest, lhs*rhs, 1, true);
}
else
{
// if the lhs and rhs matrices are big enough we should use a cache friendly
// algorithm that computes the matrix multiply in blocks.
// Loop over all the blocks in the lhs matrix
for (long r = 0; r < lhs.nr(); r+=bs)
{
for (long c = 0; c < lhs.nc(); c+=bs)
{
// make a rect for the block from lhs
rectangle lhs_block(c, r, std::min(c+bs-1,lhs.nc()-1), std::min(r+bs-1,lhs.nr()-1));
// now loop over all the rhs blocks we have to multiply with the current lhs block
for (long i = 0; i < rhs.nc(); i += bs)
{
// make a rect for the block from rhs
rectangle rhs_block(i, c, std::min(i+bs-1,rhs.nc()-1), std::min(c+bs-1,rhs.nr()-1));
// make a target rect in res
rectangle res_block(rhs_block.left(),lhs_block.top(), rhs_block.right(), lhs_block.bottom());
// This loop is optimized assuming that the data is laid out in
// row major order in memory.
for (long r = lhs_block.top(); r <= lhs_block.bottom(); ++r)
{
for (long c = lhs_block.left(); c<= lhs_block.right(); ++c)
{
const typename EXP2::type temp = lhs(r,c);
for (long i = rhs_block.left(); i <= rhs_block.right(); ++i)
{
dest(r,i) += rhs(c,i)*temp;
}
}
}
}
}
}
}
}
// ------------------------------------------------------------------------------------
}
#endif // DLIB_MATRIx_DEFAULT_MULTIPLY_
| [
"jimmy@DGJ3X3B1.(none)"
]
| [
[
[
1,
134
]
]
]
|
a9f1dc5ea90094c935e1982b96d2035ffe4983bf | cd0987589d3815de1dea8529a7705caac479e7e9 | /includes/webkitsupport/platform/BlackBerryPlatformMisc.h | 2692d7c3fe43c2b5be9a8fe6c8e005dfa5e06679 | []
| no_license | azrul2202/WebKit-Smartphone | 0aab1ff641d74f15c0623f00c56806dbc9b59fc1 | 023d6fe819445369134dee793b69de36748e71d7 | refs/heads/master | 2021-01-15T09:24:31.288774 | 2011-07-11T11:12:44 | 2011-07-11T11:12:44 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,074 | h | /*
* Copyright (C) 2009 Research In Motion Limited. http://www.rim.com/
*/
#ifndef BlackBerryPlatformMisc_h
#define BlackBerryPlatformMisc_h
#include "BlackBerryPlatformPrimitives.h"
#include "memorymanagement/VirtualMemoryManager.h"
// FIXME these should be removed, here for backwards compatibility
// with BlackBerryPlatformMisc.h before refactoring
#include "BlackBerryPlatformCursor.h"
#include "BlackBerryPlatformInputEvents.h"
#include "BlackBerryPlatformLog.h"
#include "BlackBerryPlatformWorker.h"
#include <stdarg.h>
#include <string>
#ifndef BRIDGE_IMPORT
#ifdef _MSC_VER
#define BRIDGE_IMPORT __declspec(dllimport)
#else
#define BRIDGE_IMPORT
#endif
#endif
namespace BlackBerry {
namespace Platform {
// Return current UTC time in seconds
double currentUTCTimeMS();
double tickCount();
void* stackBase();
void addStackBase(void* base);
void removeStackBase();
void willRunEventLoop();
void processNextEvent();
void scheduleLazyInitialization();
void scheduleCallOnMainThread(void(*callback)(void));
const char* environment(const char* key);
#ifdef _MSC_VER
// FIXME: on device, environment is just a wrapper around getenv. On
// simulator, we need to add strings to the environment by hand.
// see http://bugzilla-torch.rim.net/show_bug.cgi?id=707; remove this function when it is fixed
void addToEnvironment(const char* key, const char* value);
#endif
struct MemoryStatus {
unsigned baseAddress;
unsigned committedPhysicalMemory;
unsigned availableVirtualMemory;
unsigned availablePhysicalMemory;
unsigned lowPhysicalMemoryThreshold;
unsigned systemAllocatedMemory;
unsigned usedMemory;
unsigned freeMemory;
};
void getMemoryStatus(MemoryStatus& status);
} // Platform
} // Olympia
#endif // BlackBerryPlatformMisc_h
| [
"[email protected]"
]
| [
[
[
1,
74
]
]
]
|
bfa86c051ab05d6629fb750576eea030eb31ab72 | c5ecda551cefa7aaa54b787850b55a2d8fd12387 | /src/UILayer/DlgMainTabAdvance.cpp | 161e006a357cbbddf2c2fff5217acf7e72676cc6 | []
| 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,598 | cpp | // DlgMainTabAdvance.cpp : 实现文件
//
#include "stdafx.h"
#include "DlgMainTabAdvance.h"
#include ".\dlgmaintabadvance.h"
// CDlgMainTabAdvance 对话框
IMPLEMENT_DYNAMIC(CDlgMainTabAdvance, CDialog)
CDlgMainTabAdvance::CDlgMainTabAdvance(CWnd* pParent /*=NULL*/)
: CDialog(CDlgMainTabAdvance::IDD, pParent)
{
}
CDlgMainTabAdvance::~CDlgMainTabAdvance()
{
}
void CDlgMainTabAdvance::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
}
BEGIN_MESSAGE_MAP(CDlgMainTabAdvance, CDialog)
ON_WM_CREATE()
ON_WM_SIZE()
ON_WM_ERASEBKGND()
END_MESSAGE_MAP()
// CDlgMainTabAdvance 消息处理程序
int CDlgMainTabAdvance::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CDialog::OnCreate(lpCreateStruct) == -1)
return -1;
ModifyStyle(0, WS_CLIPCHILDREN);
// TODO: 在此添加您专用的创建代码
m_tbwAdvance.Create(WS_CHILD | WS_VISIBLE, CRect(0, 0, 0, 0), this);
return 0;
}
void CDlgMainTabAdvance::OnSize(UINT nType, int cx, int cy)
{
CDialog::OnSize(nType, cx, cy);
// TODO: 在此处添加消息处理程序代码
m_tbwAdvance.MoveWindow(0, 0, cx, cy, FALSE);
}
BOOL CDlgMainTabAdvance::OnEraseBkgnd(CDC* /*pDC*/)
{
// TODO: 在此添加消息处理程序代码和/或调用默认值
return TRUE;
//return CDialog::OnEraseBkgnd(pDC);
}
void CDlgMainTabAdvance::OnCancel()
{
// TODO: 在此添加专用代码和/或调用基类
//CDialog::OnCancel();
}
void CDlgMainTabAdvance::OnOK()
{
// TODO: 在此添加专用代码和/或调用基类
//CDialog::OnOK();
}
| [
"LanceFong@4a627187-453b-0410-a94d-992500ef832d"
]
| [
[
[
1,
74
]
]
]
|
84626dd8205372c6619e9c2333b4feb8997bb2be | 49f5a108a2ac593b9861f9747bd82eb597b01e24 | /src/JSON/MiniCommon/Random.h | f61891a07eec168bcdbaf515290fc819e07d9791 | []
| no_license | gpascale/iSynth | 5801b9a1b988303ad77872fad98d4bf76d86e8fe | e45e24590fabb252a5ffd10895b2cddcc988b83d | refs/heads/master | 2021-03-19T06:01:57.451784 | 2010-08-02T02:22:54 | 2010-08-02T02:22:54 | 811,695 | 0 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 4,252 | h | #ifndef Random_h
#define Random_h
// VRandom number generators.
long & RandomNumberStream_();
/// Basic generators adapted from Press et al., Numerical Recipes in C.
/// These are designed to output numbers in a flat distribution on the open
/// interval (0,1). The argument is the internal random number stream, which
/// is modified on sequential calls.
double Ran0(long & i); /// fast
double Ran1(long & i); /// not as fast, but more correlation-m_maxConcurrentConnection
/// Random bit (0 or 1)
int RanBit(unsigned long & i);
double Gaussian0(long & i); /// Gaussian deviates with variance 1; uses Ran0()
void GaussianPair0(long & i, double & g1, double & g2); /// two Gaussians as above
inline void GaussianPair0(long & i, float & g1, float & g2) {
double x,y;
GaussianPair0(i,x,y);
g1 = float(x);
g2 = float(y);
}
double Gaussian1(long & i); /// Gaussian deviates with variance 1; uses Ran1()
void GaussianPair1(long & i, double & g1, double & g2); /// two Gaussians as above
inline void GaussianPair1(long & i, float & g1, float & g2) {
double x,y;
GaussianPair1(i,x,y);
g1 = float(x);
g2 = float(y);
}
/// The simple single-threaded versions use a global number stream variable;
/// they are very easy to use, but they are not thread-safe!
/// Also, because they all use the same stream, note that intermixing calls
/// to different generators is not recommended.
inline double Ran0() { return Ran0(RandomNumberStream_()); }
inline double Ran1() { return Ran1(RandomNumberStream_()); }
inline double Gaussian0() { return Gaussian1(RandomNumberStream_()); }
inline double Gaussian1() { return Gaussian1(RandomNumberStream_()); }
inline void GaussianPair0(double & g1, double & g2) { GaussianPair0(RandomNumberStream_(), g1,g2); }
inline void GaussianPair0( float & g1, float & g2) { GaussianPair0(RandomNumberStream_(), g1,g2); }
inline void GaussianPair1(double & g1, double & g2) { GaussianPair1(RandomNumberStream_(), g1,g2); }
inline void GaussianPair1( float & g1, float & g2) { GaussianPair1(RandomNumberStream_(), g1,g2); }
template <class T> inline int RanI(T N) { return T(Ran0() * N); }
unsigned TimeSeed();
inline void RanTimeSeed() { RandomNumberStream_() = (long)TimeSeed(); }
namespace VRandom {
/// The default implementation of TimeSeed uses the number of milliseconds
/// since 1970 plus the number of milliseconds (modulo one second) that the
/// current process has been running. For 32-bit random number streams,
/// this means a compromise: there is a new stream every millisecond, but
/// an overall period of about 50 days. Of course, assuming that fresh
/// streams are not initialized within a millisecond of each other, it is
/// highly unlikely that a stream will ever be repeated. If a number of
/// streams are to be initialized at once, initialize one from the timer
/// using an alternative generator; then initialize the streams to be used
/// with seeds from the alternative generator. It is best to avoid
/// multiple streams altogether, if possible.
// Flat0 and Flat1 wrap the Ran0 and Ran1 functions.
class Flat0 {
public:
unsigned stream;
Flat0() : stream(TimeSeed()) {}
Flat0(unsigned which) : stream(which) {}
operator double () { return Ran0((long &)stream); }
};
class Flat1 {
public:
unsigned stream;
Flat1() : stream(TimeSeed()) {}
Flat1(unsigned which) : stream(which) {}
operator double () { return Ran1((long &)stream); }
};
class Gauss0 {
public:
unsigned stream;
Gauss0() : stream(TimeSeed()) {}
Gauss0(unsigned which) : stream(which) {}
operator double () { return Gaussian0((long &)stream); }
};
class Gauss1 {
public:
unsigned stream;
Gauss1() : stream(TimeSeed()) {}
Gauss1(unsigned which) : stream(which) {}
operator double () { return Gaussian1((long &)stream); }
};
};
#endif // Random_h
| [
"[email protected]"
]
| [
[
[
1,
106
]
]
]
|
bb97769b4a374112e80f94577e0fd5fbdc5e707b | 2d22825193eacf3669ac8bd7a857791745a9ead4 | /HairSimulation/HairSimulation/DynamicsLib/box.h | 1faafb9b290b8c6d4fb2a500e5a1158983b3a04f | []
| no_license | dtbinh/com-animation-classprojects | 557ba550b575c3d4efc248f7984a3faac8f052fd | 37dc800a6f2bac13f5aa4fc7e0e96aa8e9cec29e | refs/heads/master | 2021-01-06T20:45:42.613604 | 2009-01-20T00:23:11 | 2009-01-20T00:23:11 | 41,496,905 | 0 | 0 | null | null | null | null | BIG5 | C++ | false | false | 3,833 | h | #ifndef BOX_H
#define BOX_H
#include <Ogre.h>
using namespace Ogre;
//#include "glut.h"
//~~~~~~~~~ Bounding Box ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
class BoundBox{
public:
Vector3 center;
Vector3 dim; // dimension of this box. dim = (max - min)/2
Vector3 bounds[2]; // { min, max }
inline void display() const;
inline int longestAxis() const;
inline bool BallBoxIntersect( const Vector3 & C, float R2 ) const;
inline bool boxBoxIntersect( const BoundBox & B ) const;
};
// 找出最長的軸
// 0,1,2 對應 x,y,z
int BoundBox::longestAxis() const
{
int longest = 0;
if( dim.x > dim.z ){
if( dim.x > dim.y ){
longest = 0;
}else{
longest = 1;
}
}else{
if( dim.y > dim.z ){
longest = 1;
}else{
longest = 2;
}
}
return longest;
}
//~~~~ box-box intersect ~~~~
bool BoundBox::boxBoxIntersect( const BoundBox & B ) const
{
for( int i = 0; i < 3; i++ ){
if( bounds[0][i] > B.bounds[1][i] ||
B.bounds[0][i] > bounds[1][i] )
{
return false;
}
}
return true;
}
bool BoundBox::BallBoxIntersect(const Vector3 &C, float R2) const
{
float D = 0; // distance
for( int i = 0; i < 3; i++ ){
if( C[i] < bounds[0][i] ){ // C[i] < min[i]
float x = C[i] - bounds[0][i];
D += x * x;
}else if( C[i] > bounds[1][i] ){
float x = C[i] - bounds[1][i];
D += x * x;
}
}
if( D <= R2 ){
//std::cout << "ball hit box" << std::endl;
return true;
}
return false;
}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//畫出方盒子
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
void BoundBox::display() const
{
/*
//畫出方盒子
glBegin(GL_LINE_LOOP);
glVertex3f( center[0] +dim[0], center[1] +dim[1], center[2] +dim[2] );
glVertex3f( center[0] +dim[0], center[1] -dim[1], center[2] +dim[2] );
glVertex3f( center[0] +dim[0], center[1] -dim[1], center[2] -dim[2] );
glVertex3f( center[0] +dim[0], center[1] +dim[1], center[2] -dim[2] );
glEnd();
glBegin(GL_LINE_LOOP);
glVertex3f( center[0] -dim[0], center[1] +dim[1], center[2] +dim[2] );
glVertex3f( center[0] -dim[0], center[1] -dim[1], center[2] +dim[2] );
glVertex3f( center[0] -dim[0], center[1] -dim[1], center[2] -dim[2] );
glVertex3f( center[0] -dim[0], center[1] +dim[1], center[2] -dim[2] );
glEnd();
glBegin(GL_LINE_LOOP);
glVertex3f( center[0] +dim[0], center[1] +dim[1], center[2] +dim[2] );
glVertex3f( center[0] -dim[0], center[1] +dim[1], center[2] +dim[2] );
glVertex3f( center[0] -dim[0], center[1] +dim[1], center[2] -dim[2] );
glVertex3f( center[0] +dim[0], center[1] +dim[1], center[2] -dim[2] );
glEnd();
glBegin(GL_LINE_LOOP);
glVertex3f( center[0] +dim[0], center[1] -dim[1], center[2] +dim[2] );
glVertex3f( center[0] -dim[0], center[1] -dim[1], center[2] +dim[2] );
glVertex3f( center[0] -dim[0], center[1] -dim[1], center[2] -dim[2] );
glVertex3f( center[0] +dim[0], center[1] -dim[1], center[2] -dim[2] );
glEnd();
glBegin(GL_LINE_LOOP);
glVertex3f( center[0] +dim[0], center[1] +dim[1], center[2] +dim[2] );
glVertex3f( center[0] -dim[0], center[1] +dim[1], center[2] +dim[2] );
glVertex3f( center[0] -dim[0], center[1] -dim[1], center[2] +dim[2] );
glVertex3f( center[0] +dim[0], center[1] -dim[1], center[2] +dim[2] );
glEnd();
glBegin(GL_LINE_LOOP);
glVertex3f( center[0] +dim[0], center[1] +dim[1], center[2] -dim[2] );
glVertex3f( center[0] -dim[0], center[1] +dim[1], center[2] -dim[2] );
glVertex3f( center[0] -dim[0], center[1] -dim[1], center[2] -dim[2] );
glVertex3f( center[0] +dim[0], center[1] -dim[1], center[2] -dim[2] );
glEnd();
*/
//glPushMatrix();
//glTranslatef( center.x, center.y, center.z );
//glPopMatrix();
}
#endif | [
"grahamhuang@73147322-a748-11dd-a8c6-677c70d10fe4"
]
| [
[
[
1,
123
]
]
]
|
175663fe79fe127bdcc2f2cfe39c3c3471172ff2 | 208475bcab65438eed5d8380f26eacd25eb58f70 | /QianExe/LN_Report.h | 262c156c10bf3f65f5f8e5552a31545603eed63a | []
| no_license | awzhang/MyWork | 83b3f0b9df5ff37330c0e976310d75593f806ec4 | 075ad5d0726c793a0c08f9158080a144e0bb5ea5 | refs/heads/master | 2021-01-18T07:57:03.219372 | 2011-07-05T02:41:55 | 2011-07-05T02:46:30 | 15,523,223 | 1 | 2 | null | null | null | null | UTF-8 | C++ | false | false | 2,176 | h | #ifndef _LN_REPORT_H_
#define _LN_REPORT_H_
class CLN_Report
{
public:
CLN_Report();
virtual ~CLN_Report();
public:
int Init();
int Release();
int SetAlert(bool v_bEnable, DWORD v_dwAlertType, DWORD SubPar);
void SendOneAlertReport(short v_shAlermType, char *v_szRID, byte v_bytPriority);
void P_TmAlertReport();
int BeginPositionReport(char *v_szId, char *v_szBeginTime, char v_szIntervalType, DWORD v_dwIntervalValue, char v_szEndType, DWORD v_dwMaxCnt, char *v_szEndTime);
void P_TmAutoReport();
void SendOnePositionReport(char v_szReportType);
int BeginSpeedCheck();
int EndSpeedCheck();
void P_TmSpeedCheck();
int BeginAreaCheck();
int EndAreaCheck();
void P_TmAreaCheck();
bool AreaEnCheck(tag2QAreaRptCfg *objAreaRptCfg);
int BeginStartengCheck();
int EndStartengCheck();
void P_TmStartengCheck();
int BeginSpeedRptCheck();
int EndSpeedRptCheck();
void P_TmSpeedRptCheck();
bool SpeedEnCheck(tag2QAreaSpdRptCfg *objAreaSpdRptCfg);
int BeginParkTimeRptCheck();
int EndParkTimeRptCheck();
void P_TmParkTimeRptCheck();
bool ParkTimeEnCheck(tag2QAreaParkTimeRptCfg *objAreaParkTimeRptCfg);
int BeginOutLineRptCheck();
int EndOutLineRptCheck();
void P_TmOutLineRptCheck();
bool OutLineEnCheck(tag2QLineRptCfg *objLineRptCfg);
int BeginTireRptCheck();
int EndTireRptCheck();
void P_TmTireRptCheck();
int BeginMileRptCheck();
int EndMileRptCheck();
void P_TmMileRptCheck();
bool LocalTypeToReportType(DWORD v_dwLocalType, short *v_shReportType);
bool ReportTyepToLocalType(short v_shReportType, DWORD &v_dwLocalType);
byte m_accsta;
DWORD m_dwAreaParkTime[MAX_AREA_COUNT], m_dwInRegPatkTime[MAX_AREA_COUNT], m_dwOutRegPatkTime[MAX_AREA_COUNT], m_dwParkTime;
private:
DWORD m_dwReportFlag;
char m_szRID[32][20];
byte m_bytPriority[32];
ushort m_usInterval[32];
int m_iReportTimers[32];
int m_iMaxTimers[32];
DWORD m_dwLastReportTm[32];
DWORD m_dwDriverTime;
DWORD m_dwRestTime;
pthread_mutex_t m_mutex_alert;
byte m_bytSpdOverValue;
tag2QAlertCfg m_objAlertCfg;
tag2QAutoRptCfg m_objAutoCfg;
};
#endif
| [
"[email protected]"
]
| [
[
[
1,
80
]
]
]
|
c48fb1a4ff2239b038d66f2ef6c50ca913eae547 | ade08cd4a76f2c4b9b5fdbb9b9edfbc7996b1bbc | /computer_graphics/lab2/Src/Application/scene.cpp | 7d172543057fc2fe9906485c50af8240befd35a3 | []
| no_license | smi13/semester07 | 6789be72d74d8d502f0a0d919dca07ad5cbaed0d | 4d1079a446269646e1a0e3fe12e8c5e74c9bb409 | refs/heads/master | 2021-01-25T09:53:45.424234 | 2011-01-07T16:08:11 | 2011-01-07T16:08:11 | 859,509 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,694 | cpp | #include <d3dx9.h>
#include "scene.h"
using namespace cg_labs;
void Renderer::render( Scene &scene )
{
for (ObjectToNameMap::iterator it = scene._objects.begin(); it != scene._objects.end(); ++it)
it->second->render();
for (LightToNameMap::iterator it = scene._lights.begin(); it != scene._lights.end(); ++it)
it->second->getObject()->render();
}
void Renderer::lightUp( Scene &scene )
{
for (LightToNameMap::iterator it = scene._lights.begin(); it != scene._lights.end(); ++it)
it->second->set();
}
Scene::Scene()
{
}
Scene &Scene::operator<<( Object *new_object )
{
_objects.insert(std::make_pair(new_object->getName(), new_object));
return *this;
}
Scene &Scene::operator<<( Light *new_light )
{
_lights.insert(std::make_pair(new_light->getName(), new_light));
return *this;
}
Object * Scene::getObject( std::string &name )
{
ObjectToNameMap::iterator it = _objects.find(name);
if (it == _objects.end())
return 0;
return it->second;
}
Object * Scene::getObject( const char *name )
{
return getObject(std::string(name));
}
Light * Scene::getLight( std::string &name )
{
LightToNameMap::iterator it = _lights.find(name);
if (it == _lights.end())
return 0;
return it->second;
}
Light * Scene::getLight( const char *name )
{
return getLight(std::string(name));
}
Scene::~Scene()
{
for (ObjectToNameMap::iterator it = _objects.begin(); it != _objects.end(); ++it)
{
delete it->second;
}
for (LightToNameMap::iterator it = _lights.begin(); it != _lights.end(); ++it)
{
delete it->second;
}
} | [
"[email protected]"
]
| [
[
[
1,
81
]
]
]
|
bfe34e55cad6fc9d80e55e3a79df3326edec5116 | f8403b6b1005f80d2db7fad9ee208887cdca6aec | /JuceLibraryCode/modules/juce_gui_basics/filebrowser/juce_FileTreeComponent.h | 534bd505000e749c4d7fc8a2e0094cec1885fabe | []
| no_license | sonic59/JuceText | 25544cb07e5b414f9d7109c0826a16fc1de2e0d4 | 5ac010ffe59c2025d25bc0f9c02fc829ada9a3d2 | refs/heads/master | 2021-01-15T13:18:11.670907 | 2011-10-29T19:03:25 | 2011-10-29T19:03:25 | 2,507,112 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,928 | h | /*
==============================================================================
This file is part of the JUCE library - "Jules' Utility Class Extensions"
Copyright 2004-11 by Raw Material Software Ltd.
------------------------------------------------------------------------------
JUCE can be redistributed and/or modified under the terms of the GNU General
Public License (Version 2), as published by the Free Software Foundation.
A copy of the license is included in the JUCE distribution, or can be found
online at www.gnu.org/licenses.
JUCE 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.
------------------------------------------------------------------------------
To release a closed-source product which uses JUCE, commercial licenses are
available: visit www.rawmaterialsoftware.com/juce for more information.
==============================================================================
*/
#ifndef __JUCE_FILETREECOMPONENT_JUCEHEADER__
#define __JUCE_FILETREECOMPONENT_JUCEHEADER__
#include "juce_DirectoryContentsDisplayComponent.h"
#include "../widgets/juce_TreeView.h"
//==============================================================================
/**
A component that displays the files in a directory as a treeview.
This implements the DirectoryContentsDisplayComponent base class so that
it can be used in a FileBrowserComponent.
To attach a listener to it, use its DirectoryContentsDisplayComponent base
class and the FileBrowserListener class.
@see DirectoryContentsList, FileListComponent
*/
class JUCE_API FileTreeComponent : public TreeView,
public DirectoryContentsDisplayComponent
{
public:
//==============================================================================
/** Creates a listbox to show the contents of a specified directory.
*/
FileTreeComponent (DirectoryContentsList& listToShow);
/** Destructor. */
~FileTreeComponent();
//==============================================================================
/** Returns the number of files the user has got selected.
@see getSelectedFile
*/
int getNumSelectedFiles() const { return TreeView::getNumSelectedItems(); }
/** Returns one of the files that the user has currently selected.
The index should be in the range 0 to (getNumSelectedFiles() - 1).
@see getNumSelectedFiles
*/
File getSelectedFile (int index = 0) const;
/** Deselects any files that are currently selected. */
void deselectAllFiles();
/** Scrolls the list to the top. */
void scrollToTop();
/** If the specified file is in the list, it will become the only selected item
(and if the file isn't in the list, all other items will be deselected). */
void setSelectedFile (const File&);
/** Setting a name for this allows tree items to be dragged.
The string that you pass in here will be returned by the getDragSourceDescription()
of the items in the tree. For more info, see TreeViewItem::getDragSourceDescription().
*/
void setDragAndDropDescription (const String& description);
/** Returns the last value that was set by setDragAndDropDescription().
*/
const String& getDragAndDropDescription() const noexcept { return dragAndDropDescription; }
private:
//==============================================================================
String dragAndDropDescription;
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (FileTreeComponent);
};
#endif // __JUCE_FILETREECOMPONENT_JUCEHEADER__
| [
"[email protected]"
]
| [
[
[
1,
98
]
]
]
|
e29d544016975f9f4c9b054aeb60bc7730e3cf95 | 3d7fc34309dae695a17e693741a07cbf7ee26d6a | /thirdparty/JAMA/jama_cholesky.h | 6d6d3d93ecab0eb3d8c310bc14264e8bd50a2c64 | [
"LicenseRef-scancode-public-domain"
]
| permissive | nist-ionstorage/ionizer | f42706207c4fb962061796dbbc1afbff19026e09 | 70b52abfdee19e3fb7acdf6b4709deea29d25b15 | refs/heads/master | 2021-01-16T21:45:36.502297 | 2010-05-14T01:05:09 | 2010-05-14T01:05:09 | 20,006,050 | 5 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 5,495 | h | #ifndef JAMA_CHOLESKY_H
#define JAMA_CHOLESKY_H
#include "math.h"
/* needed for sqrt() below. */
namespace JAMA
{
using namespace TNT;
/**
<P>
For a symmetric, positive definite matrix A, this function
computes the Cholesky factorization, i.e. it computes a lower
triangular matrix L such that A = L*L'.
If the matrix is not symmetric or positive definite, the function
computes only a partial decomposition. This can be tested with
the is_spd() flag.
<p>Typical usage looks like:
<pre>
Array2D<double> A(n,n);
Array2D<double> L;
...
Cholesky<double> chol(A);
if (chol.is_spd())
L = chol.getL();
else
cout << "factorization was not complete.\n";
</pre>
<p>
(Adapted from JAMA, a Java Matrix Library, developed by jointly
by the Mathworks and NIST; see http://math.nist.gov/javanumerics/jama).
*/
template <class Real>
class Cholesky
{
Array2D<Real> L_; // lower triangular factor
int isspd; // 1 if matrix to be factored was SPD
public:
Cholesky();
Cholesky(const Array2D<Real> &A);
Array2D<Real> getL() const;
Array1D<Real> solve(const Array1D<Real> &B);
Array2D<Real> solve(const Array2D<Real> &B);
int is_spd() const;
};
template <class Real>
Cholesky<Real>::Cholesky() : L_(0,0), isspd(0) {}
/**
@return 1, if original matrix to be factored was symmetric
positive-definite (SPD).
*/
template <class Real>
int Cholesky<Real>::is_spd() const
{
return isspd;
}
/**
@return the lower triangular factor, L, such that L*L'=A.
*/
template <class Real>
Array2D<Real> Cholesky<Real>::getL() const
{
return L_;
}
/**
Constructs a lower triangular matrix L, such that L*L'= A.
If A is not symmetric positive-definite (SPD), only a
partial factorization is performed. If is_spd()
evalutate true (1) then the factorizaiton was successful.
*/
template <class Real>
Cholesky<Real>::Cholesky(const Array2D<Real> &A)
{
int m = A.dim1();
int n = A.dim2();
isspd = (m == n);
if (m != n)
{
L_ = Array2D<Real>(0,0);
return;
}
L_ = Array2D<Real>(n,n);
// Main loop.
for (int j = 0; j < n; j++)
{
double d = 0.0;
for (int k = 0; k < j; k++)
{
Real s = 0.0;
for (int i = 0; i < k; i++)
{
s += L_[k][i]*L_[j][i];
}
L_[j][k] = s = (A[j][k] - s)/L_[k][k];
d = d + s*s;
isspd = isspd && (A[k][j] == A[j][k]);
}
d = A[j][j] - d;
isspd = isspd && (d > 0.0);
L_[j][j] = sqrt(d > 0.0 ? d : 0.0);
for (int k = j+1; k < n; k++)
{
L_[j][k] = 0.0;
}
}
}
/**
Solve a linear system A*x = b, using the previously computed
cholesky factorization of A: L*L'.
@param B A Matrix with as many rows as A and any number of columns.
@return x so that L*L'*x = b. If b is nonconformat, or if A
was not symmetric posidtive definite, a null (0x0)
array is returned.
*/
template <class Real>
Array1D<Real> Cholesky<Real>::solve(const Array1D<Real> &b)
{
int n = L_.dim1();
if (b.dim1() != n)
return Array1D<Real>();
Array1D<Real> x = b.copy();
// Solve L*y = b;
for (int k = 0; k < n; k++)
{
for (int i = 0; i < k; i++)
x[k] -= x[i]*L_[k][i];
x[k] /= L_[k][k];
}
// Solve L'*X = Y;
for (int k = n-1; k >= 0; k--)
{
for (int i = k+1; i < n; i++)
x[k] -= x[i]*L_[i][k];
x[k] /= L_[k][k];
}
return x;
}
/**
Solve a linear system A*X = B, using the previously computed
cholesky factorization of A: L*L'.
@param B A Matrix with as many rows as A and any number of columns.
@return X so that L*L'*X = B. If B is nonconformat, or if A
was not symmetric posidtive definite, a null (0x0)
array is returned.
*/
template <class Real>
Array2D<Real> Cholesky<Real>::solve(const Array2D<Real> &B)
{
int n = L_.dim1();
if (B.dim1() != n)
return Array2D<Real>();
Array2D<Real> X = B.copy();
int nx = B.dim2();
// Cleve's original code
#if 0
// Solve L*Y = B;
for (int k = 0; k < n; k++) {
for (int i = k+1; i < n; i++) {
for (int j = 0; j < nx; j++) {
X[i][j] -= X[k][j]*L_[k][i];
}
}
for (int j = 0; j < nx; j++) {
X[k][j] /= L_[k][k];
}
}
// Solve L'*X = Y;
for (int k = n-1; k >= 0; k--) {
for (int j = 0; j < nx; j++) {
X[k][j] /= L_[k][k];
}
for (int i = 0; i < k; i++) {
for (int j = 0; j < nx; j++) {
X[i][j] -= X[k][j]*L_[k][i];
}
}
}
#endif
// Solve L*y = b;
for (int j=0; j< nx; j++)
{
for (int k = 0; k < n; k++)
{
for (int i = 0; i < k; i++)
X[k][j] -= X[i][j]*L_[k][i];
X[k][j] /= L_[k][k];
}
}
// Solve L'*X = Y;
for (int j=0; j<nx; j++)
{
for (int k = n-1; k >= 0; k--)
{
for (int i = k+1; i < n; i++)
X[k][j] -= X[i][j]*L_[i][k];
X[k][j] /= L_[k][k];
}
}
return X;
}
}
// namespace JAMA
#endif
// JAMA_CHOLESKY_H
| [
"trosen@814e38a0-0077-4020-8740-4f49b76d3b44"
]
| [
[
[
1,
258
]
]
]
|
f6f845b6698ac851e4f770ae5757c6631d1c0ba3 | a36d7a42310a8351aa0d427fe38b4c6eece305ea | /mybilliard01/ConstString.cpp | 94056ace76c6f18e66fd123f96b499f59f8f2163 | []
| no_license | newpolaris/mybilliard01 | ca92888373c97606033c16c84a423de54146386a | dc3b21c63b5bfc762d6b1741b550021b347432e8 | refs/heads/master | 2020-04-21T06:08:04.412207 | 2009-09-21T15:18:27 | 2009-09-21T15:18:27 | 39,947,400 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 4,509 | cpp | #include "stdafx.h"
#include "my_app.h"
#include "ConstString.h"
namespace my_utility {
using namespace std;
using namespace std::tr1;
// We can change these implementation to be using external XML file.
wstring ConstString::windowTitle() {
return L"Billiard";
}
wstring ConstString::name_CueBall() {
return L"CUE_BALL";
}
wstring ConstString::name_Rack() {
return L"rack01";
}
wstring ConstString::name_Ball_prefix() {
return L"ball";
}
wstring ConstString::name_Pocket_prefix() {
return L"pocket";
}
wstring ConstString::name_Rail_prefix() {
return L"rail";
}
wstring ConstString::name_CueStick() {
return L"cue_stick";
}
wstring ConstString::name_Background() {
return L"background";
}
wstring ConstString::effectFilenameByNodeName( wstring nodeName ) {
static const wstring effectShaderDirectory = L"..\\asset\\shaders\\";
static const wstring defaultEffectFilename = L"textured phong.fx";
const wstring effectFilename = effectShaderDirectory + nodeName + L".fx";
if( FileSystemHelper::isFileExist( effectFilename ) )
return effectFilename;
return effectShaderDirectory + defaultEffectFilename;
}
wstring ConstString::effectFilename_shadowMap( size_t index ) {
wstringstream filename;
filename << L"../asset/shaders/shadow_map" << std::setw(2) << std::setfill<wchar_t>( '0' ) << index << L".fx";
return filename.str();
}
wstring ConstString::effectFilename_depthCull() {
return L"../asset/shaders/depth_cull.fx";
}
wstring ConstString::effectFilename_Blur() {
return L"../asset/shaders/blur.fx";
}
wstring ConstString::effectFilename_HDR() {
return L"../asset/shaders/hdr.fx";
}
wstring ConstString::effectFilename_SSAO() {
return L"../asset/shaders/ssao.fx";
}
const wchar_t * ConstString::dllDirectory() {
return L"../dll";
}
wstring ConstString::soundFilename_BallStrong( size_t index )
{
wostringstream filename;
filename << L"..\\asset\\sound\\ball.strong." << std::setw(2) << std::setfill<wchar_t>('0') << index << L".wav";
if( false == FileSystemHelper::isFileExist( filename.str() ) ) return L"";
return filename.str();
}
wstring ConstString::soundFilename_BallWeak( size_t index )
{
wostringstream filename;
filename << L"..\\asset\\sound\\ball.weak." << std::setw(2) << std::setfill< wchar_t >('0') << index << L".wav";
if( false == FileSystemHelper::isFileExist( filename.str() ) ) return L"";
return filename.str();
}
wstring ConstString::soundFilename_BallBreak( size_t index )
{
wostringstream filename;
filename << L"..\\asset\\sound\\break." << std::setw(2) << std::setfill< wchar_t >('0') << index << L".wav";
if( false == FileSystemHelper::isFileExist( filename.str() ) ) return L"";
return filename.str();
}
wstring ConstString::soundFilename_Chalk( size_t index )
{
wostringstream filename;
filename << L"..\\asset\\sound\\chalk." << std::setw(2) << std::setfill< wchar_t >('0') << index << L".wav";
if( false == FileSystemHelper::isFileExist( filename.str() ) ) return L"";
return filename.str();
}
wstring ConstString::soundFilename_Pocket( size_t index )
{
wostringstream filename;
filename << L"..\\asset\\sound\\pocket." << std::setw(2) << std::setfill< wchar_t >('0') << index << L".wav";
if( false == FileSystemHelper::isFileExist( filename.str() ) ) return L"";
return filename.str();
}
wstring ConstString::soundFilename_CueStrong( size_t index )
{
wostringstream filename;
filename << L"..\\asset\\sound\\cue.strong." << std::setw(2) << std::setfill< wchar_t >('0') << index << L".wav";
if( false == FileSystemHelper::isFileExist( filename.str() ) ) return L"";
return filename.str();
}
wstring ConstString::soundFilename_CueWeak( size_t index )
{
wostringstream filename;
filename << L"..\\asset\\sound\\cue.weak." << std::setw(2) << std::setfill< wchar_t >('0') << index << L".wav";
if( false == FileSystemHelper::isFileExist( filename.str() ) ) return L"";
return filename.str();
}
wstring ConstString::soundFilename_BounceOnRail( size_t index )
{
wostringstream filename;
filename << L"..\\asset\\sound\\bump." << std::setw(2) << std::setfill< wchar_t >('0') << index << L".wav";
if( false == FileSystemHelper::isFileExist( filename.str() ) ) return L"";
return filename.str();
}
}
| [
"wrice127@af801a76-7f76-11de-8b9f-9be6f49bd635"
]
| [
[
[
1,
138
]
]
]
|
cd287fcc97cc32366318c9d46a73ceaf853df100 | 478570cde911b8e8e39046de62d3b5966b850384 | /apicompatanamdw/bcdrivers/mw/classicui/uifw/apps/S60_SDK3.0/bctestnote/src/bctestnoteapp.cpp | d2c99a6bdb1a6e3f944e050f68d766e9a39839fd | []
| 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 | 1,919 | cpp | /*
* Copyright (c) 2006 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: Implements main application class.
*
*/
// INCLUDE FILES
#include "bctestnoteapp.h"
#include "bctestnotedocument.h"
#include <eikstart.h>
// ================= MEMBER FUNCTIONS ========================================
// ---------------------------------------------------------------------------
// TUid CBCTestNoteApp::AppDllUid()
// Returns application UID.
// ---------------------------------------------------------------------------
//
TUid CBCTestNoteApp::AppDllUid() const
{
return KUidBCTestNote;
}
// ---------------------------------------------------------------------------
// CApaDocument* CBCTestNoteApp::CreateDocumentL()
// Creates CBCTestNoteDocument object.
// ---------------------------------------------------------------------------
//
CApaDocument* CBCTestNoteApp::CreateDocumentL()
{
return CBCTestNoteDocument::NewL( *this );
}
// ================= OTHER EXPORTED FUNCTIONS ================================
//
// ---------------------------------------------------------------------------
// CApaApplication* NewApplication()
// Constructs CBCTestNoteApp.
// Returns: CApaDocument*: created application object
// ---------------------------------------------------------------------------
//
LOCAL_C CApaApplication* NewApplication()
{
return new CBCTestNoteApp;
}
GLDEF_C TInt E32Main()
{
return EikStart::RunApplication(NewApplication);
}
| [
"none@none"
]
| [
[
[
1,
63
]
]
]
|
57b34e21e36936dad303ea76729795ea7b234928 | 6253ab92ce2e85b4db9393aa630bde24655bd9b4 | /Common/Ibeo/IbeoSyncClient.cpp | f2a888023f203f5d086e949f6a474138f908c870 | []
| no_license | Aand1/cornell-urban-challenge | 94fd4df18fd4b6cc6e12d30ed8eed280826d4aed | 779daae8703fe68e7c6256932883de32a309a119 | refs/heads/master | 2021-01-18T11:57:48.267384 | 2008-10-01T06:43:18 | 2008-10-01T06:43:18 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,278 | cpp | #include "IbeoSyncClient.h"
#include "..\time\timing.h"
IbeoSyncCallback IbeoSyncClient::callback;
IbeoSyncClient::IbeoSyncClient(){
udp_params params = udp_params();
params.remote_ip = inet_addr(IBEO_SYNC_MC_IP);
params.local_port = IBEO_SYNC_PORT;
params.reuse_addr = 1;
conn = new udp_connection (params);
conn->set_callback (&UDPCallback, NULL);
callback = NULL;
printf("IbeoSync RX Interface Initialized. %s:%d\r\n",IBEO_SYNC_MC_IP,IBEO_SYNC_PORT);
}
IbeoSyncClient::~IbeoSyncClient (){
delete conn;
}
void IbeoSyncClient::SetCallback(IbeoSyncCallback callback)
{
this->callback = callback;
}
//extern TIMER MOO;
void IbeoSyncClient::UDPCallback(udp_message& msg, udp_connection* conn, void* arg){
if(msg.len != 10 && msg.len != 11) return;
bool delayed = false;
if(msg.len==11 && msg.data[10]!=0) delayed = true; // non-0 ending packets signify a 50-ms delayed "trigger" packet
USHORT secs = *(USHORT*)(msg.data);
secs = ntohs(secs);
ULONG ticks = *(ULONG*)(msg.data+2);
ticks = ntohl(ticks);
double local_ts = timeElapsed(ref_time);
double veh_ts = (double)secs + (double)ticks*.0001;
UINT seq = *(UINT*)(msg.data+6);
if (callback!=NULL) callback(veh_ts,local_ts,delayed,seq);
} | [
"anathan@5031bdca-8e6f-11dd-8a4e-8714b3728bc5"
]
| [
[
[
1,
45
]
]
]
|
224423016d4433c63dbdf3c0fcc5c85d23ece2e7 | 5ce68cb73c79a08889c08f311d0ef6936fe06382 | /cySession/cySession/AssemblyInfo.cpp | f14d58a19ff860b191dbfe4d578ecbf1b6fad162 | []
| no_license | grilix/CyCaM | adafb1488db496c53573fc326e0b55544eeeb9f3 | 3cd6cbf20b08e16340f273a0e2dfc5e92131a806 | refs/heads/master | 2020-05-29T19:19:52.780111 | 2010-07-29T01:42:05 | 2010-07-29T01:42:05 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,334 | cpp | #include "stdafx.h"
using namespace System;
using namespace System::Reflection;
using namespace System::Runtime::CompilerServices;
using namespace System::Runtime::InteropServices;
using namespace System::Security::Permissions;
//
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
//
[assembly:AssemblyTitleAttribute("cySession")];
[assembly:AssemblyDescriptionAttribute("")];
[assembly:AssemblyConfigurationAttribute("")];
[assembly:AssemblyCompanyAttribute("")];
[assembly:AssemblyProductAttribute("cySession")];
[assembly:AssemblyCopyrightAttribute("Copyright (c) 2010")];
[assembly:AssemblyTrademarkAttribute("")];
[assembly:AssemblyCultureAttribute("")];
//
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the value or you can default the Revision and Build Numbers
// by using the '*' as shown below:
[assembly:AssemblyVersionAttribute("1.0.*")];
[assembly:ComVisible(false)];
[assembly:CLSCompliantAttribute(true)];
[assembly:SecurityPermission(SecurityAction::RequestMinimum, UnmanagedCode = true)];
| [
"[email protected]"
]
| [
[
[
1,
40
]
]
]
|
42baa046b4584c9e6c210e0ffa50f07a61c717cc | 744e9a2bf1d0aee245c42ee145392d1f6a6f65c9 | /tags/last_qt3_support_release/gui/ttcutsettings.cpp | c6b56e4f8a20972741b1310806feabd11bc5fe36 | []
| no_license | BackupTheBerlios/ttcut-svn | 2b5d00c3c6d16aa118b4a58c7d0702cfcc0b051a | 958032e74e8bb144a96b6eb7e1d63bc8ae762096 | refs/heads/master | 2020-04-22T12:08:57.640316 | 2009-02-08T16:14:00 | 2009-02-08T16:14:00 | 40,747,642 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 43,002 | cpp | /*----------------------------------------------------------------------------*/
/* COPYRIGHT: TriTime (c) 2003/2005 / www.tritime.org */
/*----------------------------------------------------------------------------*/
/* PROJEKT : TTCUT 2005 */
/* FILE : ttcutsettings.cpp */
/*----------------------------------------------------------------------------*/
/* AUTHOR : b. altendorf (E-Mail: [email protected]) DATE: 03/01/2005 */
/* MODIFIED: b. altendorf DATE: 03/23/2005 */
/* MODIFIED: b. altendorf DATE: 04/05/2005 */
/* MODIFIED: b. altendorf DATE: 08/09/2005 */
/* MODIFIED: DATE: */
/*----------------------------------------------------------------------------*/
// ----------------------------------------------------------------------------
// *** TTCUTSETTINGS
// ----------------------------------------------------------------------------
/*----------------------------------------------------------------------------*/
/* 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. */
/*----------------------------------------------------------------------------*/
#include "ttcutsettings.h"
#include <qcheckbox.h>
#include <q3groupbox.h>
#include <qlabel.h>
#include <qlineedit.h>
#include <qpushbutton.h>
#include <qspinbox.h>
#include <qlayout.h>
#include <qvariant.h>
#include <qtooltip.h>
#include <q3whatsthis.h>
#include <qcombobox.h>
#include <qradiobutton.h>
#include <qtabwidget.h>
#include <q3buttongroup.h>
//Added by qt3to4:
#include <QFileDialog>
#include <QGridLayout>
#include <QHBoxLayout>
#include <QVBoxLayout>
// /////////////////////////////////////////////////////////////////////////////
// -----------------------------------------------------------------------------
// TTCut settings object
// -----------------------------------------------------------------------------
// /////////////////////////////////////////////////////////////////////////////
TTCutSettings::TTCutSettings()
: QSettings("TriTime", "TTCut")
{
}
TTCutSettings::~TTCutSettings()
{
}
void TTCutSettings::readSettings()
{
// read application settings
// ---------------------------------------------------------------------------
// Navigation settings
// ---------------------------------------------------------------------------
beginGroup( "/Settings" );
beginGroup( "/Navigation" );
TTCut::fastSlider = value( "FastSlider/", TTCut::fastSlider ).toBool();
TTCut::stepSliderClick = value( "StepSliderClick/", TTCut::stepSliderClick ).toInt();
TTCut::stepPgUpDown = value( "StepPgUpDown/",TTCut::stepPgUpDown ).toInt();
TTCut::stepArrowKeys = value( "StepArrowKeys/",TTCut::stepArrowKeys ).toInt();
TTCut::stepPlusAlt = value( "StepPlusAlt/", TTCut::stepPlusAlt ).toInt();
TTCut::stepPlusCtrl = value( "StepPlusCtrl/", TTCut::stepPlusCtrl ).toInt();
TTCut::stepQuickJump = value( "StepQuickJump/", TTCut::stepQuickJump ).toInt();
TTCut::stepMouseWheel = value( "StepMouseWheel/", TTCut::stepMouseWheel ).toInt();
endGroup();
// Common options
// ---------------------------------------------------------------------------
beginGroup( "/Common" );
TTCut::tempDirPath = value( "TempDirPath/", TTCut::tempDirPath ).toString();
TTCut::lastDirPath = value( "LastDirPath/", TTCut::lastDirPath ).toString();
endGroup();
// Preview
// ---------------------------------------------------------------------------
beginGroup( "/Preview" );
TTCut::cutPreviewSeconds = value( "PreviewSeconds/", TTCut::cutPreviewSeconds ).toInt();
TTCut::playSkipFrames = value( "SkipFrames/", TTCut::playSkipFrames ).toInt();
endGroup();
// Search
// ---------------------------------------------------------------------------
beginGroup( "/Search" );
TTCut::searchLength = value( "Length/", TTCut::searchLength ).toInt();
TTCut::searchAccuracy = value( "Accuracy/", TTCut::searchAccuracy ).toInt();
endGroup();
// Index files
// ---------------------------------------------------------------------------
beginGroup( "/IndexFiles" );
TTCut::createVideoIDD = value( "CreateVideoIDD/", TTCut::createVideoIDD ).toBool();
TTCut::createAudioIDD = value( "CreateAudioIDD/", TTCut::createAudioIDD ).toBool();
TTCut::createPrevIDD = value( "CreatePrevIDD/", TTCut::createPrevIDD ).toBool();
TTCut::createD2V = value( "CreateD2V/", TTCut::createD2V ).toBool();
TTCut::readVideoIDD = value( "ReadVideoIDD/", TTCut::readVideoIDD ).toBool();
TTCut::readAudioIDD = value( "ReadAudioIDD", TTCut::readAudioIDD ).toBool();
TTCut::readPrevIDD = value( "ReadPrevIDD/", TTCut::readPrevIDD ).toBool();
endGroup();
// Encoder settings
// ---------------------------------------------------------------------------
beginGroup( "/Encoder" );
TTCut::encoderMode = value( "EncoderMode/", TTCut::encoderMode ).toBool();
endGroup();
// Muxer settings
// ---------------------------------------------------------------------------
beginGroup( "/Muxer" );
TTCut::muxMode = value( "MuxMode/", TTCut::muxMode ).toInt();
TTCut::mpeg2Target = value( "Mpeg2Target/", TTCut::mpeg2Target ).toInt();
TTCut::muxProg = value( "MuxProg/", TTCut::muxProg ).toString();
TTCut::muxProgPath = value( "MuxProgPath/", TTCut::muxProgPath ).toString();
TTCut::muxProgCmd = value( "MuxProgCmd/", TTCut::muxProgCmd ).toString();
TTCut::muxOutputPath = value( "MuxOutputDir/", TTCut::muxOutputPath ).toString();
endGroup();
// Chapter settings
// ---------------------------------------------------------------------------
beginGroup( "/Chapter" );
TTCut::spumuxChapter = value( "SpumuxChapter/", TTCut::spumuxChapter ).toBool();
endGroup();
// Cut option
// ---------------------------------------------------------------------------
beginGroup( "/CutOptions" );
TTCut::cutDirPath = value( "DirPath/", TTCut::cutDirPath ).toString();
TTCut::cutVideoName = value( "VideoName/", TTCut::cutVideoName ).toString();
TTCut::cutWriteMaxBitrate = value( "WriteMaxBitrate/", TTCut::cutWriteMaxBitrate ).toBool();
TTCut::cutWriteSeqEnd = value( "WriteSeqEnd/", TTCut::cutWriteSeqEnd ).toBool();
TTCut::correctCutTimeCode = value( "CorrectTimeCode/", TTCut::correctCutTimeCode ).toBool();
TTCut::correctCutBitRate = value( "CorrectBitrate/", TTCut::correctCutBitRate ).toBool();
TTCut::createCutIDD = value( "CreateIDD/", TTCut::createCutIDD ).toBool();
TTCut::readCutIDD = value( "ReadIDD/", TTCut::readCutIDD ).toBool();
endGroup();
endGroup();
// check temporary path; we must ensure we have a temporary directory
// the temporary directory is used for the preview clips and for
// the temporary avi-clips
if ( !QDir( TTCut::tempDirPath ).exists() )
TTCut::tempDirPath = QDir::tempPath();
// check the cut directory path
if ( !QDir( TTCut::cutDirPath ).exists() )
TTCut::cutDirPath = QDir::currentPath();
}
void TTCutSettings::writeSettings()
{
beginGroup( "/Settings" );
// Navigation settings
// ---------------------------------------------------------------------------
beginGroup( "/Navigation" );
setValue( "FastSlider/", TTCut::fastSlider );
setValue( "StepSliderClick/", TTCut::stepSliderClick );
setValue( "StepPgUpDown/", TTCut::stepPgUpDown );
setValue( "StepArrowKeys/", TTCut::stepArrowKeys );
setValue( "StepPlusAlt/", TTCut::stepPlusAlt );
setValue( "StepPlusCtrl/",TTCut::stepPlusCtrl );
setValue( "StepQuickJump/", TTCut::stepQuickJump );
setValue( "StepMouseWheel/", TTCut::stepMouseWheel );
endGroup();
// Common options
// ---------------------------------------------------------------------------
beginGroup( "/Common" );
setValue( "TempDirPath/" , TTCut::tempDirPath );
setValue( "LastDirPath/" , TTCut::lastDirPath );
endGroup();
// Preview
// ---------------------------------------------------------------------------
beginGroup( "/Preview" );
setValue( "PreviewSeconds/", TTCut::cutPreviewSeconds );
setValue( "SkipFrames/", TTCut::playSkipFrames );
endGroup();
// Search
// ---------------------------------------------------------------------------
beginGroup( "/Search" );
setValue( "Length/", TTCut::searchLength );
setValue( "Accuracy/", TTCut::searchAccuracy );
endGroup();
// Index files
// ---------------------------------------------------------------------------
beginGroup( "/IndexFiles" );
setValue( "CreateVideoIDD/", TTCut::createVideoIDD );
setValue( "CreateAudioIDD/", TTCut::createAudioIDD );
setValue( "CreatePrevIDD/", TTCut::createPrevIDD );
setValue( "CreateD2V/", TTCut::createD2V );
setValue( "ReadVideoIDD/", TTCut::readVideoIDD );
setValue( "ReadAudioIDD", TTCut::readAudioIDD );
setValue( "ReadPrevIDD/", TTCut::readPrevIDD );
endGroup();
// Encoder settings
// ---------------------------------------------------------------------------
beginGroup( "/Encoder" );
setValue( "EncoderMode/", TTCut::encoderMode );
endGroup();
// Muxer settings
// ---------------------------------------------------------------------------
beginGroup( "/Muxer" );
setValue( "MuxMode/", TTCut::muxMode );
setValue( "Mpeg2Target/", TTCut::mpeg2Target );
setValue( "MuxProg/", TTCut::muxProg );
setValue( "MuxProgPath/", TTCut::muxProgPath );
setValue( "MuxProgCmd/", TTCut::muxProgCmd );
setValue( "MuxOutputDir/", TTCut::muxOutputPath );
endGroup();
// Chapter settings
// ---------------------------------------------------------------------------
beginGroup( "/Chapter" );
setValue( "SpumuxChapter/", TTCut::spumuxChapter );
endGroup();
// Cut option
// ---------------------------------------------------------------------------
beginGroup( "/CutOptions" );
setValue( "DirPath/", TTCut::cutDirPath );
setValue( "VideoName/", TTCut::cutVideoName );
setValue( "WriteMaxBitrate/", TTCut::cutWriteMaxBitrate );
setValue( "WriteSeqEnd/", TTCut::cutWriteSeqEnd );
setValue( "CorrectTimeCode/", TTCut::correctCutTimeCode );
setValue( "CorrectBitrate/", TTCut::correctCutBitRate );
setValue( "CreateIDD/", TTCut::createCutIDD );
setValue( "ReadIDD/", TTCut::readCutIDD );
endGroup();
endGroup();
}
// /////////////////////////////////////////////////////////////////////////////
// -----------------------------------------------------------------------------
// TTCut settings dialog; Container for the setting tabs
// -----------------------------------------------------------------------------
// /////////////////////////////////////////////////////////////////////////////
TTCutSettingsDlg::TTCutSettingsDlg( QWidget* parent, const char* name,
bool modal, Qt::WFlags fl )
: QDialog( parent, name, modal, fl )
{
if ( !name )
setName( "TTCutSettingsDlg" );
resize( 596, 480 );
setCaption( tr( "Settings" ) );
// Dialog layout manager
TTCutSettingsDlgLayout = new QGridLayout( this );
TTCutSettingsDlgLayout->setSpacing( 6 );
TTCutSettingsDlgLayout->setMargin( 11 );
// the tab widget
TTSettingsTab = new QTabWidget( this, "TTSettingsTab" );
TTSettingsTab->setEnabled( TRUE );
// common settings tab
// ---------------------------------------------------------------
commonTab = new TTCutCommonSettings( 0, "CommonTab" );
TTSettingsTab->insertTab( commonTab, tr( "Common" ) );
// files settings tab
// ---------------------------------------------------------------
filesTab = new TTCutFilesSettings( 0, "filesTab" );
TTSettingsTab->insertTab( filesTab, tr( "Files" ) );
// encoder settings tab
// ---------------------------------------------------------------
encoderTab = new TTCutEncoderSettings( 0, "EncoderTab" );
TTSettingsTab->insertTab( encoderTab, tr( "Encoding" ) );
// muxer settings tab
// ---------------------------------------------------------------
muxerTab = new TTCutMuxerSettings( 0, "MuxerTab" );
TTSettingsTab->insertTab( muxerTab, tr( "Muxing" ) );
// chapter settings tab
// ---------------------------------------------------------------
chapterTab = new TTCutChapterSettings( 0, "ChapterTab" );
TTSettingsTab->insertTab( chapterTab, tr( "Chapters" ) );
// add tab widget to central layout
TTCutSettingsDlgLayout->addWidget( TTSettingsTab, 0, 0 );
// button ok, cancel
// ---------------------------------------------------------------
Layout1 = new QHBoxLayout;
Layout1->setSpacing( 6 );
Layout1->setMargin( 0 );
QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum );
Layout1->addItem( spacer );
btnOk = new QPushButton( this, "BtnOk" );
btnOk->setText( tr( "&Ok" ) );
Layout1->addWidget( btnOk );
btnCancel = new QPushButton( this, "BtnCancel" );
btnCancel->setText( tr( "&Cancel" ) );
Layout1->addWidget( btnCancel );
TTCutSettingsDlgLayout->addLayout( Layout1, 1, 0 );
// signals and slot connection
// ------------------------------------------------------------------
connect( btnOk, SIGNAL( clicked() ), SLOT( onDlgOk() ) );
connect( btnCancel, SIGNAL( clicked() ), SLOT( onDlgCancel() ) );
// set the tabs data
// ------------------------------------------------------------------
commonTab->setTabData();
filesTab->setTabData();
encoderTab->setTabData();
muxerTab->setTabData();
chapterTab->setTabData();
}
TTCutSettingsDlg::~TTCutSettingsDlg()
{
}
// save the tabs data
void TTCutSettingsDlg::setGlobalData()
{
commonTab->getTabData();
filesTab->getTabData();
encoderTab->getTabData();
muxerTab->getTabData();
chapterTab->getTabData();
}
// exit, saving changes
void TTCutSettingsDlg::onDlgOk()
{
setGlobalData();
done( 0 );
}
// exit, discard changes
void TTCutSettingsDlg::onDlgCancel()
{
done( 1 );
}
// /////////////////////////////////////////////////////////////////////////////
// -----------------------------------------------------------------------------
// TTCut common settings tab
// -----------------------------------------------------------------------------
// /////////////////////////////////////////////////////////////////////////////
// constructor
TTCutCommonSettings::TTCutCommonSettings( QWidget* parent, const char* name, Qt::WFlags fl )
: QWidget( parent, name, fl )
{
if ( !name )
setName( "TTCutCommonSettings" );
resize( 577, 328 );
setCaption( tr( "Common" ) );
TTCutCommonSettingsLayout = new QGridLayout( this );
TTCutCommonSettingsLayout->setSpacing( 6 );
TTCutCommonSettingsLayout->setMargin( 11 );
gbNavigation = new Q3GroupBox( this, "gbNavigation" );
gbNavigation->setTitle( tr( "Navigation" ) );
gbNavigation->setColumnLayout(0, Qt::Vertical );
gbNavigation->layout()->setSpacing( 0 );
gbNavigation->layout()->setMargin( 0 );
gbNavigationLayout = new QGridLayout( gbNavigation->layout() );
gbNavigationLayout->setAlignment( Qt::AlignTop );
gbNavigationLayout->setSpacing( 6 );
gbNavigationLayout->setMargin( 11 );
cbQuickSearch = new QCheckBox( gbNavigation, "cbQuickSearch" );
cbQuickSearch->setText( tr( "Use quick seek (slider positioned only on I-Frames)" ) );
gbNavigationLayout->addWidget( cbQuickSearch, 1, 0 );
Layout4 = new QHBoxLayout;
Layout4->setSpacing( 6 );
Layout4->setMargin( 0 );
Layout1 = new QVBoxLayout;
Layout1->setSpacing( 6 );
Layout1->setMargin( 0 );
laSliderClick = new QLabel( gbNavigation, "laSliderClick" );
laSliderClick->setText( tr( "Slider click placement" ) );
Layout1->addWidget( laSliderClick );
laPgUpDown = new QLabel( gbNavigation, "laPgUpDown" );
laPgUpDown->setText( tr( "Page up/down placement" ) );
Layout1->addWidget( laPgUpDown );
laArrowPlacement = new QLabel( gbNavigation, "laArrowPlacement" );
laArrowPlacement->setText( tr( "Arrow keys placement" ) );
Layout1->addWidget( laArrowPlacement );
laAltJump = new QLabel( gbNavigation, "laAltJump" );
laAltJump->setText( tr( "'Alt' key jump distance" ) );
Layout1->addWidget( laAltJump );
laCtrlJump = new QLabel( gbNavigation, "laCtrlJump" );
laCtrlJump->setText( tr( "'Ctrl' key jump distance" ) );
Layout1->addWidget( laCtrlJump );
laQuickJump = new QLabel( gbNavigation, "laQuickJump" );
laQuickJump->setText( tr( "Quick jump distance" ) );
Layout1->addWidget( laQuickJump );
laMouseWheel = new QLabel( gbNavigation, "laMouseWheel" );
laMouseWheel->setText( tr( "Mouse wheel distance" ) );
Layout1->addWidget( laMouseWheel );
Layout4->addLayout( Layout1 );
Layout2 = new QVBoxLayout;
Layout2->setSpacing( 6 );
Layout2->setMargin( 0 );
// TODO: add apropriate values for min/max values and step
sbSliderClickPlacement = new QSpinBox( gbNavigation, "sbSliderClickPlacement" );
sbSliderClickPlacement->setMaxValue( 200 );
sbSliderClickPlacement->setMinValue( 5 );
sbSliderClickPlacement->setLineStep( 5 );
Layout2->addWidget( sbSliderClickPlacement );
sbPgUpDown = new QSpinBox( gbNavigation, "sbPgUpDown" );
sbPgUpDown->setMaxValue( 200 );
sbPgUpDown->setMinValue( 5 );
sbPgUpDown->setLineStep( 5 );
Layout2->addWidget( sbPgUpDown );
sbArrowKeyPlacement = new QSpinBox( gbNavigation, "sbArrowKeyPlacement" );
sbArrowKeyPlacement->setMaxValue( 40 );
sbArrowKeyPlacement->setMinValue( 1 );
sbArrowKeyPlacement->setLineStep( 1 );
Layout2->addWidget( sbArrowKeyPlacement );
sbAltDistance = new QSpinBox( gbNavigation, "sbAltDistance" );
sbAltDistance->setMaxValue( 200 );
sbAltDistance->setMinValue( 5 );
sbAltDistance->setLineStep( 5 );
Layout2->addWidget( sbAltDistance );
sbCtrlDistance = new QSpinBox( gbNavigation, "sbCtrlDistance" );
sbCtrlDistance->setMaxValue( 200 );
sbCtrlDistance->setMinValue( 5 );
sbCtrlDistance->setLineStep( 5 );
Layout2->addWidget( sbCtrlDistance );
sbQuickJumpDistance = new QSpinBox( gbNavigation, "sbQuickJumpDistance" );
sbQuickJumpDistance->setMaxValue( 200 );
sbQuickJumpDistance->setMinValue( 5 );
sbQuickJumpDistance->setLineStep( 5 );
Layout2->addWidget( sbQuickJumpDistance );
sbMouseWheel = new QSpinBox( gbNavigation, "sbMouseWheel" );
sbMouseWheel->setMaxValue( 200 );
sbMouseWheel->setMinValue( 5 );
sbMouseWheel->setLineStep( 5 );
Layout2->addWidget( sbMouseWheel );
Layout4->addLayout( Layout2 );
Layout3 = new QVBoxLayout;
Layout3->setSpacing( 6 );
Layout3->setMargin( 0 );
laFrames1 = new QLabel( gbNavigation, "laFrames1" );
laFrames1->setText( tr( "frames" ) );
Layout3->addWidget( laFrames1 );
laFrames2 = new QLabel( gbNavigation, "laFrames2" );
laFrames2->setText( tr( "frames" ) );
Layout3->addWidget( laFrames2 );
laFrames3 = new QLabel( gbNavigation, "laFrames3" );
laFrames3->setText( tr( "frames" ) );
Layout3->addWidget( laFrames3 );
laFrames4 = new QLabel( gbNavigation, "laFrames4" );
laFrames4->setText( tr( "frames" ) );
Layout3->addWidget( laFrames4 );
laFrames5 = new QLabel( gbNavigation, "laFrames5" );
laFrames5->setText( tr( "frames" ) );
Layout3->addWidget( laFrames5 );
laSeconds1 = new QLabel( gbNavigation, "laSeconds1" );
laSeconds1->setText( tr( "seconds" ) );
Layout3->addWidget( laSeconds1 );
laFrames7 = new QLabel( gbNavigation, "laFrames6" );
laFrames7->setText( tr( "frames" ) );
Layout3->addWidget( laFrames7 );
Layout4->addLayout( Layout3 );
gbNavigationLayout->addLayout( Layout4, 0, 0 );
TTCutCommonSettingsLayout->addMultiCellWidget( gbNavigation, 0, 1, 0, 0 );
gbSearchPlay = new Q3GroupBox( this, "gbSearchPlay" );
gbSearchPlay->setTitle( tr( "Search/Play" ) );
gbSearchPlay->setColumnLayout(0, Qt::Vertical );
gbSearchPlay->layout()->setSpacing( 0 );
gbSearchPlay->layout()->setMargin( 0 );
gbSearchPlayLayout = new QGridLayout( gbSearchPlay->layout() );
gbSearchPlayLayout->setAlignment( Qt::AlignTop );
gbSearchPlayLayout->setSpacing( 6 );
gbSearchPlayLayout->setMargin( 11 );
Layout5 = new QVBoxLayout;
Layout5->setSpacing( 6 );
Layout5->setMargin( 0 );
laSearch = new QLabel( gbSearchPlay, "laSearch" );
laSearch->setText( tr( "Search CutOut Frame within" ) );
Layout5->addWidget( laSearch );
laPreview = new QLabel( gbSearchPlay, "laPreview" );
laPreview->setText( tr( "Preview each Cut" ) );
Layout5->addWidget( laPreview );
laSkip = new QLabel( gbSearchPlay, "laSkip" );
laSkip->setText( tr( "Skip while playing" ) );
Layout5->addWidget( laSkip );
gbSearchPlayLayout->addLayout( Layout5, 0, 0 );
Layout6 = new QVBoxLayout;
Layout6->setSpacing( 6 );
Layout6->setMargin( 0 );
sbSearchIntervall = new QSpinBox( gbSearchPlay, "sbSearchIntervall" );
sbSearchIntervall->setMaxValue( 200 );
sbSearchIntervall->setMinValue( 5 );
sbSearchIntervall->setLineStep( 5 );
Layout6->addWidget( sbSearchIntervall );
spPreviewLength = new QSpinBox( gbSearchPlay, "spPreviewLength" );
spPreviewLength->setMaxValue( 200 );
spPreviewLength->setMinValue( 5 );
spPreviewLength->setLineStep( 5 );
Layout6->addWidget( spPreviewLength );
sbSkipFrames = new QSpinBox( gbSearchPlay, "sbSkipFrames" );
sbSkipFrames->setMaxValue( 200 );
sbSkipFrames->setMinValue( 5 );
sbSkipFrames->setLineStep( 5 );
Layout6->addWidget( sbSkipFrames );
gbSearchPlayLayout->addLayout( Layout6, 0, 1 );
Layout7 = new QVBoxLayout;
Layout7->setSpacing( 6 );
Layout7->setMargin( 0 );
laSeconds2 = new QLabel( gbSearchPlay, "laSeconds2" );
laSeconds2->setText( tr( "seconds" ) );
Layout7->addWidget( laSeconds2 );
laSeconds3 = new QLabel( gbSearchPlay, "laSeconds3" );
laSeconds3->setText( tr( "seconds" ) );
Layout7->addWidget( laSeconds3 );
laFrame6 = new QLabel( gbSearchPlay, "laFrame6" );
laFrame6->setText( tr( "frames" ) );
Layout7->addWidget( laFrame6 );
gbSearchPlayLayout->addLayout( Layout7, 0, 2 );
TTCutCommonSettingsLayout->addWidget( gbSearchPlay, 0, 1 );
QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Minimum, QSizePolicy::Expanding );
TTCutCommonSettingsLayout->addItem( spacer, 1, 1 );
gbFilesDirs = new Q3GroupBox( this, "gbFilesDirs" );
gbFilesDirs->setTitle( tr( "Files/Directories" ) );
gbFilesDirs->setColumnLayout(0, Qt::Vertical );
gbFilesDirs->layout()->setSpacing( 0 );
gbFilesDirs->layout()->setMargin( 0 );
gbFilesDirsLayout = new QGridLayout( gbFilesDirs->layout() );
gbFilesDirsLayout->setAlignment( Qt::AlignTop );
gbFilesDirsLayout->setSpacing( 6 );
gbFilesDirsLayout->setMargin( 11 );
laTempDir = new QLabel( gbFilesDirs, "laTempDir" );
laTempDir->setText( tr( "Temp directory" ) );
gbFilesDirsLayout->addWidget( laTempDir, 0, 0 );
leTempDirectory = new QLineEdit( gbFilesDirs, "leTempDirectory" );
gbFilesDirsLayout->addWidget( leTempDirectory, 0, 1 );
btnDirOpen = new QPushButton( gbFilesDirs, "btnDirOpen" );
btnDirOpen->setMinimumSize( QSize( 30, 30 ) );
btnDirOpen->setMaximumSize( QSize( 30, 30 ) );
btnDirOpen->setPixmap( *(TTCut::imgFileOpen24) );
gbFilesDirsLayout->addWidget( btnDirOpen, 0, 2 );
TTCutCommonSettingsLayout->addMultiCellWidget( gbFilesDirs, 3, 3, 0, 1 );
QSpacerItem* spacer_2 = new QSpacerItem( 20, 20, QSizePolicy::Minimum, QSizePolicy::Expanding );
TTCutCommonSettingsLayout->addItem( spacer_2, 2, 0 );
connect( btnDirOpen, SIGNAL( clicked() ), this, SLOT( selectTempDirAction() ) );
}
// destructor
TTCutCommonSettings::~TTCutCommonSettings()
{
// no need to delete child widgets, Qt does it all for us
}
// select a temp directory path
void TTCutCommonSettings::selectTempDirAction()
{
QString str_dir = QFileDialog::getExistingDirectory( this,
"Select temporary directory",
TTCut::tempDirPath,
(QFileDialog::DontResolveSymlinks |
QFileDialog::ShowDirsOnly) );
if ( !str_dir.isEmpty() )
{
TTCut::tempDirPath = str_dir;
leTempDirectory->setText( TTCut::tempDirPath );
}
}
// set the tab data from the global parameter
void TTCutCommonSettings::setTabData()
{
// --------------------------------------------------------------
// common settings
// --------------------------------------------------------------
// Navigation
sbSliderClickPlacement->setValue( TTCut::stepSliderClick );
sbPgUpDown->setValue( TTCut::stepPgUpDown );
sbArrowKeyPlacement->setValue( TTCut::stepArrowKeys );
sbAltDistance->setValue( TTCut::stepPlusAlt );
sbCtrlDistance->setValue( TTCut::stepPlusCtrl );
sbQuickJumpDistance->setValue( TTCut::stepQuickJump );
sbMouseWheel->setValue( TTCut::stepMouseWheel );
// Preview
spPreviewLength->setValue( TTCut::cutPreviewSeconds );
// Frame search
sbSearchIntervall->setValue( TTCut::searchLength );
sbSkipFrames->setValue( TTCut::playSkipFrames );
// Options, directories
if ( TTCut::fastSlider )
cbQuickSearch->setChecked( true );
else
cbQuickSearch->setChecked( false );
leTempDirectory->setText( TTCut::tempDirPath );
}
// get the tab data and fill the global parameter
void TTCutCommonSettings::getTabData()
{
// Navigation
TTCut::stepSliderClick = sbSliderClickPlacement->value( );
TTCut::stepPgUpDown = sbPgUpDown->value( );
TTCut::stepArrowKeys = sbArrowKeyPlacement->value( );
TTCut::stepPlusAlt = sbAltDistance->value( );
TTCut::stepPlusCtrl = sbCtrlDistance->value( );
TTCut::stepQuickJump = sbQuickJumpDistance->value( );
TTCut::stepMouseWheel = sbMouseWheel->value( );
// Preview
TTCut::cutPreviewSeconds = spPreviewLength->value( );
// Frame search
TTCut::searchLength = sbSearchIntervall->value( );
TTCut::playSkipFrames = sbSkipFrames->value( );
// Options, directories
if ( cbQuickSearch->isChecked() )
TTCut::fastSlider = true;
else
TTCut::fastSlider = false;
TTCut::tempDirPath = leTempDirectory->text( );
if ( !QDir(TTCut::tempDirPath).exists() )
TTCut::tempDirPath = QDir::tempPath();
}
// /////////////////////////////////////////////////////////////////////////////
// -----------------------------------------------------------------------------
// TTCut files settings tab
// -----------------------------------------------------------------------------
// /////////////////////////////////////////////////////////////////////////////
// constructor
TTCutFilesSettings::TTCutFilesSettings( QWidget* parent, const char* name, Qt::WFlags fl )
: QWidget( parent, name, fl )
{
if ( !name )
setName( "TTCutFilesSettings" );
resize( 536, 263 );
// Main layout
// -------------------------------------------------------------------------
TTCutFilesSettingsLayout = new QGridLayout( this );
TTCutFilesSettingsLayout->setSpacing( 6 );
TTCutFilesSettingsLayout->setMargin( 11 );
// MPEG2Schnitt index files (*.idd)
// -------------------------------------------------------------------------
cbCreateCutVideoIDD = new Q3GroupBox( this, "cbCreateCutVideoIDD" );
cbCreateCutVideoIDD->setGeometry( QRect( 10, 10, 254, 137 ) );
cbCreateCutVideoIDD->setTitle( tr( "MPEG2Schnitt Index Files (*.idd)" ) );
cbCreateCutVideoIDD->setColumnLayout(0, Qt::Vertical );
cbCreateCutVideoIDD->layout()->setSpacing( 0 );
cbCreateCutVideoIDD->layout()->setMargin( 0 );
cbCreateCutVideoIDDLayout = new QGridLayout( cbCreateCutVideoIDD->layout() );
cbCreateCutVideoIDDLayout->setAlignment( Qt::AlignTop );
cbCreateCutVideoIDDLayout->setSpacing( 6 );
cbCreateCutVideoIDDLayout->setMargin( 11 );
cbCreateVideoIDD = new QCheckBox( cbCreateCutVideoIDD, "cbCreateVideoIDD" );
cbCreateVideoIDD->setText( tr( "Create video index file" ) );
cbCreateCutVideoIDDLayout->addWidget( cbCreateVideoIDD, 0, 0 );
cbReadVideoIDD = new QCheckBox( cbCreateCutVideoIDD, "cbReadVideoIDD" );
cbReadVideoIDD->setText( tr( "Read video index file" ) );
cbCreateCutVideoIDDLayout->addWidget( cbReadVideoIDD, 1, 0 );
cbCreateAudioIDD = new QCheckBox( cbCreateCutVideoIDD, "cbCreateAudioIDD" );
cbCreateAudioIDD->setText( tr( "Create audio index file" ) );
cbCreateCutVideoIDDLayout->addWidget( cbCreateAudioIDD, 2, 0 );
cbReadAudioIDD = new QCheckBox( cbCreateCutVideoIDD, "cbReadAudioIDD" );
cbReadAudioIDD->setText( tr( "Read audio index file" ) );
cbCreateCutVideoIDDLayout->addWidget( cbReadAudioIDD, 3, 0 );
CheckBox9 = new QCheckBox( cbCreateCutVideoIDD, "CheckBox9" );
CheckBox9->setText( tr( "Create cut video index file" ) );
cbCreateCutVideoIDDLayout->addWidget( CheckBox9, 4, 0 );
TTCutFilesSettingsLayout->addWidget( cbCreateCutVideoIDD, 0, 0 );
// Logfile and logfile options
// -------------------------------------------------------------------------
gbLogfile = new Q3GroupBox( this, "gbLogfile" );
gbLogfile->setGeometry( QRect( 270, 10, 237, 119 ) );
gbLogfile->setTitle( tr( "Logfile" ) );
gbLogfile->setColumnLayout(0, Qt::Vertical );
gbLogfile->layout()->setSpacing( 0 );
gbLogfile->layout()->setMargin( 0 );
gbLogfileLayout = new QGridLayout( gbLogfile->layout() );
gbLogfileLayout->setAlignment( Qt::AlignTop );
gbLogfileLayout->setSpacing( 6 );
gbLogfileLayout->setMargin( 11 );
gbLogfileOptions = new Q3GroupBox( gbLogfile, "gbLogfileOptions" );
gbLogfileOptions->setTitle( tr( "Logfile Options" ) );
gbLogfileOptions->setColumnLayout(0, Qt::Vertical );
gbLogfileOptions->layout()->setSpacing( 0 );
gbLogfileOptions->layout()->setMargin( 0 );
gbLogfileOptionsLayout = new QGridLayout( gbLogfileOptions->layout() );
gbLogfileOptionsLayout->setAlignment( Qt::AlignTop );
gbLogfileOptionsLayout->setSpacing( 6 );
gbLogfileOptionsLayout->setMargin( 11 );
cbLogPlusVideoIndex = new QCheckBox( gbLogfileOptions, "cbLogPlusVideoIndex" );
cbLogPlusVideoIndex->setText( tr( "Video index information" ) );
gbLogfileOptionsLayout->addWidget( cbLogPlusVideoIndex, 1, 0 );
cbLogExtended = new QCheckBox( gbLogfileOptions, "cbLogExtended" );
cbLogExtended->setText( tr( "Extended messages and information" ) );
gbLogfileOptionsLayout->addWidget( cbLogExtended, 0, 0 );
gbLogfileLayout->addWidget( gbLogfileOptions, 1, 0 );
cbCreateLog = new QCheckBox( gbLogfile, "cbCreateLog" );
cbCreateLog->setText( tr( "Create logfile" ) );
gbLogfileLayout->addWidget( cbCreateLog, 0, 0 );
TTCutFilesSettingsLayout->addWidget( gbLogfile, 0, 1 );
QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Minimum, QSizePolicy::Expanding );
TTCutFilesSettingsLayout->addItem( spacer, 1, 0 );
}
// destruct object
TTCutFilesSettings::~TTCutFilesSettings()
{
// no need to delete child widgets, Qt does it all for us
}
// set the tab data from the global parameter
void TTCutFilesSettings::setTabData()
{
cbCreateVideoIDD->setChecked( TTCut::createVideoIDD );
cbCreateAudioIDD->setChecked( TTCut::createAudioIDD );
cbReadVideoIDD->setChecked( TTCut::readVideoIDD );
cbReadAudioIDD->setChecked( TTCut::readAudioIDD );
cbCreateLog->setChecked( TTCut::createLogFile );
cbLogExtended->setChecked( TTCut::logModeExtended );
cbLogPlusVideoIndex->setChecked( TTCut::logVideoIndexInfo );
}
// get the tab data and fill the global parameter
void TTCutFilesSettings::getTabData()
{
TTCut::createVideoIDD = cbCreateVideoIDD->isChecked( );
TTCut::createAudioIDD = cbCreateAudioIDD->isChecked( );
TTCut::readVideoIDD = cbReadVideoIDD->isChecked( );
TTCut::readAudioIDD = cbReadAudioIDD->isChecked( );
TTCut::createLogFile = cbCreateLog->isChecked( );
TTCut::logModeExtended = cbLogExtended->isChecked( );
TTCut::logVideoIndexInfo = cbLogPlusVideoIndex->isChecked( );
}
// /////////////////////////////////////////////////////////////////////////////
// -----------------------------------------------------------------------------
// TTCut encoding settings tab
// -----------------------------------------------------------------------------
// /////////////////////////////////////////////////////////////////////////////
// constructor
TTCutEncoderSettings::TTCutEncoderSettings( QWidget* parent, const char* name, Qt::WFlags fl )
: QWidget( parent, name, fl )
{
if ( !name )
setName( "TTCutEncoderSettings" );
resize( 596, 370 );
setCaption( tr( "Form1" ) );
cbEncodingMode = new QCheckBox( this, "cbEncodingMode" );
cbEncodingMode->setGeometry( QRect( 10, 20, 200, 20 ) );
cbEncodingMode->setText( tr( "Use encoding mode" ) );
}
// destructor
TTCutEncoderSettings::~TTCutEncoderSettings()
{
// no need to delete child widgets, Qt does it all for us
}
// set the tab data from the global parameter
void TTCutEncoderSettings::setTabData()
{
cbEncodingMode->setChecked( TTCut::encoderMode );
}
// get the tab data and fill the global parameter
void TTCutEncoderSettings::getTabData()
{
if ( cbEncodingMode->isChecked() )
TTCut::encoderMode = true;
else
TTCut::encoderMode = false;
}
// /////////////////////////////////////////////////////////////////////////////
// -----------------------------------------------------------------------------
// TTCut muxer settings tab
// -----------------------------------------------------------------------------
// /////////////////////////////////////////////////////////////////////////////
// constructor
TTCutMuxerSettings::TTCutMuxerSettings( QWidget* parent, const char* name, Qt::WFlags fl )
: QWidget( parent, name, fl )
{
if ( !name )
setName( "TTCutMuxerSettings" );
resize( 596, 370 );
setCaption( tr( "Form2" ) );
TTCutMuxerSettingsLayout = new QGridLayout( this );
TTCutMuxerSettingsLayout->setSpacing( 6 );
TTCutMuxerSettingsLayout->setMargin( 11 );
bgMuxOptions = new Q3ButtonGroup( this, "bgMuxOptions" );
bgMuxOptions->setTitle( tr( "Mux options" ) );
bgMuxOptions->setColumnLayout(0, Qt::Vertical );
bgMuxOptions->layout()->setSpacing( 0 );
bgMuxOptions->layout()->setMargin( 0 );
bgMuxOptionsLayout = new QGridLayout( bgMuxOptions->layout() );
bgMuxOptionsLayout->setAlignment( Qt::AlignTop );
bgMuxOptionsLayout->setSpacing( 6 );
bgMuxOptionsLayout->setMargin( 11 );
rbMuxNone = new QRadioButton( bgMuxOptions, "rbMuxNone" );
rbMuxNone->setText( tr( "No muxing" ) );
bgMuxOptionsLayout->addWidget( rbMuxNone, 0, 2 );
rbCreateMuxScript = new QRadioButton( bgMuxOptions, "rbCreateMuxScript" );
rbCreateMuxScript->setText( tr( "Create mux script for batch muxing" ) );
bgMuxOptionsLayout->addWidget( rbCreateMuxScript, 0, 1 );
rbMuxStreams = new QRadioButton( bgMuxOptions, "rbMuxStreams" );
rbMuxStreams->setText( tr( "Finally mux result streams" ) );
bgMuxOptionsLayout->addWidget( rbMuxStreams, 0, 0 );
TTCutMuxerSettingsLayout->addWidget( bgMuxOptions, 0, 0 );
gbMuxerSettings = new Q3GroupBox( this, "gbMuxerSettings" );
gbMuxerSettings->setTitle( tr( "Muxer settings" ) );
gbMuxerSettings->setColumnLayout(0, Qt::Vertical );
gbMuxerSettings->layout()->setSpacing( 0 );
gbMuxerSettings->layout()->setMargin( 0 );
gbMuxerSettingsLayout = new QGridLayout( gbMuxerSettings->layout() );
gbMuxerSettingsLayout->setAlignment( Qt::AlignTop );
gbMuxerSettingsLayout->setSpacing( 6 );
gbMuxerSettingsLayout->setMargin( 11 );
QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum );
gbMuxerSettingsLayout->addMultiCell( spacer, 1, 1, 4, 5 );
laMuxTarget = new QLabel( gbMuxerSettings, "laMuxTarget" );
laMuxTarget->setText( tr( "MPEG-2 target" ) );
gbMuxerSettingsLayout->addWidget( laMuxTarget, 0, 0 );
cbMuxTarget = new QComboBox( FALSE, gbMuxerSettings, "cbMuxTarget" );
gbMuxerSettingsLayout->addWidget( cbMuxTarget, 0, 1 );
QSpacerItem* spacer_2 = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum );
gbMuxerSettingsLayout->addItem( spacer_2, 0, 2 );
laOutputPath = new QLabel( gbMuxerSettings, "laOutputPath" );
laOutputPath->setText( tr( "Output path" ) );
gbMuxerSettingsLayout->addWidget( laOutputPath, 2, 0 );
cbMuxerProg = new QComboBox( FALSE, gbMuxerSettings, "cbMuxerProg" );
gbMuxerSettingsLayout->addMultiCellWidget( cbMuxerProg, 1, 1, 1, 2 );
laMuxerProg = new QLabel( gbMuxerSettings, "laMuxerProg" );
laMuxerProg->setText( tr( "Used muxer" ) );
gbMuxerSettingsLayout->addWidget( laMuxerProg, 1, 0 );
pbConfigureMuxer = new QPushButton( gbMuxerSettings, "pbConfigureMuxer" );
pbConfigureMuxer->setMinimumSize( QSize( 0, 0 ) );
pbConfigureMuxer->setMaximumSize( QSize( 32767, 32767 ) );
pbConfigureMuxer->setText( tr( "configure..." ) );
pbConfigureMuxer->setIconSet( QIcon( *(TTCut::imgSettings18) ) );
gbMuxerSettingsLayout->addWidget( pbConfigureMuxer, 1, 3 );
btnOutputPath = new QPushButton( gbMuxerSettings, "btnOutputPath" );
btnOutputPath->setMinimumSize( QSize( 30, 30 ) );
btnOutputPath->setMaximumSize( QSize( 30, 30 ) );
btnOutputPath->setPixmap( *(TTCut::imgFileOpen24) );
gbMuxerSettingsLayout->addWidget( btnOutputPath, 2, 5 );
leOutputPath = new QLineEdit( gbMuxerSettings, "leOutputPath" );
gbMuxerSettingsLayout->addMultiCellWidget( leOutputPath, 2, 2, 1, 4 );
TTCutMuxerSettingsLayout->addWidget( gbMuxerSettings, 1, 0 );
gbPostMuxing = new Q3GroupBox( this, "gbPostMuxing" );
gbPostMuxing->setTitle( tr( "post muxing action" ) );
gbPostMuxing->setColumnLayout(0, Qt::Vertical );
gbPostMuxing->layout()->setSpacing( 0 );
gbPostMuxing->layout()->setMargin( 0 );
gbPostMuxingLayout = new QGridLayout( gbPostMuxing->layout() );
gbPostMuxingLayout->setAlignment( Qt::AlignTop );
gbPostMuxingLayout->setSpacing( 6 );
gbPostMuxingLayout->setMargin( 11 );
cbPause = new QCheckBox( gbPostMuxing, "cbPause" );
cbPause->setText( tr( "Pause" ) );
gbPostMuxingLayout->addWidget( cbPause, 0, 0 );
cbDeleteES = new QCheckBox( gbPostMuxing, "cbDeleteES" );
cbDeleteES->setText( tr( "Delete elemtary streams" ) );
gbPostMuxingLayout->addWidget( cbDeleteES, 1, 0 );
TTCutMuxerSettingsLayout->addWidget( gbPostMuxing, 2, 0 );
QSpacerItem* spacer_3 = new QSpacerItem( 20, 20, QSizePolicy::Minimum, QSizePolicy::Expanding );
TTCutMuxerSettingsLayout->addItem( spacer_3, 3, 0 );
}
// destructor
TTCutMuxerSettings::~TTCutMuxerSettings()
{
// no need to delete child widgets, Qt does it all for us
}
// set the tab data from the global parameter
void TTCutMuxerSettings::setTabData()
{
}
// get the tab data and fill the global parameter
void TTCutMuxerSettings::getTabData()
{
}
// /////////////////////////////////////////////////////////////////////////////
// -----------------------------------------------------------------------------
// TTCut chapter settings tab
// -----------------------------------------------------------------------------
// /////////////////////////////////////////////////////////////////////////////
TTCutChapterSettings::TTCutChapterSettings( QWidget* parent, const char* name, Qt::WFlags fl )
: QWidget( parent, name, fl )
{
if ( !name )
setName( "TTCutChapterSettings" );
resize( 596, 480 );
setCaption( tr( "Form3" ) );
TTCutChapterSettingsLayout = new QGridLayout( this );
TTCutChapterSettingsLayout->setSpacing( 6 );
TTCutChapterSettingsLayout->setMargin( 11 );
cbSpumuxChapter = new QCheckBox( this, "cbSpumuxChapter" );
cbSpumuxChapter->setText( tr( "Write spumux (XML) chapter-list" ) );
TTCutChapterSettingsLayout->addWidget( cbSpumuxChapter, 0, 0 );
QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Minimum, QSizePolicy::Expanding );
TTCutChapterSettingsLayout->addItem( spacer, 1, 0 );
}
TTCutChapterSettings::~TTCutChapterSettings()
{
// no need to delete child widgets, Qt does it all for us
}
// set the tab data from the global parameter
void TTCutChapterSettings::setTabData()
{
}
// get the tab data and fill the global parameter
void TTCutChapterSettings::getTabData()
{
}
| [
"tritime@7763a927-590e-0410-8f7f-dbc853b76eaa"
]
| [
[
[
1,
1122
]
]
]
|
938e7772519229b872dee8d93040a18082228e98 | c86f787916e295d20607cbffc13c524018888a0f | /tp3/codigo/benchmark/FiltroGrafos.h | 9221e45ed80d3b186fd7692bc813bb0d8d8e156d | []
| 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 | 704 | h | #ifndef Filtro_Grafos_H
#define Filtro_Grafos_H
#include "Dibujo.h"
#include <vector>
#include <list>
using namespace std;
class FiltroGrafos{
public:
FiltroGrafos(Dibujo& entrada);
Dibujo reconstruirDibujo(Dibujo& limpio);
Dibujo* dibujoLimpio;
~FiltroGrafos();
private:
vector<nodo> marcados1,marcados2;
vector<nodo> traduccion;
list<nodo> nulos1, nulos2;
GrafoBipartito *grafoOriginal;
GrafoBipartito* grafoLimpio;
vector<nodo> nuevoP1;
vector<nodo> nuevoP2;
list<nodo> nuevoV1;
list<nodo> nuevoV2;
list<eje> losEjesNuevos;
unsigned v1,v2,IV1,IV2;
list<nodo> p1Posta;
list<nodo> p2Posta;
};
#endif
| [
"federicoemartinez@bfd18afd-6e49-0410-abef-09437ef2666c"
]
| [
[
[
1,
34
]
]
]
|
03e7a749fdff42a4402333e8ae41573b6274f42a | 138a353006eb1376668037fcdfbafc05450aa413 | /source/ogre/OgreNewt/boost/mpl/order_fwd.hpp | ec9cb8e4192cdc4205e3389ae4119e1bd5cbc4e7 | []
| no_license | sonicma7/choreopower | 107ed0a5f2eb5fa9e47378702469b77554e44746 | 1480a8f9512531665695b46dcfdde3f689888053 | refs/heads/master | 2020-05-16T20:53:11.590126 | 2009-11-18T03:10:12 | 2009-11-18T03:10:12 | 32,246,184 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 749 | hpp |
#ifndef BOOST_MPL_ORDER_FWD_HPP_INCLUDED
#define BOOST_MPL_ORDER_FWD_HPP_INCLUDED
// Copyright Aleksey Gurtovoy 2003-2004
// Copyright David Abrahams 2003-2004
//
// 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.
// $Source: /cvsroot/ogre/ogreaddons/ogrenewt/OgreNewt_Main/inc/boost/mpl/order_fwd.hpp,v $
// $Date: 2006/04/17 23:49:40 $
// $Revision: 1.1 $
namespace boost { namespace mpl {
template< typename Tag > struct order_impl;
template< typename AssociativeSequence, typename Key > struct order;
}}
#endif // BOOST_MPL_ORDER_FWD_HPP_INCLUDED
| [
"Sonicma7@0822fb10-d3c0-11de-a505-35228575a32e"
]
| [
[
[
1,
25
]
]
]
|
c2939ddeab35545f90be50f599f3fabc9954d2ed | a36d7a42310a8351aa0d427fe38b4c6eece305ea | /core_billiard/GeometryFactoryImp.cpp | c0fae84dd371dfa83dedbdc82d715fab916997d9 | []
| no_license | newpolaris/mybilliard01 | ca92888373c97606033c16c84a423de54146386a | dc3b21c63b5bfc762d6b1741b550021b347432e8 | refs/heads/master | 2020-04-21T06:08:04.412207 | 2009-09-21T15:18:27 | 2009-09-21T15:18:27 | 39,947,400 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,075 | cpp | #include "stdafx.h"
#include "my_render_imp.h"
namespace my_render_imp {
GeometryFactoryImp::GeometryFactoryImp( InstanceResolver * instanceResolver )
{
}
Geometry * GeometryFactoryImp::createGeometry( domGeometryRef geo ) {
const wstring id = convertString( geo->getId() );
const wstring name = convertString( geo->getName() );
const wstring uri = convertString( geo->getDocumentURI()->getURI() );
if( isAlreadyCreated( id ) ) return NULL;
domMeshRef const mesh = geo->getMesh();
domConvex_mesh * const convexMesh = geo->getConvex_mesh();
domSplineRef const spline = geo->getSpline();
if( ! ( mesh || convexMesh || spline ) ) return NULL;
Geometry * const newGeo = createGeometry( id, name, uri );
if( NULL == newGeo ) return NULL;
const bool bMesh = readGeometryMesh( newGeo->getMesh(), mesh );
assert( bMesh );
if( false == bMesh ) {
destroyGeometry( newGeo );
return NULL;
}
return newGeo;
}
Geometry * GeometryFactoryImp::createGeometry( wstring id, wstring name, wstring uri ) {
if( isAlreadyCreated( id ) ) return NULL;
GeometryImp * const newGeo = new GeometryImp();
if( NULL == newGeo ) return NULL;
geometries_.push_back( GeometryImpPtr( newGeo ) );
newGeo->setID( id );
newGeo->setName( name );
newGeo->setURI( uri );
return newGeo;
}
bool GeometryFactoryImp::isAlreadyCreated( wstring id ) {
return NULL != find( id );
}
Geometry * GeometryFactoryImp::find( wstring id ) {
MY_FOR_EACH( Geometries, iter, geometries_ ) {
if( (*iter)->getID() != id ) continue;
return iter->get();
}
return NULL;
}
bool GeometryFactoryImp::destroyGeometry( Geometry * ptr ) {
MY_FOR_EACH( Geometries, iter, geometries_ ) {
if( iter->get() != ptr ) continue;
GeometryMesh * const mesh = (*iter)->getMesh();
const size_t numberOfPrimitives = mesh->getNumberOfPrimitives();
for( size_t i = 0; i < numberOfPrimitives; ++i )
destroyGeometryMeshPrimitive( mesh->getPrimitive( i ) );
geometries_.erase( iter );
return true;
}
return false;
}
GeometryMeshPrimitiveImp * GeometryFactoryImp::createGeometryMeshPrimitive( wstring name, size_t triangleCount, wstring materialName, int primitiveTypeID )
{
GeometryMeshPrimitiveImp * const newPrim = new GeometryMeshPrimitiveImp();
if( NULL == newPrim ) return NULL;
primitives_.push_back( GeometryMeshPrimitivePtr( newPrim ) );
newPrim->setName( name );
newPrim->setTriangleCount( triangleCount );
newPrim->setMaterialName( materialName );
newPrim->setRenderingPrimitiveType( primitiveTypeID );
return newPrim;
}
bool GeometryFactoryImp::destroyGeometryMeshPrimitive( GeometryMeshPrimitive * ptr ) {
MY_FOR_EACH( Primitives, iter, primitives_ ) {
if( iter->get() != ptr ) continue;
primitives_.erase( iter );
return true;
}
return false;
}
}
| [
"wrice127@af801a76-7f76-11de-8b9f-9be6f49bd635"
]
| [
[
[
1,
100
]
]
]
|
3097822fe32d462e0e0e45fbdf1717898fbb81e7 | 629e4fdc23cb90c0144457e994d1cbb7c6ab8a93 | /lib/entity/entity.cpp | cb00bac799d7f0b087e292928e953b33310b9ef1 | []
| no_license | akin666/ice | 4ed846b83bcdbd341b286cd36d1ef5b8dc3c0bf2 | 7cfd26a246f13675e3057ff226c17d95a958d465 | refs/heads/master | 2022-11-06T23:51:57.273730 | 2011-12-06T22:32:53 | 2011-12-06T22:32:53 | 276,095,011 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 458 | cpp | /*
* entity.cpp
*
* Created on: 14.10.2011
* Author: akin
*/
#include "entity"
namespace ice
{
EntityKey Entity::s_id = 0xFF;
const EntityKey Entity::NIL = 0x0;
unsigned int Entity::genId()
{
return s_id++;
}
Entity::Entity()
: id( genId() )
{
}
Entity::Entity( const Entity& other )
: id( other.id )
{
}
Entity::Entity( EntityKey key )
: id( key )
{
}
Entity::~Entity()
{
}
} /* namespace ice */
| [
"akin@lich",
"akin@localhost"
]
| [
[
[
1,
12
],
[
15,
25
],
[
36,
40
]
],
[
[
13,
14
],
[
26,
35
]
]
]
|
b7b591fe18199b70a08645cdf3497305c346f56e | 4ed04c4f418f2404db1fb94363b30552623e53da | /TibiaTekBot Injected DLL/Constants.cpp | 207785c291824d6fd75247718aab708c2d895419 | []
| no_license | Cameri/tibiatekbot | 5f8ff3629d0fd2153ee2657af193ba2bc7585411 | f98695749224061ba13ab56e922efb8a971b6363 | refs/heads/master | 2020-05-25T12:05:39.437437 | 2009-05-29T23:46:21 | 2009-05-29T23:46:21 | 32,226,477 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,096 | cpp | #include "stdafx.h"
#include <string>
#include <windows.h>
#include "Constants.h"
namespace Consts {
/* General */
const unsigned int * INGAME = 0;
const unsigned int * ptrCharX = 0;
const unsigned int * ptrCharY = 0;
const unsigned int * ptrCharZ = 0;
const unsigned int * ptrCharacterID = 0;
/* Keyboard */
const unsigned int * POPUP = NULL;
/* Battlelist */
const unsigned int * ptrBattlelistBegin = 0;
unsigned int BLMax = 0;
unsigned int BLDist = 0;
unsigned int BLNameOffset = 0x4;
unsigned int BLLocationOffset = 0;
unsigned int BLOnScreenOffset = 0;
unsigned int BLHPPercentOffset = 0;
/* Displaying Text Stuff */
DWORD ptrPrintName = 0;
DWORD ptrPrintFPS = 0;
DWORD ptrShowFPS = 0;
DWORD ptrNopFPS = 0;
}
/* DLL Injection Related Stuff */
WNDPROC WndProc = 0;
HINSTANCE hMod = 0;
HWND TibiaWindowHandle = 0;
DWORD TibiaProcessID = 0;
/* Pipes */
std::string PipeName;
bool PipeConnected = false;
HANDLE PipeHandle = 0;
HANDLE PipeThread = 0;
BYTE Buffer[1024] = {0};
CRITICAL_SECTION PipeReadCriticalSection;
| [
"cameri2005@33ddfa00-593a-0410-b0c9-7b4335ea722e",
"oskari.virtanen@33ddfa00-593a-0410-b0c9-7b4335ea722e"
]
| [
[
[
1,
8
],
[
14,
18
],
[
32,
47
]
],
[
[
9,
13
],
[
19,
31
],
[
48,
48
]
]
]
|
28da482561ba49cd2c9a5839de02284b2d1e8610 | 7a4326a6fffc766fb3c126e01b2ff8cd811a7986 | /code/games/tank/src/GameHudTankZb.cpp | 41c48f9cd146c3be6fc4d723e3b39c36e396741e | []
| no_license | zhangchenghgd/zeroballistics | c326351f537d5a657e1441b978a3111441e1d8f2 | 34bb5f294b032ad025e3b4f5d82b86ac62245a10 | refs/heads/master | 2021-05-31T01:30:25.977219 | 2011-01-16T21:28:41 | 2011-01-16T21:28:41 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 10,559 | cpp |
#include "GameHudTankZb.h"
#include <limits>
#include <osg/Geode>
#include <osg/Group>
#include <osg/Geometry>
#include <osg/NodeCallback>
#include <osg/BlendFunc>
#include <osg/BlendColor>
#include "SceneManager.h"
#include "PuppetMasterClient.h"
#include "Tank.h"
#include "HudBar.h"
#include "HudAlphaBar.h"
#include "HudTextElement.h"
#include "Minimap.h"
#include "WeaponSystem.h"
#include "ParameterManager.h"
#include "Datatypes.h"
#include "GameLogicClientCommon.h" // used for time limit display
#undef min
#undef max
//------------------------------------------------------------------------------
GameHudTankZb::GameHudTankZb(PuppetMasterClient * master, const std::string & config_file) :
GameHudTank(master, config_file)
{
geode_->addDrawable(new HudTextureElement("back1"));
osg::Drawable * overlay = new HudTextureElement("back2");
geode_->addDrawable(overlay);
overlay->getOrCreateStateSet()->setRenderBinDetails(BN_HUD_OVERLAY, "RenderBin");
setupTankTurretHud("");
// Reload Bar
reload_bar_ = new HudAlphaBar("reload_bar");
geode_->addDrawable(reload_bar_.get());
reload_bar_skill1_ = new HudBar("reload_bar_skill1");
geode_->addDrawable(reload_bar_skill1_.get());
reload_bar_skill2_ = new HudBar("reload_bar_skill2");
geode_->addDrawable(reload_bar_skill2_.get());
// Health display
health_bar_ = new HudAlphaBar("health_bar");
geode_->addDrawable(health_bar_.get());
health_text_ = new HudTextElement("health");
geode_->addDrawable(health_text_.get());
// Upgrade Bars, lights
for (unsigned i=0; i<NUM_UPGRADE_CATEGORIES; ++i)
{
upgrade_bar_[i] = new HudAlphaBar("upgrade_bar" + toString(i+1));
geode_->addDrawable(upgrade_bar_[i].get());
upgrade_light_[i] = new HudTextureElement("upgrade_light" + toString(i+1));
upgrade_light_[i]->getOrCreateStateSet()->setRenderBinDetails(BN_HUD_OVERLAY, "RenderBin");
}
// Setup hit feedback
osg::Geode * hit_feedback_geode = new osg::Geode;
hit_feedback_ = new HudTextureElement("hit_feedback");
// blend out stateset
osg::StateSet * hit_feedback_stateset = hit_feedback_geode->getOrCreateStateSet();
hit_feedback_stateset->setAttribute(new osg::BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA));
hit_feedback_stateset->setMode(GL_BLEND, osg::StateAttribute::ON);
hit_feedback_stateset->setRenderingHint(BN_HUD_OVERLAY);
hit_feedback_geode->addDrawable(hit_feedback_.get());
group_->addChild(hit_feedback_geode);
// Frags
score_text_ = new HudTextElement("score");
geode_->addDrawable(score_text_.get());
// Time limit display
hud_time_limit_ = new HudTextElement("time_limit");
geode_->addDrawable(hud_time_limit_.get());
time_limit_bar_ = new HudAlphaBar(std::string("time_limit_bar"));
geode_->addDrawable(time_limit_bar_.get());
onWindowResized();
}
//------------------------------------------------------------------------------
GameHudTankZb::~GameHudTankZb()
{
}
//------------------------------------------------------------------------------
void GameHudTankZb::update(float dt)
{
GameHudTank::update(dt);
assert(puppet_master_);
GameLogicClientCommon * game_logic = (GameLogicClientCommon*)puppet_master_->getGameLogic();
PlayerScore * tracked_score = game_logic->getScore().getPlayerScore(game_logic->getTrackedPlayer());
if (!tracked_score) return;
Tank * tank = dynamic_cast<Tank*>(tracked_score->getPlayer()->getControllable());
if(tank)
{
float yaw,pitch;
tank->getProxyTurretPos(yaw,pitch);
osg::Matrix m = body_transform_->getMatrix();
m.setRotate(osg::Quat(-yaw,osg::Vec3(0.0,0.0,1.0)));
body_transform_->setMatrix(m);
health_bar_->setValue((float)tank->getHitpoints() /
(float)tank->getMaxHitpoints());
// show info for weapons ammo
WeaponSystem ** weapons = tank->getWeaponSystems();
reload_bar_ ->setValue(1.0f - weapons[0]->getCooldownStatus());
reload_bar_skill1_->setValue(weapons[2]->getCooldownStatus());
reload_bar_skill2_->setValue(weapons[3]->getCooldownStatus());
// ammo_text_->setText(toString(weapons[0]->getAmmo()));
// Upgrade bars & lights
uint16_t current_points = tracked_score->upgrade_points_;
for(unsigned c=0; c < NUM_UPGRADE_CATEGORIES; ++c)
{
UPGRADE_CATEGORY category = (UPGRADE_CATEGORY)c;
if(tracked_score->isUpgradeCategoryLocked(category))
{
enableUpgradeLight(category, false);
upgrade_bar_[c]->setValue(1.0f);
osg::Vec4Array * osg_color = (osg::Vec4Array*)upgrade_bar_[c]->getColorArray();
if ((*osg_color)[0].y() != 0.0f)
{
(*osg_color)[0].set(1, 0, 0, 0.5);
upgrade_bar_[c]->setColorArray(osg_color);
}
} else
{
uint16_t needed_points = tracked_score->getNeededUpgradePoints(category);
enableUpgradeLight(category, current_points >= needed_points);
upgrade_bar_[c]->setValue((float)current_points / needed_points);
osg::Vec4Array * osg_color = (osg::Vec4Array*)upgrade_bar_[c]->getColorArray();
if ((*osg_color)[0].y() != 1.0f)
{
(*osg_color)[0].x() = 1.0f;
(*osg_color)[0].y() = 1.0f;
(*osg_color)[0].z() = 1.0f;
upgrade_bar_[c]->setColorArray(osg_color);
}
}
}
score_text_->setText(toString(tracked_score->kills_));
health_text_->setText(toString(tank->getHitpoints()));
}
// Update hit feedback
setHitFeedbackBlend(std::max(getHitFeedbackBlend() - (dt / BLEND_OUT_HIT_MARKER_TIME), 0.0f));
// update remaining time
float time_left = game_logic->getScore().getTimeLeft();
float perc = 1.0f;
// time_left / s_params.get<float>("server.settings.time_limit");
// XXXX change this as soon as server->client parameter
// transmission works
unsigned minutes = (unsigned)(time_left / 60.0f);
time_left -= minutes*60;
unsigned seconds = (unsigned)time_left;
time_left -= seconds;
std::ostringstream strstr;
strstr << std::setw(3) << std::setfill(' ') << minutes << ":";
strstr << std::setw(2) << std::setfill('0') << seconds;
hud_time_limit_->setText(strstr.str());
time_limit_bar_->setValue(perc);
}
//------------------------------------------------------------------------------
void GameHudTankZb::onWindowResized()
{
GameHudTank::onWindowResized();
Vector2d pos = HudTextureElement::getScreenCoords("attitude_display");
float size = HudTextureElement::alignAndGetSize("attitude_display", pos);
osg::Matrix scale_n_offset;
scale_n_offset.makeScale(osg::Vec3(size,
size, 1.0f));
scale_n_offset.setTrans(pos.x_, pos.y_, 0.0f);
tank_orientation_->setMatrix(scale_n_offset);
hud_time_limit_->recalcTextPos();
score_text_->recalcTextPos();
health_text_->recalcTextPos();
// ammo_text_->recalcTextPos();
}
//------------------------------------------------------------------------------
void GameHudTankZb::activateHitFeedback()
{
setHitFeedbackBlend(1.0f);
}
//------------------------------------------------------------------------------
void GameHudTankZb::setAttitudeTexture(const std::string & tex)
{
DeleteNodeVisitor v1(body_transform_.get());
DeleteNodeVisitor v2(tank_orientation_.get());
s_scene_manager.getRootNode()->accept(v1);
s_scene_manager.getRootNode()->accept(v2);
assert(body_transform_ ->referenceCount() == 1);
assert(tank_orientation_->referenceCount() == 1);
body_transform_ = NULL;
tank_orientation_ = NULL;
setupTankTurretHud(tex);
onWindowResized(); // XXX HACK?
}
//------------------------------------------------------------------------------
void GameHudTankZb::setupTankTurretHud(const std::string & tex)
{
// Screen position transform
tank_orientation_ = new osg::MatrixTransform;
tank_orientation_->setName("HUD tank screen pos");
// tank body transform
body_transform_ = new osg::MatrixTransform;
body_transform_->setName("HUD tank body");
tank_orientation_->addChild(body_transform_.get());
group_->addChild(tank_orientation_.get());
if (!tex.empty())
{
osg::ref_ptr<osg::Geode> turret_geode = new osg::Geode;
turret_geode->addDrawable(new HudTextureElement("attitude_turret", "data/textures/hud/turret_" + tex + ".dds"));
turret_geode->setName("Turret");
tank_orientation_->addChild(turret_geode.get());
osg::ref_ptr<osg::Geode> body_geode = new osg::Geode;
body_geode->addDrawable(new HudTextureElement("attitude_tank", "data/textures/hud/tank_" + tex + ".dds"));
body_geode->setName("Body");
body_transform_->addChild(body_geode.get());
}
}
//------------------------------------------------------------------------------
void GameHudTankZb::enableUpgradeLight(UPGRADE_CATEGORY category, bool e)
{
if (!e && upgrade_light_[category]->getNumParents() == 1)
{
((osg::Geode*)upgrade_light_[category]->getParent(0))->removeDrawable(upgrade_light_[category].get());
} else if (e && upgrade_light_[category]->getNumParents() == 0)
{
geode_->addDrawable(upgrade_light_[category].get());
}
}
//------------------------------------------------------------------------------
void GameHudTankZb::setHitFeedbackBlend(float b)
{
osg::Vec4Array * osg_color = (osg::Vec4Array*)hit_feedback_->getColorArray();
(*osg_color)[0].set(1, 1, 1, b);
}
//------------------------------------------------------------------------------
float GameHudTankZb::getHitFeedbackBlend() const
{
osg::Vec4Array * osg_color = (osg::Vec4Array*)hit_feedback_->getColorArray();
return (float)(*osg_color)[0].a();
}
| [
"musch@2846cbf5-6c17-0410-bc73-dc7e12504047"
]
| [
[
[
1,
306
]
]
]
|
c2878b4296ba8893fa69e6e8209ade424e4e094b | 95a3e8914ddc6be5098ff5bc380305f3c5bcecb2 | /src/FusionForever_lib/Projectile.cpp | 24f99f361546f383f85aeafe07734586f1c7fc72 | []
| no_license | danishcake/FusionForever | 8fc3b1a33ac47177666e6ada9d9d19df9fc13784 | 186d1426fe6b3732a49dfc8b60eb946d62aa0e3b | refs/heads/master | 2016-09-05T16:16:02.040635 | 2010-04-24T11:05:10 | 2010-04-24T11:05:10 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 691 | cpp | #include "StdAfx.h"
#include "Projectile.h"
int Projectile::projectile_spawn_count_ = 0;
int Projectile::projectile_free_count_ = 0;
Projectile::Projectile(void)
: BaseEntity()
{
damage_ = 10;
lifetime_ = 5;
mass_ = 100;
moment_ = 1;
firer_id_ = -1;
projectile_spawn_count_++;
}
Projectile::~Projectile(void)
{
projectile_free_count_ ++;
}
void Projectile::Tick(float _timespan, std::vector<Decoration_ptr>& /*_spawn_dec*/, Matrix4f _transform)
{
lifetime_ -= _timespan;
BaseEntity::Tick(_timespan, _transform);
}
void Projectile::DrawSelf()
{
glPushMatrix();
glLoadMatrixf(ltv_transform_);
fill_.DrawFillDisplayList();
glPopMatrix();
}
| [
"Edward Woolhouse@e6f1df29-e57c-d74d-9e6e-27e3b006b1a7",
"[email protected]"
]
| [
[
[
1,
22
],
[
24,
35
]
],
[
[
23,
23
]
]
]
|
216a2f499458dd40054fb2434b1ba679bfca9c58 | 6c8c4728e608a4badd88de181910a294be56953a | /CommunicationModule/CommunicationUI/LoginHelper.cpp | c9cf7ade146b3640ea4ba76eef844b98deac97d2 | [
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference"
]
| permissive | caocao/naali | 29c544e121703221fe9c90b5c20b3480442875ef | 67c5aa85fa357f7aae9869215f840af4b0e58897 | refs/heads/master | 2021-01-21T00:25:27.447991 | 2010-03-22T15:04:19 | 2010-03-22T15:04:19 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,738 | cpp | // For conditions of distribution and use, see copyright notice in license.txt
#include "StableHeaders.h"
#include "DebugOperatorNew.h"
#include "LoginHelper.h"
#include "Credentials.h"
#include "CommunicationService.h"
#include "ConnectionInterface.h"
#include "CoreDefines.h"
#include "CoreException.h"
#include <QUrl>
#include "MemoryLeakCheck.h"
namespace UiHelpers
{
LoginHelper::LoginHelper()
: QObject(),
login_ui_(0),
communication_service_(Communication::CommunicationService::GetInstance()),
im_connection_(0),
error_message_(""),
username_(""),
server_(""),
password_("")
{
}
LoginHelper::~LoginHelper()
{
login_ui_ = 0;
im_connection_ = 0;
communication_service_ = 0;
}
void LoginHelper::SetupUi(Ui::LoginWidget *login_ui)
{
SAFE_DELETE(login_ui_);
login_ui_ = login_ui;
}
QString LoginHelper::GetErrorMessage()
{
return error_message_;
}
QMap<QString, QString> LoginHelper::GetPreviousCredentials()
{
QMap<QString, QString> data_map;
data_map["username"] = username_;
data_map["server"] = server_;
data_map["password"] = password_;
return data_map;
}
void LoginHelper::TryLogin()
{
assert(login_ui_);
username_ = login_ui_->usernameLineEdit->text();
server_ = login_ui_->serverLineEdit->text();
password_ = login_ui_->passwordLineEdit->text();
// Username validation
if (!username_.contains("@"))
username_.append(QString("@%1").arg(server_));
// Server and port validation
if (!server_.startsWith("http://") || !server_.startsWith("https://"))
server_ = "http://" + server_;
QUrl server_url(server_);
if (server_url.port() == -1)
server_url.setPort(5222);
// Create the credentials
Communication::Credentials credentials;
credentials.SetProtocol("jabber");
credentials.SetUserID(username_);
credentials.SetPassword(password_);
credentials.SetServer(server_url.host());
credentials.SetPort(server_url.port());
server_ = server_url.authority();
try
{
im_connection_ = 0; // CommunicationService will delete this
im_connection_ = communication_service_->OpenConnection(credentials);
}
catch (Exception &/*e*/) { /* e.what() for error */ }
connect(im_connection_, SIGNAL( ConnectionReady(Communication::ConnectionInterface&) ), SLOT( ConnectionEstablished(Communication::ConnectionInterface&) ));
connect(im_connection_, SIGNAL( ConnectionError(Communication::ConnectionInterface&) ), SLOT( ConnectionFailed(Communication::ConnectionInterface&) ));
emit StateChange(UiDefines::UiStates::Connecting);
}
void LoginHelper::LoginCanceled()
{
error_message_ = "Connecting operation canceled";
im_connection_->Close();
emit StateChange(UiDefines::UiStates::Disconnected);
}
void LoginHelper::ConnectionFailed(Communication::ConnectionInterface &connection_interface)
{
error_message_ = "Connecting failed, please check your credentials";
im_connection_->Close();
emit StateChange(UiDefines::UiStates::Disconnected);
}
void LoginHelper::ConnectionEstablished(Communication::ConnectionInterface &connection_interface)
{
error_message_ = "";
emit StateChange(UiDefines::UiStates::Connected);
}
} | [
"jonnenau@5b2332b8-efa3-11de-8684-7d64432d61a3",
"jujjyl@5b2332b8-efa3-11de-8684-7d64432d61a3",
"Stinkfist0@5b2332b8-efa3-11de-8684-7d64432d61a3",
"mattiku@5b2332b8-efa3-11de-8684-7d64432d61a3"
]
| [
[
[
1,
3
],
[
5,
8
],
[
12,
14
],
[
17,
38
],
[
50,
68
],
[
70,
87
],
[
89,
89
],
[
91,
92
],
[
94,
120
]
],
[
[
4,
4
],
[
9,
11
],
[
15,
16
],
[
39,
49
]
],
[
[
69,
69
],
[
88,
88
],
[
93,
93
]
],
[
[
90,
90
]
]
]
|
396e96d87547e8cf61626f97728d0ffa246ccc04 | 0f8559dad8e89d112362f9770a4551149d4e738f | /Wall_Destruction/Algorithms/CSGTree.h | 30e986e9184582c3b08a2f9436063b01da270c13 | []
| no_license | TheProjecter/olafurabertaymsc | 9360ad4c988d921e55b8cef9b8dcf1959e92d814 | 456d4d87699342c5459534a7992f04669e75d2e1 | refs/heads/master | 2021-01-10T15:15:49.289873 | 2010-09-20T12:58:48 | 2010-09-20T12:58:48 | 45,933,002 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,530 | h | #ifndef CSGTREE_H
#define CSGTREE_H
#include "Volume.h"
enum OPERATOR_TYPE {AND, OR};
/* CSG Tree:
N
/ \
/ \
N N
/ \ / \
/ \ V N
V V / \
V V
V = Volume
N = Operator Node
*/
struct OPERATOR_NODE{
OPERATOR_TYPE type;
// if left or right is an in-tree operator
OPERATOR_NODE *NLeft;
OPERATOR_NODE *NRight;
// If left or right is a leave
Volume *Left;
Volume *Right;
};
class CSGTree
{
public:
CSGTree(void);
~CSGTree(void);
void CreateTree(OPERATOR_NODE* node){
this->Root = node;
}
Volume* GetComputedVolume();
// and's
OPERATOR_NODE* And(Volume *Left, Volume *Right);
OPERATOR_NODE* And(Volume *Left, OPERATOR_NODE *Right);
OPERATOR_NODE* And(OPERATOR_NODE *Left, Volume *Right);
OPERATOR_NODE* And( OPERATOR_NODE *Left, OPERATOR_NODE *Right );
// or's
OPERATOR_NODE* Or(Volume *Left, Volume *Right);
OPERATOR_NODE* Or(Volume *Left, OPERATOR_NODE *Right);
OPERATOR_NODE* Or(OPERATOR_NODE *Left, Volume *Right);
OPERATOR_NODE* Or(OPERATOR_NODE *Left, OPERATOR_NODE *Right );
// Get the surface of the object
Volume* Compute();
void CleanUp();
private:
OPERATOR_NODE *Root;
void CleanUpNode(OPERATOR_NODE* node);
Volume *volume;
OPERATOR_NODE* CreateNode(Volume *Left, Volume *Right, OPERATOR_NODE *NLeft, OPERATOR_NODE *NRight, OPERATOR_TYPE type);
// compute the surface from a operator node
Volume* Compute(OPERATOR_NODE *N);
};
#endif | [
"[email protected]"
]
| [
[
[
1,
71
]
]
]
|
6cc05df615244b6670b85b4b30cfb0ff9d61ca50 | 4d5ee0b6f7be0c3841c050ed1dda88ec128ae7b4 | /src/nvmesh/tools/baker/Samplers.cpp | 7b991dd3fa98365f394258a598fa9dfc9bc84590 | []
| no_license | saggita/nvidia-mesh-tools | 9df27d41b65b9742a9d45dc67af5f6835709f0c2 | a9b7fdd808e6719be88520e14bc60d58ea57e0bd | refs/heads/master | 2020-12-24T21:37:11.053752 | 2010-09-03T01:39:02 | 2010-09-03T01:39:02 | 56,893,300 | 0 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 11,060 | cpp | // Copyright NVIDIA Corporation 2008 -- Ignacio Castano <[email protected]>
#include <nvmath/Montecarlo.h>
#include <nvmesh/raytracing/Raytracing.h>
#include <nvmesh/kdtree/KDTree.h>
#include "Samplers.h"
#include "BaseSurface.h"
using namespace nv;
GeometrySampler::GeometrySampler(GeometryImage & image, BitMap & imageMask) : m_image(image), m_imageMask(imageMask)
{
nvCheck(image.width() == imageMask.width());
nvCheck(image.height() == imageMask.height());
}
/*static*/
void GeometrySampler::sampleTriCallback(void * param, int x, int y, Vector3::Arg bar, Vector3::Arg dx, Vector3::Arg dy, float coverage)
{
((GeometrySampler *)param)->sampleTri(x, y, bar, dx, dy, coverage);
}
/*static*/
void GeometrySampler::sampleQuadCallback(void * param, int x, int y, Vector3::Arg bar, Vector3::Arg dx, Vector3::Arg dy, float coverage)
{
((GeometrySampler *)param)->sampleQuad(x, y, bar, dx, dy, coverage);
}
void GeometrySampler::setCurrentFace(uint vertexCount, const Vector3 * positions, const Vector3 * normals)
{
nvDebugCheck(vertexCount<=4);
m_positions = positions;
m_normals = normals;
for (uint k=0; k<vertexCount; k++)
{
m_midedgenormals[k] = normalizeSafe(normals[k] + normals[(k+1)%vertexCount], Vector3(zero), 0);
}
if (vertexCount==4) {
m_midedgenormals[4] = normalizeSafe(m_normals[0]+normals[1]+normals[2]+normals[3], Vector3(zero), 0);
}
}
void GeometrySampler::sampleTri(int x, int y, Vector3::Arg bar, Vector3::Arg dx, Vector3::Arg dy, float coverage)
{
nvDebugCheck(isFinite(coverage));
Vector3 position = bar.x() * m_positions[0] + bar.y() * m_positions[1] + bar.z() * m_positions[2];
m_image.addPixel(coverage * position, x, y, m_image.positionChannel());
//Vector3 normal = normalizeSafe(cross(m_positions[1] - m_positions[0], m_positions[2] - m_positions[0]), Vector3(zero), 0.0f);
Vector3 linearNormal = normalizeSafe(bar.x() * m_normals[0] + bar.y() * m_normals[1] + bar.z() * m_normals[2], Vector3(zero), 0.0f);
float u=bar.x(), v=bar.y(), w=bar.z();
Vector3 normal = normalizeSafe( u*u*m_normals[0] + v*v*m_normals[1] + w*w*m_normals[2] +
2*(u*v*m_midedgenormals[0] + v*w*m_midedgenormals[1] + w*u*m_midedgenormals[2]), Vector3(zero), 0);
float mx = max(max(u,v),w);
m_image.addPixel(coverage * normal, x, y, m_image.normalChannel());
/*if (m_image.occlusionChannel() != -1)
{
float occlusion = sampleOcclusion(position, normal, x, y);
nvCheck(occlusion >= 0.0f && occlusion <= 1.0f);
m_image.addPixel(coverage * occlusion, x, y, m_image.occlusionChannel());
}*/
m_image.addPixel(coverage, x, y, m_image.coverageChannel());
m_imageMask.setBitAt(x, y);
}
static inline float triangleArea(Vector2::Arg a, Vector2::Arg b, Vector2::Arg c)
{
Vector2 v0 = a - c;
Vector2 v1 = b - c;
return (v0.x() * v1.y() - v0.y() * v1.x());
}
void GeometrySampler::sampleQuad(int x, int y, Vector3::Arg bar, Vector3::Arg dx, Vector3::Arg dy, float coverage)
{
nvDebugCheck(isFinite(coverage));
const float u = bar.x(), U = 1-u;
const float v = bar.y(), V = 1-v;
// bilinear position interpolation
Vector3 position = (U * m_positions[0] + u * m_positions[1]) * V +
(U * m_positions[3] + u * m_positions[2]) * v;
m_image.addPixel(coverage * position, x, y, m_image.positionChannel());
// biquadratic normal interpolation
Vector3 normal = normalizeSafe(
(U*U * m_normals[0] + 2*U*u*m_midedgenormals[0] + u*u * m_normals[1]) * V*V +
(U*U*m_midedgenormals[3] + 2*U*u*m_midedgenormals[4] + u*u*m_midedgenormals[1]) * 2*V*v +
(U*U * m_normals[3] + 2*U*u*m_midedgenormals[2] + u*u * m_normals[2]) * v*v, Vector3(zero), 0);
m_image.addPixel(coverage * normal, x, y, m_image.normalChannel());
/*
if (m_image.occlusionChannel() != -1)
{
// piecewise linear position interpolation
#if 0
Vector3 tripos;
if (u < v)
{
float barx = triangleArea(Vector2(1,1), Vector2(0,1), Vector2(u,v));
float bary = triangleArea(Vector2(0,0), Vector2(1,1), Vector2(u,v));
float barz = triangleArea(Vector2(0,1), Vector2(0,0), Vector2(u,v));
nvCheck(equal(1, barx+bary+barz));
tripos = barx * m_positions[0] + bary * m_positions[1] + barz * m_positions[2];
}
else
{
float barx = triangleArea(Vector2(1,0), Vector2(1,1), Vector2(u,v));
float bary = triangleArea(Vector2(1,1), Vector2(0,0), Vector2(u,v));
float barz = triangleArea(Vector2(0,0), Vector2(1,0), Vector2(u,v));
nvCheck(equal(1, barx+bary+barz));
tripos = barx * m_positions[0] + bary * m_positions[3] + barz * m_positions[2];
}
#endif
float occlusion = sampleOcclusion(position, normal, x, y);
nvCheck(occlusion >= 0.0f && occlusion <= 1.0f);
m_image.addPixel(coverage * occlusion, x, y, m_image.occlusionChannel());
}
*/
m_image.addPixel(coverage, x, y, m_image.coverageChannel());
m_imageMask.setBitAt(x, y);
}
DisplacementPatchSampler::DisplacementPatchSampler(const GeometryImage & detailedGeometryMap, const BitMap & detailedGeometryMask, GeometryImage & geometryMap, BitMap & geometryMask) :
m_detailedGeometryMap(detailedGeometryMap),
m_detailedGeometryMask(detailedGeometryMask),
m_geometryMap(geometryMap),
m_geometryMask(geometryMask)
{
nvCheck(geometryMap.width() == geometryMask.width());
nvCheck(geometryMap.height() == geometryMask.height());
}
/*static*/ void DisplacementPatchSampler::sampleCallback(void * param, int x, int y, Vector3::Arg bar, Vector3::Arg dx, Vector3::Arg dy, float coverage)
{
((DisplacementPatchSampler *)param)->sample(x, y, bar, dx, dy, coverage);
}
// setDetailedGeometryMap(const GeometryImage & detailedGeometryMap, const BitMap & detailedGeometryMask);
// setOutputGeometryMap(GeometryImage & detailedGeometryMap, BitMap & detailedGeometryMask);
void DisplacementPatchSampler::setTangentSpace(bool enabled)
{
m_tangentSpace = enabled;
}
void DisplacementPatchSampler::setVectorDisplacement(bool enabled)
{
m_vectorDisplacement = enabled;
}
void DisplacementPatchSampler::setCurrentSurface(const BaseSurface * surface)
{
m_surface = surface;
}
void DisplacementPatchSampler::sample(int x, int y, Vector3::Arg bar, Vector3::Arg dx, Vector3::Arg dy, float coverage)
{
const float u = bar.x();
const float v = bar.y();
Vector3 origin;
Basis patchFrame;
Basis chartFrame;
m_surface->evaluate(u, v, &origin, &patchFrame, &chartFrame);
float normalDeviation = dot(chartFrame.normal, patchFrame.normal);
//tni: remove it for now
//patchFrame.normal = chartFrame.normal;
#if 0
Vector3 tangentSpaceNormal = chartFrame.tangent;
// tangentSpaceNormal = chartFrame.bitangent;
// tangentSpaceNormal = chartFrame.normal;
m_geometryMap.addPixel(coverage * tangentSpaceNormal, x, y, m_geometryMap.normalChannel());
// Update coverage.
m_geometryMap.addPixel(coverage, x, y, m_geometryMap.coverageChannel());
m_geometryMask.setBitAt(x, y);
return;
#endif
// assuming coverage has been normalized before!!
if (m_detailedGeometryMask.bitAt(x, y))
{
// Compute tangent space normal.
if (m_detailedGeometryMap.normalChannel() != -1)
{
if (m_tangentSpace)
{
const Vector3 normal = 2 * m_detailedGeometryMap.normal(x, y) - 1;
Vector3 tangentSpaceNormal = chartFrame.transformI(normal);
tangentSpaceNormal = normalizeSafe(tangentSpaceNormal, Vector3(zero), 0);
// tangentSpaceNormal = Vector3(normalDeviation, normalDeviation, normalDeviation);
m_geometryMap.addPixel(coverage * tangentSpaceNormal, x, y, m_geometryMap.normalChannel());
}
}
if (m_detailedGeometryMap.positionChannel() != -1)
{
// Compute displacement.
const Vector3 dest = m_detailedGeometryMap.position(x, y);
const Vector3 displacement = dest - origin;
if (m_vectorDisplacement)
{
if (m_tangentSpace)
{
Vector3 tangentSpaceDisplacement = chartFrame.transformI(displacement);
m_geometryMap.addPixel(coverage * tangentSpaceDisplacement, x, y, m_geometryMap.displacementChannel());
}
else
{
m_geometryMap.addPixel(coverage * displacement, x, y, m_geometryMap.displacementChannel());
}
}
else
{
//tni: remove it for now, since chart frame is not computed at all
//float l = dot(chartFrame.normal, displacement);
float l = dot(patchFrame.normal, displacement);
m_geometryMap.addPixel(coverage * l, x, y, m_geometryMap.displacementChannel());
}
}
// Update coverage.
m_geometryMap.addPixel(coverage, x, y, m_geometryMap.coverageChannel());
m_geometryMask.setBitAt(x, y);
}
}
// SCALAR DISPLACEMENTS
/*
void sampleAA(int x, int y, Vector3::Arg bar, Vector3::Arg dx, Vector3::Arg dy, float coverage)
{
nvDebugCheck(m_positions != NULL);
nvDebugCheck(m_normals != NULL);
nvDebugCheck(isFinite(coverage));
const float u = bar.y();
const float v = bar.x();
Vector3 origin = ((1-u) * m_positions[0] + (u) * m_positions[1]) * (1-v) +
((1-u) * m_positions[3] + (u) * m_positions[2]) * (v);
Vector3 normal = normalizeSafe(
((1-u) * m_normals[0] + (u) * m_normals[1]) * (1-v) +
((1-u) * m_normals[3] + (u) * m_normals[2]) * (v), Vector3(zero), 0.0f);
Vector3 dest = Vector3(
m_geometryMap.pixel(x, y, 0),
m_geometryMap.pixel(x, y, 1),
m_geometryMap.pixel(x, y, 2));
dest /= m_geometryMap.pixel(x, y, 6); // normalize just to be sure
Vector3 displacement = dest - origin;
// Make sure that displacement is roughly in the right direction.
// if(!equal(dot(normal, normalize(displacement)), 1, NV_NORMAL_EPSILON))
// {
// float diff = dot(normal, normalize(displacement));
// printf("%f\n", diff);
// nvDebugBreak();
// }
// @@ Project displacement onto normal?
if (length(displacement) < m_outlierThreshold)
{
m_displacementMap.addPixel(coverage * length(displacement), x, y, 0);
m_displacementMap.addPixel(coverage, x, y, 1);
m_displacementMask.setBitAt(x, y);
}
}
*/
// Vector Displacement from flat quads
/*
void sampleAA(int x, int y, Vector3::Arg bar, Vector3::Arg dx, Vector3::Arg dy, float coverage)
{
nvDebugCheck(m_positions != NULL);
nvDebugCheck(m_normals != NULL);
const float u = bar.y();
const float v = bar.x();
Vector3 origin = ((1-u) * m_positions[0] + (u) * m_positions[1]) * (1-v) +
((1-u) * m_positions[3] + (u) * m_positions[2]) * (v);
Vector3 destiny = Vector3(
m_geometryMap.pixel(x, y, 0),
m_geometryMap.pixel(x, y, 1),
m_geometryMap.pixel(x, y, 2)); // assuming subpixel-coverage normalized to 1
Vector3 displacement = destiny - origin;
if (length(displacement) < m_outlierThreshold)
{
m_displacementMap.setPixel(displacement.x(), x, y, 0);
m_displacementMap.setPixel(displacement.y(), x, y, 1);
m_displacementMap.setPixel(displacement.z(), x, y, 2);
m_displacementMask.setBitAt(x, y);
}
}
*/
| [
"castano@0f2971b0-9fc2-11dd-b4aa-53559073bf4c",
"tianyun06@0f2971b0-9fc2-11dd-b4aa-53559073bf4c"
]
| [
[
[
1,
202
],
[
205,
257
],
[
261,
351
]
],
[
[
203,
204
],
[
258,
260
]
]
]
|
7bbe1418bbd32e7724808e3dbc872f072beca7f6 | e7c45d18fa1e4285e5227e5984e07c47f8867d1d | /Common/Scd/ScExec/SP_DBExtra.h | e1e08e5e40b88b02ef8730a29020c56b8420cce0 | []
| 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,179 | h | //================== SysCAD - Copyright Kenwalt (Pty) Ltd ===================
// $Nokeywords: $
//===========================================================================
#ifndef __SP_DBEXTRA_H
#define __SP_DBEXTRA_H
#ifndef __SC_DEFS_H
#include "sc_defs.h"
#endif
#ifndef __SP_DB_H
#include "sp_db.h"
#endif
#if defined(__SP_DBEXTRA_CPP)
#define DllImportExport DllExport
#elif !defined(SCEXEC)
#define DllImportExport DllImport
#else
#define DllImportExport
#endif
//===========================================================================
class DllImportExport SpeciePropCfgItem
{
public:
Strng Name;
short iWidth;
byte bOptional:1,
bFound:1,
bString:1,
bDisplay:1;
SpeciePropCfgItem();
SpeciePropCfgItem(char* pName, short Width, byte String, byte Display=1, byte Optional=0);
void Set(char* pName, short Width, byte String, byte Display=1, byte Optional=0);
};
class DllImportExport SpeciePropCfgHelper
{
friend class SpecieProp;
//friend class CSpeciePropDataBase;
protected:
int iPropCnt;
SpeciePropCfgItem * pCfgItems;
char ** pPropNames;
char ** pOptPropNames;
public:
SpeciePropCfgHelper();
~SpeciePropCfgHelper();
void Init(SpeciePropCfgItem * CfgItems, int Count);
int PropCount() { return iPropCnt; };
char ** PropNames() { return pPropNames; };
char ** OptPropNames() { return pOptPropNames; };
SpeciePropCfgItem* CfgItem(int PropIndex) { return &pCfgItems[PropIndex]; };
char* Name(int PropIndex) { return pCfgItems[PropIndex].Name(); };
int Width(int PropIndex) { return pCfgItems[PropIndex].iWidth; };
bool Optional(int PropIndex) { return pCfgItems[PropIndex].bOptional; };
bool Found(int PropIndex) { return pCfgItems[PropIndex].bFound; };
bool String(int PropIndex) { return pCfgItems[PropIndex].bString; };
bool Display(int PropIndex) { return pCfgItems[PropIndex].bDisplay; };
};
//---------------------------------------------------------------------------
class DllImportExport SpecieProp
{
friend class CSpeciePropDataBase;
protected:
unsigned int bOK:1;
int iSId;
SpeciePropCfgHelper* pPropCfg;
double* dProp;
Strng* sProp;
public:
SpecieProp(SpeciePropCfgHelper* PropCfg, int SId);
virtual ~SpecieProp();
int Load(CStringArray & Values);
bool OK() { return bOK; };
SpeciePropCfgHelper* PropCfg() { return pPropCfg; };
char* Name(int PropIndex) { return pPropCfg->Name(PropIndex); };
double Prop(int PropIndex) { return dProp[PropIndex]; };
char* StrProp(int PropIndex) { return sProp[PropIndex](); };
char* Tag() { return SDB[iSId].Tag(); };
CSpecie & Specie() { return SDB[iSId]; };
};
//---------------------------------------------------------------------------
class DllImportExport CSpeciePropDataBase
{
friend class OrePropDataBase;
private:
SpeciePropCfgHelper PropCfg;
SpecieProp * SP[MaxSpecies];
int iSpCnt;
public:
CSpeciePropDataBase();
virtual ~CSpeciePropDataBase();
int Init(SpeciePropCfgItem * CfgItems, int Count);
int Load(char* DataFile, char* TableName);
SpecieProp * FindSolid(char* Tag);
SpecieProp * Find(int SpId);
SpecieProp * operator [](int index) { return index<iSpCnt ? SP[index] : NULL; };
SpecieProp * GetProp(int index) { return index<iSpCnt ? SP[index] : NULL; };
int GetCount() { return iSpCnt; };
int PropCount() { return PropCfg.PropCount(); };
char* PropName(int PropIndex) { return PropCfg.Name(PropIndex); };
SpeciePropCfgHelper* GetPropCfg() { return &PropCfg; };
};
//===========================================================================
#undef DllImportExport
#endif
| [
"[email protected]"
]
| [
[
[
1,
122
]
]
]
|
53067f0348ade4122617e860d00f4d31a1ab8282 | 611fc0940b78862ca89de79a8bbeab991f5f471a | /src/Teki/Boss/Ookami/ASOokamiJumpingDeath.cpp | 880d26421580c81db5081e36d49c1d7bced7ab1d | []
| no_license | LakeIshikawa/splstage2 | df1d8f59319a4e8d9375b9d3379c3548bc520f44 | b4bf7caadf940773a977edd0de8edc610cd2f736 | refs/heads/master | 2021-01-10T21:16:45.430981 | 2010-01-29T08:57:34 | 2010-01-29T08:57:34 | 37,068,575 | 0 | 0 | null | null | null | null | SHIFT_JIS | C++ | false | false | 1,545 | cpp | #include <string>
#include <vector>
#include <exception>
using namespace std;
#include "..\\..\\..\\Mob\\ActionControllable\\ActionControllable.h"
#include "..\\..\\..\\Management\\GameControl.h"
#include "ASOokamiJumpingDeath.h"
/************************************************************//**
* アニメーション
****************************************************************/
void ASOokamiJumpingDeath::BuildAnimation(ActionState* rPrevState)
{
mAnimation = Animation::ParseFromFile( "data\\animdata\\ookami\\Death.txt" );
}
/************************************************************//**
* 破片の作成と風を止める
****************************************************************/
void ASOokamiJumpingDeath::OnEnter()
{
// 風
if( storm ) {
GAMECONTROL->GetMobManager()->Remove(storm);
storm = NULL;
}
// 家
/*if( brick ) {
brick->Destroy();
}*/
if( straw ) straw->StopParticles();
if( rog ) straw->StopParticles();
// 基本処理
ASJumpingDeath::OnEnter();
// SE
GAMECONTROL->GetSoundController()->StopSE("audio\\se\\se_boss2_bress_atack.wav");
GAMECONTROL->GetSoundController()->StopSE("audio\\se\\se_boss2_bress_out.wav");
GAMECONTROL->GetSoundController()->StopSE("audio\\se\\se_boss2_bress_tame.wav");
GAMECONTROL->GetSoundController()->StopSE("audio\\se\\se_boss2_move.wav");
GAMECONTROL->GetSoundController()->StopSE("audio\\se\\se_boss2_house_break.wav");
GAMECONTROL->GetSoundController()->PlaySE("audio\\se\\se_teki_down.wav");
}
| [
"lakeishikawa@c9935178-01ba-11df-8f7b-bfe16de6f99b",
"cat2.silly.affection@c9935178-01ba-11df-8f7b-bfe16de6f99b"
]
| [
[
[
1,
37
],
[
48,
48
]
],
[
[
38,
47
]
]
]
|
7058b459ab905fc380c2a29ffad947e3b056ef3c | 5851a831bcc95145bf501b40e90e224d08fa4ac9 | /src/ui_main.cpp | 0fef0e6c57fdfcf8dc2cdcffa3f2e8b7e54b99b1 | []
| no_license | jemyzhang/Cashup | a80091921a2e74f24db045dd731f7bf43c09011a | f4e768a7454bfa437ad9842172de817fa8da71e2 | refs/heads/master | 2021-01-13T01:35:51.871352 | 2010-03-06T14:26:55 | 2010-03-06T14:26:55 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,257 | cpp | #include <cMzCommon.h>
using namespace cMzCommon;
#include "ui_main.h"
#include "resource.h"
#include <UiIconButton.h>
#include "commondef.h"
#define MZ_IDC_TOOLBAR_MAIN 101
#define MZ_IDC_SCROLLWIN 102
#define MZ_IDC_TITLE 103
#ifdef _DEBUG
#define COMPILEM L"D"
#else
#define COMPILEM L"R"
#endif
#ifdef MZFC_STATIC
#define COMPILEL L"s"
#else
#define COMPILEL L"d"
#endif
#define VER_STRING L"3.00"COMPILEL
#define BUILD_STRING L"201003060001" COMPILEM
extern ImagingHelper *pimg[IDB_PNG_END - IDB_PNG_BEGIN + 1];
extern HINSTANCE LangresHandle;
class UiModuleItem : public UiIconButton{
public:
UiModuleItem(CPluginBase* obj, int nID) : UiIconButton() {
this->SetText(obj->GetName());
this->SetImage(obj->GetIconImage());
this->SetID(nID);
}
};
MZ_IMPLEMENT_DYNAMIC(Ui_MainWnd)
Ui_MainWnd::Ui_MainWnd(){
module_cnt = 0;
}
Ui_MainWnd::~Ui_MainWnd(){
::UnLoadPlugins(true);
}
BOOL Ui_MainWnd::OnInitDialog() {
// Must all the Init of parent class first!
if (!Ui_BaseWnd::OnInitDialog()) {
return FALSE;
}
// Then init the controls & other things in the window
int y = GetHeight() - 120;
m_TextAbout.SetPos(0, y, GetWidth(), MZM_HEIGHT_BUTTONEX*2);
m_TextAbout.SetEnable(false);
m_TextAbout.SetTextColor(RGB(255-64,255-64,255-64));
m_TextAbout.SetDrawTextFormat(DT_RIGHT);
m_TextAbout.SetTextSize(20);
CMzString sAbout;
wchar_t sa[256];
wsprintf(sa,LOADSTRING(IDS_STR_APPAUTHOR).C_Str(),L"JEMYZHANG");
sAbout = sa;
sAbout = sAbout + L"\n";
wsprintf(sa,LOADSTRING(IDS_STR_APPVERSION).C_Str(),VER_STRING,BUILD_STRING);
sAbout = sAbout + sa;
sAbout = sAbout + L"\n";
sAbout = sAbout + L"Email: [email protected]\n";
wsprintf(sa,LOADSTRING(IDS_STR_COPYRIGHT).C_Str(),2009,L"JEMYZHANG");
sAbout = sAbout + sa;
m_TextAbout.SetText(sAbout.C_Str());
AddUiWin(&m_TextAbout);
return TRUE;
}
void Ui_MainWnd::DelayShow(){
ShowModules();
dbg_printf("main: %04x\n",m_hWnd);
}
void Ui_MainWnd::AppendModule(CPluginBase *obj){
UiModuleItem *item = new UiModuleItem(obj,IDC_MODULE_BEGIN + module_cnt);
item->SetPos(30 + 110 * (module_cnt%4), 10 + 140 * (module_cnt / 4), 90, 90+25);
m_ScrollWin.AddChild(item);
item->Invalidate();
item->Update();
module_cnt ++;
}
void Ui_MainWnd::ShowModules(){
PostMessageW(MZ_MW_REQ_CHANGE_TITLE,IDS_MODULE_LOADING,(LPARAM)(MzGetInstanceHandle()));
DateTime::waitms(1);
::LoadPlugins(L"modules",L"mol",L"modules_createOjbect",
reinterpret_cast<void*>(this),&Ui_MainWnd::static_callback);
PostMessageW(MZ_MW_REQ_CHANGE_TITLE,IDS_TTL_MAIN,(LPARAM)(MzGetInstanceHandle()));
DateTime::waitms(1);
}
LRESULT Ui_MainWnd::MzDefWndProc(UINT message, WPARAM wParam, LPARAM lParam) {
return Ui_BaseWnd::MzDefWndProc(message, wParam, lParam);
}
void Ui_MainWnd::OnMzCommand(WPARAM wParam, LPARAM lParam) {
UINT_PTR id = LOWORD(wParam);
if(id >= IDC_MODULE_BEGIN && id <= IDC_MODULE_BEGIN + 16){
PLUGIN module = GetPlugin(id - IDC_MODULE_BEGIN);
//m_Title.SetText(module.pObj->GetName());
module.pObj->Show(m_hWnd);
PostMessageW(MZ_MW_REQ_CHANGE_TITLE,IDS_TTL_MAIN,(LPARAM)MzGetInstanceHandle());
}
}
| [
"jemyzhang@e7c2eee8-530d-454e-acc3-bb8019a9d48c"
]
| [
[
[
1,
117
]
]
]
|
4881da2da26d1e120a69898a9be753a6a64d6838 | 138a353006eb1376668037fcdfbafc05450aa413 | /source/ogre/OgreNewt/boost/mpl/set/set0_c.hpp | d3cf5e4c551f6a486e979263c414fd7c958870d8 | []
| no_license | sonicma7/choreopower | 107ed0a5f2eb5fa9e47378702469b77554e44746 | 1480a8f9512531665695b46dcfdde3f689888053 | refs/heads/master | 2020-05-16T20:53:11.590126 | 2009-11-18T03:10:12 | 2009-11-18T03:10:12 | 32,246,184 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 824 | hpp |
#ifndef BOOST_MPL_SET_SET0_C_HPP_INCLUDED
#define BOOST_MPL_SET_SET0_C_HPP_INCLUDED
// Copyright Aleksey Gurtovoy 2003-2004
// Copyright David Abrahams 2003-2004
//
// 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.
// $Source: /cvsroot/ogre/ogreaddons/ogrenewt/OgreNewt_Main/inc/boost/mpl/set/set0_c.hpp,v $
// $Date: 2006/04/17 23:49:48 $
// $Revision: 1.1 $
#include <boost/mpl/set/set0.hpp>
#include <boost/mpl/integral_c.hpp>
namespace boost { namespace mpl {
template< typename T > struct set0_c
: set0<>
{
typedef set0_c type;
typedef T value_type;
};
}}
#endif // BOOST_MPL_SET_SET0_C_HPP_INCLUDED
| [
"Sonicma7@0822fb10-d3c0-11de-a505-35228575a32e"
]
| [
[
[
1,
32
]
]
]
|
ae80a4ade2216fe851458ebf87242a985647330f | b73f27ba54ad98fa4314a79f2afbaee638cf13f0 | /projects/MainUI/thumbctrl.cpp | c4a06be8de94b85fbdb3ac1c2727b23224ecd084 | []
| no_license | weimingtom/httpcontentparser | 4d5ed678f2b38812e05328b01bc6b0c161690991 | 54554f163b16a7c56e8350a148b1bd29461300a0 | refs/heads/master | 2021-01-09T21:58:30.326476 | 2009-09-23T08:05:31 | 2009-09-23T08:05:31 | 48,733,304 | 3 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 17,447 | cpp | // ThumbCtrl.cpp : implementation file
//
#include "stdafx.h"
#include "ThumbCtrl.h"
#include "resource.h" // It need a icon to representate default image.
#include <deque>
#include <Gdiplus.h>
using namespace Gdiplus;
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CThreadPool
// This class used to buffer data for thread. The data type is a deque of ListNode.
// This class have two instances, one is pThreadInPool, the other is pThreadOutPool,
// Their behavir is very different. The common part is that they have basic operation
// on buffer, like Get, Insert, Delete, Clear, and they are all in critical section.
//
// The InPool maintained the whole list
// in the listview, and use m_Offset to indicate that from where begin to process.
// It will be empty only if user called clear method. The delete method is the
// synchronization with the listview, so it surly could delete one.
//
// The OutPool is different, it only maintain the items processed and was not showed.
// When the OnUpdateImage of main thread was called, it use GetNode(TRUE) to get and
// remove the node after they are shown by list.SetItem(). The delete operation will
// occured only when the item needed be delete is just in this pool.
//
// The main point of this module is the synchronization between main thread and
// additional thread. There are three critical section and two event is used just
// for this purpose. The event can ensure the operation could be trigered on time,
// and the critical section ensure that the of check event and make action will be
// simultaneously.
class CThreadPool
{
public:
struct ListNode{
INT_PTR ItemNo;
CString FileName;
INT_PTR ImageNo;
};
protected:
std::deque<struct ListNode> Queue;
CRITICAL_SECTION CriticalSection;
INT_PTR m_Offset;
INT_PTR m_Type; // 0: InPool, 1: OutPool;
public:
BOOL DeleteItem(INT_PTR nItem);
void InsertNode(INT_PTR ItemNo, CString FileName="", INT_PTR ImageNo=0);
void AddNode(INT_PTR ItemNo, INT_PTR ImageNo);
struct ListNode GetNextNode(BOOL bRemove);
void Clear();
BOOL IsEmpty() { return Queue.empty(); }
CThreadPool(INT_PTR Type)
{
m_Type = Type;
m_Offset = 0;
InitializeCriticalSection( & CriticalSection );
}
~CThreadPool()
{
DeleteCriticalSection( & CriticalSection );
}
};
// Used by In Pool.
void CThreadPool::InsertNode(INT_PTR ItemNo, CString FileName, INT_PTR ImageNo)
{
EnterCriticalSection( & CriticalSection );
//TRACE("Insert to In pool: %d, %d, %s, Size:%d\n", ItemNo, ImageNo, FileName, Queue.size() );
struct ListNode node;
node.ItemNo = ItemNo;
node.FileName = FileName;
node.ImageNo = ImageNo;
if(ItemNo > Queue.size())
ItemNo = Queue.size();
std::deque<ListNode>::iterator itor;
itor = Queue.begin() + ItemNo;
Queue.insert( itor, node );
//Queue.push_back( node );
LeaveCriticalSection( & CriticalSection );
}
// Used by Out pool
void CThreadPool::AddNode(INT_PTR ItemNo, INT_PTR ImageNo)
{
EnterCriticalSection( & CriticalSection );
//TRACE("Insert to out pool: %d, %d, Size:%d\n", ItemNo, ImageNo, Queue.size() );
struct ListNode node;
node.ItemNo = ItemNo;
node.FileName = "";
node.ImageNo = ImageNo;
Queue.push_back( node );
LeaveCriticalSection( & CriticalSection );
}
void CThreadPool::Clear()
{
EnterCriticalSection( & CriticalSection );
//TRACE( "Cleared\n" );
Queue.clear();
m_Offset = 0;
LeaveCriticalSection( & CriticalSection );
}
struct CThreadPool::ListNode CThreadPool::GetNextNode(BOOL bRemove)
{
EnterCriticalSection( & CriticalSection );
struct ListNode node;
if(Queue.size() == 0 || Queue.size() <= m_Offset)
{
node.ItemNo = -1;
}
else if(bRemove)
{
node = Queue.front();
Queue.pop_front();
}
else
{
if( m_Offset >= Queue.size() )
m_Offset = 0;
node.ItemNo = -1;
std::deque<ListNode>::iterator itor;
for(itor = Queue.begin() + m_Offset; itor < Queue.end(); itor++)
if(itor->ImageNo == 0)
{
node = *itor;
itor->ImageNo = -1;
node.ItemNo = itor-Queue.begin();
m_Offset = node.ItemNo;
break;
}
if( node.ItemNo == -1 )
{
for(itor = Queue.begin(); itor < Queue.end(); itor++)
{
if(itor->ImageNo == 0)
{
node = *itor;
itor->ImageNo = -1;
node.ItemNo = itor-Queue.begin();
m_Offset = node.ItemNo;
break;
}
}
}
}
//TRACE("Get node from pool: %d, %d, %s, Size:%d, Off:%d,%d\n", node.ItemNo, node.ImageNo, node.FileName, Queue.size(), m_Offset, bRemove);
LeaveCriticalSection( & CriticalSection );
return node;
}
BOOL CThreadPool::DeleteItem(INT_PTR nItem)
{
ASSERT( m_Type == 0 || m_Type == 1);
EnterCriticalSection( & CriticalSection );
BOOL found = FALSE;
std::deque<ListNode>::iterator itor;
if( m_Type == 1 ) // Out Pool
{
for(itor=Queue.begin(); itor<Queue.end(); itor++)
{
if(itor->ItemNo == nItem)
{
found = TRUE;
Queue.erase(itor);
}
else if(itor->ItemNo > nItem)
{
itor->ItemNo --;
}
}
}
else // In Pool
{
ASSERT( nItem < Queue.size() );
if( nItem < Queue.size() )
{
itor = Queue.begin() + nItem;
Queue.erase(itor);
if( nItem <= m_Offset)
m_Offset --;
found = TRUE;
}
}
LeaveCriticalSection( & CriticalSection );
return found;
}
/////////////////////////////////////////////////////////////////////////////
// CThumbCtrl
IMPLEMENT_DYNCREATE(CThumbCtrl, CListCtrl)
CThumbCtrl::CThumbCtrl(INT_PTR ThumbWidth, INT_PTR ThumbHeight)
{
m_pThread = NULL;
m_ThumbWidth = ThumbWidth;
m_ThumbHeight = ThumbHeight;
m_Margin = 2;
pThreadInPool = new CThreadPool(0); // 0 Specified In Pool
pThreadOutPool = new CThreadPool(1); // 1 Specified Out Pool
if(pThreadInPool == NULL || pThreadOutPool == NULL){
MessageBox(" Thread buffer alloc failed.", "Error", MB_OK | MB_ICONSTOP );
return;
}
if((m_ExitEvent = CreateEvent(NULL, TRUE, TRUE, NULL)) == NULL){
MessageBox(" Create event failed\n", "Error", MB_OK | MB_ICONSTOP );
return;
}
if((m_StopEvent = CreateEvent(NULL, FALSE, FALSE, NULL)) == NULL){
MessageBox(" Create event failed\n", "Error", MB_OK | MB_ICONSTOP );
return;
}
InitializeCriticalSection( & m_CSSetStop );
InitializeCriticalSection( & m_CSExitCheck );
InitializeCriticalSection( & m_CSNeitherInBothPoolSection );
}
CThumbCtrl::~CThumbCtrl()
{
CloseHandle( m_ExitEvent );
CloseHandle( m_StopEvent );
delete pThreadInPool;
delete pThreadOutPool;
DeleteCriticalSection( & m_CSSetStop );
DeleteCriticalSection( & m_CSExitCheck );
DeleteCriticalSection( & m_CSNeitherInBothPoolSection );
}
BEGIN_MESSAGE_MAP(CThumbCtrl, CListCtrl)
//{{AFX_MSG_MAP(CThumbCtrl)
ON_WM_CREATE()
ON_NOTIFY_REFLECT(LVN_DELETEITEM, OnDeleteItem)
ON_NOTIFY_REFLECT(LVN_DELETEALLITEMS, OnDeleteAllItems)
ON_WM_DESTROY()
//}}AFX_MSG_MAP
ON_MESSAGE( WM_UPDATE_IMAGEDATA, OnUpdateImageData )
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CThumbCtrl diagnostics
#ifdef _DEBUG
void CThumbCtrl::AssertValid() const
{
CListCtrl::AssertValid();
}
void CThumbCtrl::Dump(CDumpContext& dc) const
{
CListCtrl::Dump(dc);
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CThumbCtrl message handlers
INT_PTR CThumbCtrl::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CListCtrl::OnCreate(lpCreateStruct) == -1)
return -1;
// TODO: Add your specialized creation code here
ModifyStyle(LVS_TYPEMASK, LVS_ICON | LVS_AUTOARRANGE);
CClientDC dc(this);
CDC memdc;
memdc.CreateCompatibleDC(&dc);
CBrush bkBrush(RGB(192, 192, 192)), *pOldBrush;
CBitmap Bmp, * pOldBmp;
Bmp.CreateCompatibleBitmap(&dc, m_ThumbWidth, m_ThumbHeight);
pOldBmp = memdc.SelectObject(&Bmp);
pOldBrush = memdc.SelectObject(&bkBrush);
memdc.PatBlt(0,0,m_ThumbWidth,m_ThumbHeight, PATCOPY);
memdc.Draw3dRect(0,0,m_ThumbWidth, m_ThumbHeight, RGB(222, 222, 222), RGB(128, 128, 128));
memdc.DrawIcon((m_ThumbWidth-32)/2, (m_ThumbHeight-32)/2, AfxGetApp()->LoadIcon(IDR_MAINFRAME));
memdc.SelectObject(pOldBmp);
m_ImageList.Create(m_ThumbWidth, m_ThumbHeight, ILC_COLOR24 | ILC_MASK, 20, 20);
m_ImageList.Add(&Bmp, RGB(0,0,0));
m_BackupImageList.Create(&m_ImageList);
SetImageList(&m_ImageList, LVSIL_NORMAL);
ListView_SetIconSpacing( m_hWnd, m_ThumbWidth + 10, m_ThumbHeight + 30 );
return 0;
}
// I want transform InsertItem into OnInsertItem in order to provide a united interface
// with CListCtrl, but when the message occured, I can't get item from list ctrl.
/*void CThumbCtrl::OnInsertItem(NMHDR* pNMHDR, LRESULT* pResult)
{
NM_LISTVIEW* pNMListView = (NM_LISTVIEW*)pNMHDR;
// TODO: Add your control notification handler code here
CString FileName, PathName;
LVITEM item;
item.iItem = pNMListView->iItem;
item.iSubItem = 0;
item.mask = LVIF_TEXT;
GetListCtrl().GetItem(&item);
PathName = item.pszText;
FileName = PathName.Right(PathName.GetLength() - PathName.ReverseFind('\\') - 1);
item.iImage = 0;
item.pszText = FileName.GetBuffer(FileName.GetLength() + 1);
GetListCtrl().SetItem(&item);
FileName.ReleaseBuffer();
*pResult = 0;
}*/
INT_PTR CThumbCtrl::InsertItem(INT_PTR ItemNo, LPCTSTR lpszFileName)
{
CString PathName, FileName;
PathName = lpszFileName;
FileName = PathName.Right(PathName.GetLength() - PathName.ReverseFind('\\') - 1);
ItemNo = CListCtrl::InsertItem(ItemNo,FileName, 0); //Default image index.
pThreadInPool->InsertNode(ItemNo, PathName); // Put into pool to wait for processing.
EnterCriticalSection( & m_CSExitCheck );
if(WaitForSingleObject(m_ExitEvent, 0) == WAIT_OBJECT_0)
{
tagParameter * Parameter = new tagParameter;
Parameter->hListView = this->m_hWnd;
Parameter->hImageList = m_ImageList.m_hImageList;
Parameter->Parent = this;
m_pThread = AfxBeginThread(ImageRendering, Parameter, THREAD_PRIORITY_BELOW_NORMAL, 0, 0, NULL);
ResetEvent( m_ExitEvent ); // Indicate the thread begin.
}
LeaveCriticalSection( & m_CSExitCheck );
return ItemNo;
}
void CThumbCtrl::OnDeleteItem(NMHDR* pNMHDR, LRESULT* pResult)
{
NM_LISTVIEW* pNMListView = (NM_LISTVIEW*)pNMHDR;
// TODO: Add your control notification handler code here
LVITEM item;
item.iItem = pNMListView->iItem;
item.iSubItem = 0;
item.mask = LVIF_IMAGE;
ASSERT(item.iItem >= 0);
GetItem(&item);
EnterCriticalSection( & m_CSNeitherInBothPoolSection );
pThreadInPool->DeleteItem(item.iItem);
pThreadOutPool->DeleteItem(item.iItem);
LeaveCriticalSection( & m_CSNeitherInBothPoolSection );
*pResult = 0;
}
void CThumbCtrl::OnDeleteAllItems(NMHDR* pNMHDR, LRESULT* pResult)
{
NM_LISTVIEW* pNMListView = (NM_LISTVIEW*)pNMHDR;
// TODO: Add your control notification handler code here
pThreadInPool->Clear();
KillRenderingThread();
pThreadOutPool->Clear();
m_ImageList.DeleteImageList();
m_ImageList.Create(&m_BackupImageList);
// Do not sent OnDeleteItem when delete all.
*pResult = TRUE;
}
void CThumbCtrl::OnDestroy()
{
KillRenderingThread();
if(m_pThread != NULL)
WaitForSingleObject( m_pThread->m_hThread, INFINITE );
CListCtrl::OnDestroy();
// TODO: Add your message handler code here
}
//--------------------------------------------------------------------------------------
// Thread process part.
//--------------------------------------------------------------------------------------
UINT CThumbCtrl::ImageRendering(LPVOID Param)
{
struct tagParameter * pParameter = (struct tagParameter *)Param;
CThumbCtrl *Parent = pParameter->Parent;
CListCtrl *list = (CListCtrl *)CWnd::FromHandle(pParameter->hListView);
CImageList *ImageList = (CImageList *)CImageList::FromHandle(pParameter->hImageList);
INT_PTR Margin = Parent->m_Margin;
INT_PTR ThumbWidth = Parent->m_ThumbWidth;
INT_PTR ThumbHeight = Parent->m_ThumbHeight;
delete pParameter;
CString PathName, FileName;
BSTR bstrPathName;
INT_PTR imgNo, ItemNo;
Image * img, * Thumb;
Rect ActRect;
CBitmap Bmp, * pOldBmp;
CBrush bkBrush(RGB(192,192,192)), * pOldBrush;
CClientDC cdc(list);
CDC memdc;
memdc.CreateCompatibleDC(&cdc);
ResetEvent( Parent->m_ExitEvent ); // Indicate the thread begin.
TRACE0("Begin of Thumbnail thread\n");
EnterCriticalSection( & Parent->m_CSExitCheck );
EnterCriticalSection( & Parent->m_CSNeitherInBothPoolSection );
struct CThreadPool::ListNode node = Parent->pThreadInPool->GetNextNode(FALSE);
while( node.ItemNo != -1 ) // if InPool is not empty.
{
if(WaitForSingleObject(Parent->m_StopEvent, 0) == WAIT_OBJECT_0)
{
TRACE0( " Was stoped\n" );
break;
}
LeaveCriticalSection( & Parent->m_CSExitCheck );
ItemNo = node.ItemNo;
PathName = node.FileName;
bstrPathName = PathName.AllocSysString();
if(bstrPathName == NULL){
AfxMessageBox("Alloc sys string failed.", MB_OK | MB_ICONSTOP );
return 0;
}
img = Image::FromFile(bstrPathName);
::SysFreeString( bstrPathName );
if( NULL == img ){ // Need more consideration.
AfxMessageBox( "Please initialize the Gdiplus." );
return 0;
}
if(img->GetLastStatus() != Ok)
{
CString errmsg;
errmsg.Format("Can't open file %s,\r\n check files please.", PathName);
AfxMessageBox(errmsg, MB_OK | MB_ICONEXCLAMATION);
delete img;
LeaveCriticalSection( & Parent->m_CSNeitherInBothPoolSection );
}
else
{
Thumb = img->GetThumbnailImage(ThumbWidth - 2*Margin, ThumbHeight - 2*Margin);
ASSERT(Thumb->GetLastStatus() == Ok);
VERIFY(Bmp.CreateCompatibleBitmap(&cdc, ThumbWidth, ThumbHeight) != 0);
pOldBmp = memdc.SelectObject(&Bmp);
pOldBrush = memdc.SelectObject(&bkBrush);
memdc.PatBlt(0,0,ThumbWidth,ThumbHeight, PATCOPY);
memdc.Draw3dRect(0,0,ThumbWidth, ThumbHeight, RGB(222, 222, 222), RGB(128, 128, 128));
Graphics* graphics;
graphics = Graphics::FromHDC(memdc.m_hDC);
ASSERT( img->GetWidth() != 0 && img->GetHeight() != 0 );
double XRate = (double)img->GetWidth() / (ThumbWidth - 2*Margin);
double YRate = (double)img->GetHeight() / (ThumbHeight - 2*Margin);
if(XRate > YRate)
{
ActRect.Width = ThumbWidth - 2*Margin;
ActRect.Height = img->GetHeight() / XRate;
ActRect.X = Margin;
ActRect.Y = (ThumbHeight - 2*Margin - ActRect.Height) / 2 + Margin;
}
else
{
ActRect.Height = ThumbHeight - 2*Margin;
ActRect.Width = img->GetWidth() / YRate;
ActRect.X = (ThumbWidth - 2*Margin - ActRect.Width) / 2 + Margin;
ActRect.Y = Margin;
}
graphics->DrawImage(Thumb, ActRect);
delete graphics;
delete Thumb;
delete img;
memdc.SelectObject(pOldBrush);
memdc.SelectObject(pOldBmp);
imgNo = ImageList->Add(&Bmp, RGB(255,255,255));
Bmp.DeleteObject();
if(imgNo == -1){
AfxMessageBox( "Can't add image into the Imaglist.", MB_OK | MB_ICONSTOP );
return 0;
}
Parent->pThreadOutPool->AddNode( ItemNo, imgNo);
LeaveCriticalSection( & Parent->m_CSNeitherInBothPoolSection );
list->PostMessage(WM_UPDATE_IMAGEDATA, 0, 0);
}
EnterCriticalSection( & Parent->m_CSExitCheck );
EnterCriticalSection( & Parent->m_CSNeitherInBothPoolSection );
node = Parent->pThreadInPool->GetNextNode(FALSE);
}
LeaveCriticalSection( & Parent->m_CSNeitherInBothPoolSection );
EnterCriticalSection( & Parent->m_CSSetStop );
SetEvent(Parent->m_ExitEvent);
WaitForSingleObject(Parent->m_StopEvent, 0);
LeaveCriticalSection( & Parent->m_CSSetStop );
LeaveCriticalSection( & Parent->m_CSExitCheck );
TRACE0("End of Thumbnail thread\n");
return 1;
}
void CThumbCtrl::KillRenderingThread()
{
EnterCriticalSection( & m_CSSetStop );
if(WaitForSingleObject(m_ExitEvent, 0) != WAIT_OBJECT_0)
{
SetEvent(m_StopEvent);
TRACE0("SetEvent of stop\n");
LeaveCriticalSection( & m_CSSetStop );
WaitForSingleObject(m_ExitEvent, INFINITE);
TRACE0(" The thread is already dead.\n");
}
else
LeaveCriticalSection( & m_CSSetStop );
}
// This message handler used to update the image to the list view. This work
// was assigned to thread, but it may lead to deadlock when killRenderingThread
// because main thread will block to wait thread exit and the thread is calling
// SendMessage to send setitem message to list view, and the main thread is
// waiting and will not answer the message. So dead locked.
// So we add a OutPool, and thread process the data and put it to the OutPool and
// Post a user message to main thread, and used this function to handle that message
// and finish setitem function and clear the OutPool.
LRESULT CThumbCtrl::OnUpdateImageData(WPARAM, LPARAM)
{
CThreadPool::ListNode node;
//CListCtrl & list = GetListCtrl();
node = pThreadOutPool->GetNextNode(TRUE);
INT_PTR res;
while( node.ItemNo != -1 )
{
res = SetItem(node.ItemNo, 0, LVIF_IMAGE, NULL, node.ImageNo, 0, 0, 0);
ASSERT( res != 0 );
node = pThreadOutPool->GetNextNode(TRUE);
}
return 0;
}
| [
"[email protected]"
]
| [
[
[
1,
588
]
]
]
|
188d0bdbdb085215a505861d9782c5090ae70ced | be2e23022d2eadb59a3ac3932180a1d9c9dee9c2 | /NpcServer/EncryptClient.h | 110d79dcd97c7e3ed0a4b88e86c8183248c39682 | []
| no_license | cronoszeu/revresyksgpr | 78fa60d375718ef789042c452cca1c77c8fa098e | 5a8f637e78f7d9e3e52acdd7abee63404de27e78 | refs/heads/master | 2020-04-16T17:33:10.793895 | 2010-06-16T12:52:45 | 2010-06-16T12:52:45 | 35,539,807 | 0 | 2 | null | null | null | null | GB18030 | C++ | false | false | 4,216 | h | ////////////////////////////////////////////////////////////////////////////////////////////////////
// 客户端SOCKET用加密模板
////////////////////////////////////////////////////////////////////////////////////////////////////
// 仙剑修, 2001.10.26
// 修改为模板:2001.12.11
#ifndef ENCRYPTCLIENT_H
#define ENCRYPTCLIENT_H
#include <stdlib.h>
//#include "Profile.h"
////////////////////////////////////////////////////////////////////////////////////////////////////
//#define LOGCATCH LOGERROR
//@@@ #define LOGCATCH LogSave
////////////////////////////////////////////////////////////////////////////////////////////////////
template <unsigned char a1, unsigned char b1, unsigned char c1, unsigned char fst1,
unsigned char a2, unsigned char b2, unsigned char c2, unsigned char fst2>
class CEncryptClient
{
public:
CEncryptClient(){ Init(); }
//default CEncryptClient(CEncryptClient & cEncrypt);
public:
void Init() { m_nPos1 = m_nPos2 = 0; }
void Encrypt(unsigned char * bufMsg, int nLen, bool bMove = true);
void ChangeCode(DWORD dwData);
protected:
int m_nPos1;
int m_nPos2;
protected:
class CEncryptCode
{
public:
CEncryptCode()
{
try{
//* 与下面ELSE算法相同,只为加强复杂性:)
unsigned char nCode = fst1;
int i;
for(i = 0; i < 256; i++)
{
m_bufEncrypt1[i] = nCode;
int nTemp = (a1*nCode) % 256;
nCode = (c1 + nTemp*nCode + b1*nCode) % 256;
}
//@@@ assert(nCode == fst1);
nCode = fst2;
for( i = 0; i < 256; i++)
{
m_bufEncrypt2[i] = nCode;
int nTemp = a2*nCode;
nCode = ((b2 + nTemp)*nCode + c2) & 0xFF;
}
//@@@ assert(nCode == fst2);
//*/
/*else
unsigned char nCode = fst1;
for(int i = 0; i < 256; i++)
{
m_bufEncrypt1[i] = nCode;
// printf("%02X ", nCode); //???
nCode = (a1*nCode*nCode + b1*nCode + c1) % 256;
}
// printf("[%02X]\n", nCode); //???
assert(nCode == fst1);
nCode = fst2;
for( i = 0; i < 256; i++)
{
m_bufEncrypt2[i] = nCode;
nCode = (a2*nCode*nCode + b2*nCode + c2) % 256;
}
assert(nCode == fst2);
//*/
}catch(...){ /*@@@ LOGCATCH("Encrypt init fail."); exit(3);*/ }
}
// protected:
unsigned char m_bufEncrypt1[256];
unsigned char m_bufEncrypt2[256];
}m_cGlobalEncrypt; //??? 应改成静态共享的成员对象,以节约资源
};
//template <unsigned char a1, unsigned char b1, unsigned char c1, unsigned char fst1,
// unsigned char a2, unsigned char b2, unsigned char c2, unsigned char fst2>
//CEncryptClient<a1, b1, c1, fst1, a2, b2, c2, fst2>::CEncryptCode CEncryptClient<a1, b1, c1, fst1, a2, b2, c2, fst2>::m_cGlobalEncrypt;
template <unsigned char a1, unsigned char b1, unsigned char c1, unsigned char fst1,
unsigned char a2, unsigned char b2, unsigned char c2, unsigned char fst2>
inline void CEncryptClient<a1, b1, c1, fst1, a2, b2, c2, fst2>::Encrypt(unsigned char * bufMsg, int nLen, bool bMove /*= true*/)
{
try{
int nOldPos1 = m_nPos1;
int nOldPos2 = m_nPos2;
for(int i = 0; i < nLen; i++)
{
bufMsg[i] ^= m_cGlobalEncrypt.m_bufEncrypt1[m_nPos1];
bufMsg[i] ^= m_cGlobalEncrypt.m_bufEncrypt2[m_nPos2];
if(++m_nPos1 >= 256)
{
m_nPos1 = 0;
if(++m_nPos2 >= 256)
m_nPos2 = 0;
}
//@@@ assert(m_nPos1 >=0 && m_nPos1 < 256);
//@@@ assert(m_nPos2 >=0 && m_nPos2 < 256);
}
if(!bMove)
{
// 恢复指针
m_nPos1 = nOldPos1;
m_nPos2 = nOldPos2;
}
}catch(...){ /*@@@ LOGCATCH("Encrypt fail."); exit(3);*/ }
}
template <unsigned char a1, unsigned char b1, unsigned char c1, unsigned char fst1,
unsigned char a2, unsigned char b2, unsigned char c2, unsigned char fst2>
inline void CEncryptClient<a1, b1, c1, fst1, a2, b2, c2, fst2>::ChangeCode(DWORD dwData)
{
try{
DWORD dwData2 = dwData*dwData;
for(int i = 0; i < 256; i += 4)
{
*(DWORD*)(&m_cGlobalEncrypt.m_bufEncrypt1[i]) ^= dwData;
*(DWORD*)(&m_cGlobalEncrypt.m_bufEncrypt2[i]) ^= dwData2;
}
}catch(...){ /*LOGCATCH("ChangeCode fail.");*/ }
}
#endif // ENCRYPTCLIENT_H
| [
"rpgsky.com@cc92e6ba-efcf-11de-bf31-4dec8810c1c1"
]
| [
[
[
1,
137
]
]
]
|
98ff33e8744d4f02f5b9845a127c0c961d422e69 | 1c9f99b2b2e3835038aba7ec0abc3a228e24a558 | /Projects/elastix/elastix_sources_v4/src/Common/xout/xoutcell.hxx | 7c941e2adb753a8cdbd45e70e0d2ddd893b6c023 | []
| no_license | mijc/Diploma | 95fa1b04801ba9afb6493b24b53383d0fbd00b33 | bae131ed74f1b344b219c0ffe0fffcd90306aeb8 | refs/heads/master | 2021-01-18T13:57:42.223466 | 2011-02-15T14:19:49 | 2011-02-15T14:19:49 | 1,369,569 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,306 | hxx | /*======================================================================
This file is part of the elastix software.
Copyright (c) University Medical Center Utrecht. All rights reserved.
See src/CopyrightElastix.txt or http://elastix.isi.uu.nl/legal.php for
details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notices for more information.
======================================================================*/
#ifndef __xoutcell_hxx
#define __xoutcell_hxx
#include "xoutcell.h"
namespace xoutlibrary
{
using namespace std;
/**
* ************************ Constructor *************************
*/
template< class charT, class traits >
xoutcell<charT, traits>::xoutcell()
{
this->AddTargetCell( "InternalBuffer", &(this->m_InternalBuffer) );
} // end Constructor
/**
* ********************* Destructor *****************************
*/
template< class charT, class traits >
xoutcell<charT, traits>::~xoutcell()
{
//nothing
} // end Destructor
/**
* ******************** WriteBufferedData ***********************
*
* The buffered data is sent to the outputs.
*/
template< class charT, class traits >
void xoutcell<charT, traits>::WriteBufferedData(void)
{
/** Make sure all data is written to the string */
this->m_InternalBuffer << flush;
const std::string & strbuf = this->m_InternalBuffer.str();
const char * charbuf = strbuf.c_str();
/** Send the string to the outputs */
for ( CStreamMapIteratorType cit = this->m_COutputs.begin();
cit != this->m_COutputs.end(); ++cit )
{
*(cit->second) << charbuf << flush;
}
/** Send the string to the outputs */
for ( XStreamMapIteratorType xit = this->m_XOutputs.begin();
xit != this->m_XOutputs.end(); ++xit )
{
*(xit->second) << charbuf;
xit->second->WriteBufferedData();
}
/** Empty the internal buffer */
this->m_InternalBuffer.str( string("") );
} // end WriteBufferedData
} // end namespace xoutlibrary
#endif // end #ifndef __xoutcell_hxx
| [
"[email protected]"
]
| [
[
[
1,
90
]
]
]
|
b4ada2a9998e1a9841df3713a98569efc78471cf | a79201edd21df9cd1a5cd2e28e4bd41c925bfa93 | /vps/include/net/TCPNetwork.h | 4556c995f9d39275d323a85cfd1535ecff17ab53 | []
| no_license | BackupTheBerlios/c--compiler | 122667d012c54e3cfab1a78ac1d6654117058906 | 9163037e985d07823dc2bef25997e14d4968500a | refs/heads/master | 2021-01-23T12:05:29.527743 | 2004-12-11T11:44:48 | 2004-12-11T11:44:48 | 40,076,510 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,261 | h | #ifndef UDPNETWORK_H
#define UDPNETWORK_H
#include "net/IPNetwork.h"
#include <sys/time.h>
#include <iostream>
using namespace std;
/**
* The TcpNetwork Class will be used to communicate through the network.
*
* every message to a server or to a client shall be send with the help of this class
*/
class TCPNetwork : IPNetwork {
public:
/**
* Create a network object with a specified port. This is necessary for the server so that it can
* offer a service.
*
* @param port is the port that the server will be bound to
*/
TCPNetwork(short port);
/**
* Create a network object. A client does not need to specify a port.
*/
TCPNetwork();
/**
* Every time a client wants to communicate to the server it has to do a request. It sends its message
* with the command that shall be executed and waits for the answer of the server.
*
* @param server to whom the connection should be done
* @param req is the buffer that will be send through the network
* @param reqlen is the length of the buffer
* @param res is the buffer with the answer of the server
* @param reslen is the length of the buffer "res"
* @param timeout is the time (in seconds) that we wait for an answer
* @return the length of the received message
*/
ssize_t request(const Server& server, void* req, size_t reqlen, void* res, size_t reslen, int timeout=5);
/**
* Wait the whole time for a message that arrives at a specified port.
*
* @param client is the information of the client that sent a request
* @param req is the buffer that will be send through the network
* @param reqlen is the length of the buffer
* @return the length of the received message
*/
ssize_t receive(Client& client, void* req, size_t reqlen);
/**
* Send a message to the client from that we received a request.
*
* @param client is the information of the client that has been sent a request
* @param res is the buffer that will be send through the network
* @param reslen is the length of the buffer
* @return the length of the message that was sent
*/
ssize_t reply(const Client& client, void* res, size_t reslen);
timeval to;
int lastfd;
int clientfd;
};
#endif
| [
"tobi1024",
"stieli"
]
| [
[
[
1,
21
],
[
23,
24
],
[
26,
26
],
[
28,
29
],
[
40,
40
],
[
42,
43
],
[
50,
50
],
[
52,
53
],
[
60,
60
],
[
62,
62
],
[
66,
69
]
],
[
[
22,
22
],
[
25,
25
],
[
27,
27
],
[
30,
39
],
[
41,
41
],
[
44,
49
],
[
51,
51
],
[
54,
59
],
[
61,
61
],
[
63,
65
]
]
]
|
1edcce8f34a28f7466765df2c6abecdcb864ea90 | 8342f87cc7e048aa812910975c68babc6fb6c5d8 | /client/Game2/Control/ObserverActions.cpp | d38b69759c3251464077cd4c0463a4a7279eff99 | []
| no_license | espes/hoverrace | 1955c00961af4bb4f5c846f20e65ec9312719c08 | 7d5fd39ba688e2c537f35f7c723dedced983a98c | refs/heads/master | 2021-01-23T13:23:03.710443 | 2010-12-19T22:26:12 | 2010-12-19T22:26:12 | 2,005,364 | 0 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 1,679 | cpp | // ObserverActions.cpp
// A collection of classes implementing the ObserverAction template class
// (just has to implement Perform() and a constructor). These are all
// actions to be performed when the user presses a control key.
//
// Copyright (c) 2010, Ryan Curtin
//
// Licensed under GrokkSoft HoverRace SourceCode License v1.0(the "License");
// you may not use this file except in compliance with the License.
//
// A copy of the license should have been attached to the package from which
// you have taken this file. If you can not find the license you can not use
// this file.
//
//
// The author makes no representations about the suitability of
// this software for any purpose. It is provided "as is" "AS IS",
// 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.
//
#include "StdAfx.h"
#include "ObserverActions.h"
using namespace HoverRace::Client::Control;
using HoverRace::Client::Observer;
void ObserverAction::SetObservers(Observer** observers, int nObservers)
{
this->observers = observers;
this->nObservers = nObservers;
}
void ObserverTiltAction::operator()(int value)
{
if(value > 0) {
for(int i = 0; i < nObservers; i++)
observers[i]->Scroll(tiltIncrement);
}
}
void ObserverZoomAction::operator()(int value)
{
if(value > 0) {
for(int i = 0; i < nObservers; i++)
observers[i]->Zoom(zoomIncrement);
}
}
void ObserverResetAction::operator()(int value)
{
if(value > 0) {
for(int i = 0; i < nObservers; i++)
observers[i]->Home();
}
} | [
"ryan@7d5085ce-8879-48fc-b0cc-67565f2357fd"
]
| [
[
[
1,
60
]
]
]
|
4cd05e95e7812f9f2bea3ac5c1d2f85e35b18f68 | b22c254d7670522ec2caa61c998f8741b1da9388 | /dependencies/OpenSceneGraph/include/osg/Texture2D | b843497a92e3a5f395b1e77d25f2edaa4184dc9f | []
| no_license | ldaehler/lbanet | 341ddc4b62ef2df0a167caff46c2075fdfc85f5c | ecb54fc6fd691f1be3bae03681e355a225f92418 | refs/heads/master | 2021-01-23T13:17:19.963262 | 2011-03-22T21:49:52 | 2011-03-22T21:49:52 | 39,529,945 | 0 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 5,990 | /* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield
*
* This library is open source and may be redistributed and/or modified under
* the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
* (at your option) any later version. The full license is in LICENSE file
* included with this distribution, and on the openscenegraph.org website.
*
* 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
* OpenSceneGraph Public License for more details.
*/
#ifndef OSG_TEXTURE2D
#define OSG_TEXTURE2D 1
#include <osg/Texture>
namespace osg {
/** Encapsulates OpenGl 2D texture functionality. Doesn't support cube maps,
* so ignore \a face parameters.
*/
class OSG_EXPORT Texture2D : public Texture
{
public :
Texture2D();
Texture2D(Image* image);
/** Copy constructor using CopyOp to manage deep vs shallow copy. */
Texture2D(const Texture2D& text,const CopyOp& copyop=CopyOp::SHALLOW_COPY);
META_StateAttribute(osg, Texture2D,TEXTURE);
/** Return -1 if *this < *rhs, 0 if *this==*rhs, 1 if *this>*rhs. */
virtual int compare(const StateAttribute& rhs) const;
virtual GLenum getTextureTarget() const { return GL_TEXTURE_2D; }
/** Sets the texture image. */
void setImage(Image* image);
/** Gets the texture image. */
Image* getImage() { return _image.get(); }
/** Gets the const texture image. */
inline const Image* getImage() const { return _image.get(); }
inline unsigned int& getModifiedCount(unsigned int contextID) const
{
// get the modified count for the current contextID.
return _modifiedCount[contextID];
}
/** Sets the texture image, ignoring face. */
virtual void setImage(unsigned int, Image* image) { setImage(image); }
/** Gets the texture image, ignoring face. */
virtual Image* getImage(unsigned int) { return _image.get(); }
/** Gets the const texture image, ignoring face. */
virtual const Image* getImage(unsigned int) const { return _image.get(); }
/** Gets the number of images that can be assigned to the Texture. */
virtual unsigned int getNumImages() const { return 1; }
/** Sets the texture width and height. If width or height are zero,
* calculate the respective value from the source image size. */
inline void setTextureSize(int width, int height) const
{
_textureWidth = width;
_textureHeight = height;
}
void setTextureWidth(int width) { _textureWidth=width; }
void setTextureHeight(int height) { _textureHeight=height; }
virtual int getTextureWidth() const { return _textureWidth; }
virtual int getTextureHeight() const { return _textureHeight; }
virtual int getTextureDepth() const { return 1; }
class OSG_EXPORT SubloadCallback : public Referenced
{
public:
virtual void load(const Texture2D& texture,State& state) const = 0;
virtual void subload(const Texture2D& texture,State& state) const = 0;
};
void setSubloadCallback(SubloadCallback* cb) { _subloadCallback = cb;; }
SubloadCallback* getSubloadCallback() { return _subloadCallback.get(); }
const SubloadCallback* getSubloadCallback() const { return _subloadCallback.get(); }
/** Helper function. Sets the number of mipmap levels created for this
* texture. Should only be called within an osg::Texture::apply(), or
* during a custom OpenGL texture load. */
void setNumMipmapLevels(unsigned int num) const { _numMipmapLevels=num; }
/** Gets the number of mipmap levels created. */
unsigned int getNumMipmapLevels() const { return _numMipmapLevels; }
/** Copies pixels into a 2D texture image, as per glCopyTexImage2D.
* Creates an OpenGL texture object from the current OpenGL background
* framebuffer contents at position \a x, \a y with width \a width and
* height \a height. \a width and \a height must be a power of two. */
void copyTexImage2D(State& state, int x, int y, int width, int height );
/** Copies a two-dimensional texture subimage, as per
* glCopyTexSubImage2D. Updates a portion of an existing OpenGL
* texture object from the current OpenGL background framebuffer
* contents at position \a x, \a y with width \a width and height
* \a height. Loads framebuffer data into the texture using offsets
* \a xoffset and \a yoffset. \a width and \a height must be powers
* of two. */
void copyTexSubImage2D(State& state, int xoffset, int yoffset, int x, int y, int width, int height );
/** Bind the texture object. If the texture object hasn't already been
* compiled, create the texture mipmap levels. */
virtual void apply(State& state) const;
protected :
virtual ~Texture2D();
virtual void computeInternalFormat() const;
void allocateMipmap(State& state) const;
ref_ptr<Image> _image;
/** Subloaded images can have different texture and image sizes. */
mutable GLsizei _textureWidth, _textureHeight;
/** Number of mipmap levels created. */
mutable GLsizei _numMipmapLevels;
ref_ptr<SubloadCallback> _subloadCallback;
typedef buffered_value<unsigned int> ImageModifiedCount;
mutable ImageModifiedCount _modifiedCount;
};
}
#endif
| [
"vdelage@3806491c-8dad-11de-9a8c-6d5b7d1e4d13"
]
| [
[
[
1,
155
]
]
]
|
|
9d5a06c220b806f8f9aeed6c648ac85677d3a39a | b6743b5bead9dbf4cd94fd7867dee1bf65deeec2 | /courses/eecs487/pa/pa4-animation/image_io.h | 22e88b9f4be63506e8ec33cec7593f400c2aef44 | []
| no_license | fporrata/fisher-code | 5d6541c7bcc3c8bcbba8f7ff6f3829efd6133f2f | 683074283e6b37789adc7ff2b6cd4ddd40ee41b7 | refs/heads/master | 2021-01-21T12:36:50.679610 | 2010-04-15T14:34:00 | 2010-04-15T14:34:00 | 38,948,199 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 397 | h | #ifndef __IMAGE_IO_H
#define __IMAGE_IO_H
#include "image.h"
class ImageIO {
public:
enum ImageFormatEnum {
FORMAT_NONE = -1,
FORMAT_PNG = 0,
FORMAT_JPEG = 1
};
static Image* LoadJPEG(const char* filename);
static Image* LoadPNG(const char* filename);
static ImageFormatEnum recognize_image_format(const char* filename);
};
#endif // __IMAGE_IO_H
| [
"yufu.fisher@949dbb96-0d51-11df-8f49-cf7c468afe83"
]
| [
[
[
1,
21
]
]
]
|
00275a7b0793ad3fdf50b88d68593db30face390 | aecc6d0ee5b767cc9c6ad2b22718f55e43abfe53 | /Aesir/Attic/BasicCanvas.h | df79db800ca9a2f8f15121f72a150f9fc6db2ea9 | []
| no_license | yeah-dude/aesirtk | 72ab3427535ee6c4535f4a7a16b5bd580309a2cd | fe43bedb45cdfb894935411b84c55197601a5702 | refs/heads/master | 2021-01-18T11:43:09.961319 | 2007-06-27T21:42:10 | 2007-06-27T21:42:10 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 523 | h | #pragma once
#include <wx/glcanvas.h>
class BasicCanvas : public wxGLCanvas {
public:
BasicCanvas(wxWindow *parent);
// HACK: This is a pretty shitty way to do it...
BasicCanvas(wxWindow *parent, bool main);
// Derived classes override this to implement custom drawing
virtual void Render() { }
private:
wxScrollBar *horizontalScroll, *verticalScroll;
void Resize(int width, int height);
void Setup();
void OnSize(wxSizeEvent &event);
void OnPaint(wxPaintEvent &event);
DECLARE_EVENT_TABLE()
}; | [
"MisterPhyrePhox@6418936e-2d2e-0410-bd97-81d43f9d527b"
]
| [
[
[
1,
18
]
]
]
|
111d5954e005efd25a76655bee51b50ac3e0ec5d | 2fe1bab56e0e08499b167f2b4a293e2f16c951a0 | /Sim65App.h | 43cfe42fe89773002f17874164ec37119c82f0e9 | []
| no_license | g6ujj/sim6502 | 24096d523634d8be8717f5e32c56568c04bd33df | 9d036bb27815c73c6a52d0577e83422ea43b4b8d | refs/heads/master | 2021-01-01T17:28:38.007286 | 2011-11-26T22:51:07 | 2011-11-26T22:51:07 | 2,858,152 | 0 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 527 | h | /***************************************************************
* Name: Sim65App.h
* Purpose: Defines Application Class
* Author: Neil Stoker ([email protected])
* Created: 2011-11-26
* Copyright: Neil Stoker (https://sites.google.com/site/g6ujjcode/)
* License:
**************************************************************/
#ifndef SIM65APP_H
#define SIM65APP_H
#include <wx/app.h>
class Sim65App : public wxApp
{
public:
virtual bool OnInit();
};
#endif // SIM65APP_H
| [
"[email protected]"
]
| [
[
[
1,
21
]
]
]
|
b3af2b9f3c0a14701f108ecb45e533894647622c | b5ab57edece8c14a67cc98e745c7d51449defcff | /Captain's Log/MainGame/Source/Managers/SLList.h | 5e1255a02adaa8a960f2041d110f0563d478493a | []
| no_license | tabu34/tht-captainslog | c648c6515424a6fcdb628320bc28fc7e5f23baba | 72d72a45e7ea44bdb8c1ffc5c960a0a3845557a2 | refs/heads/master | 2020-05-30T15:09:24.514919 | 2010-07-30T17:05:11 | 2010-07-30T17:05:11 | 32,187,254 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 7,902 | h | #ifndef SLLIST_H_
#define SLLIST_H_
//#include "CCodeProfiler.h"
template <typename Type> class SLLIter;
template <typename Type>
class SLList
{
struct Node
{
Type Data;
Node* next;
};
Node* Head;
public:
friend class SLLIter<Type>;
///////////////////////////////////////////////////////////////////////////////
// Function : Constructor
// Notes : constructs an empty list
///////////////////////////////////////////////////////////////////////////////
SLList()
{
Head = NULL;
}
///////////////////////////////////////////////////////////////////////////////
// Function : Destructor
// Notes : Destroys the list
///////////////////////////////////////////////////////////////////////////////
~SLList()
{
clear();
}
///////////////////////////////////////////////////////////////////////////////
// Function : Assignment Operator
///////////////////////////////////////////////////////////////////////////////
SLList<Type>& operator=(const SLList<Type>& that)
{
if (this != &that && that.Head)
{
this->clear();
Node* temp = that.Head->next;
Node* prev = that.Head;
Node* newPrev;
Head = new Node;
Head->Data = that.Head->Data;
Head->next = NULL;
newPrev = Head;
while(temp)
{
Node* curr = new Node;
curr->Data = temp->Data;
curr->next = NULL;
newPrev->next = curr;
newPrev = curr;
prev = prev->next;
temp = temp->next;
}
}
else if (!that.Head)
{
this->clear();
}
return *this;
}
///////////////////////////////////////////////////////////////////////////////
// Function : Copy Constructor
///////////////////////////////////////////////////////////////////////////////
SLList(const SLList<Type>& that)
{
Head = NULL;
this->clear();
Node* temp = that.Head->next;
Node* prev = that.Head;
Node* newPrev;
Head = new Node;
Head->Data = that.Head->Data;
Head->next = NULL;
newPrev = Head;
while(temp)
{
Node* curr = new Node;
curr->Data = temp->Data;
curr->next = NULL;
newPrev->next = curr;
newPrev = curr;
prev = prev->next;
temp = temp->next;
}
}
///////////////////////////////////////////////////////////////////////////////
// Function : addHead
// Parameters : v - the item to add to the list
///////////////////////////////////////////////////////////////////////////////
void addHead(const Type& v)
{
Node* pNode = new Node;
pNode->Data = v;
pNode->next = Head;
Head = pNode;
}
///////////////////////////////////////////////////////////////////////////////
// Function : clear
// Notes : clears the list, freeing any dynamic memory
///////////////////////////////////////////////////////////////////////////////
void clear()
{
Node* pDel;
while (Head)
{
pDel = Head;
Head = Head->next;
delete pDel;
}
}
///////////////////////////////////////////////////////////////////////////////
// Function : insert
// Parameters : index - an iterator to the location to insert at
// v - the item to insert
// Notes : do nothing on a bad iterator
///////////////////////////////////////////////////////////////////////////////
void insert(SLLIter<Type>& index, const Type& v)
{
if (index.curr == NULL)
return;
if (index.curr == Head)
{
Node* newNode = new Node;
newNode->Data = v;
newNode->next = Head;
Head = newNode;
index.curr = Head;
index.next = index.curr->next;
}
else
{
Node* temp = Head->next;
index.prev = Head;
index.next = Head->next->next;
while(temp && temp != index.curr)
{
temp = temp->next;
index.prev = index.prev->next;
if (index.next)
{
index.next = index.next->next;
}
}
Node* newNode = new Node;
newNode->Data = v;
newNode->next = index.curr;
index.prev->next = newNode;
index.curr = newNode;
index.next = index.curr->next;
//Node* curr = Head->next;
//Node* prev = Head;
//for (int i = 2; i < index; i++)
//{
// if (curr)
// {
// curr = curr->next;
// prev = prev->next;
// }
//}
//if (curr)
//{
// Node* newNode = new Node;
// newNode->Data = v;
// newNode->next = curr;
// prev->next = newNode;
//}
}
}
///////////////////////////////////////////////////////////////////////////////
// Function : remove
// Parameters : index - an iterator to the location to remove from
// Notes : do nothing on a bad iterator
///////////////////////////////////////////////////////////////////////////////
void remove(SLLIter<Type>& index)
{
if (index.curr == Head)
{
if (Head)
{
index.next = Head->next;
delete Head;
Head = index.next;
index.curr = index.next;
if (index.next)
index.next = index.curr->next;
}
//Node* pDel = Head;
//Head = Head->next;
//delete pDel;
}
else
{
Node* temp = Head->next;
index.prev = Head;
index.next = Head->next->next;
while(temp && temp != index.curr)
{
temp = temp->next;
index.prev = index.prev->next;
if (index.next)
{
index.next = index.next->next;
}
}
delete temp;
index.prev->next = index.next;
index.curr = index.next;
if (index.curr)
{
index.next = index.curr->next;
}
//Node* curr = Head->next;
//Node* prev = Head;
//for (int i = 2; i < index; i++)
//{
// if (curr)
// {
// curr = curr->next;
// prev = prev->next;
// }
//}
//if (curr)
//{
// Node* pDel = curr;
// prev->next = curr->next;
// delete pDel;
//}
}
}
inline unsigned int size() const
{
unsigned int nSize = 0;
Node* temp = Head;
while (temp)
{
temp = temp->next;
nSize++;
}
return nSize;
}
};
template <typename Type>
class SLLIter
{
SLList<Type>* List;
typename SLList<Type>::Node * curr;
typename SLList<Type>::Node * prev;
typename SLList<Type>::Node * next;
public:
friend class SLList<Type>;
///////////////////////////////////////////////////////////////////////////////
// Function : Constructor
// Parameters : listToIterate - the list to iterate
///////////////////////////////////////////////////////////////////////////////
SLLIter(SLList<Type>& listToIterate)
{
List = &listToIterate;
curr = prev = next = NULL;
}
///////////////////////////////////////////////////////////////////////////////
// Function : begin
// Notes : moves the iterator to the head of the list
///////////////////////////////////////////////////////////////////////////////
void begin()
{
curr = List->Head;
}
///////////////////////////////////////////////////////////////////////////////
// Function : end
// Notes : returns true if we are at the end of the list, false otherwise
///////////////////////////////////////////////////////////////////////////////
bool end() const
{
return (!curr)?true:false;
}
///////////////////////////////////////////////////////////////////////////////
// Function : operator++
// Notes : move the iterator forward one node
///////////////////////////////////////////////////////////////////////////////
SLLIter<Type>& operator++()
{
if (curr)
{
prev = curr;
curr = curr->next;
if (next)
next = next->next;
}
return *this;
}
///////////////////////////////////////////////////////////////////////////////
// Function : current
// Notes : returns the item at the current iterator location
///////////////////////////////////////////////////////////////////////////////
Type& current() const
{
return curr->Data;
}
};
#endif | [
"notserp007@34577012-8437-c882-6fb8-056151eb068d"
]
| [
[
[
1,
358
]
]
]
|
2815753ef54b9cafff4833198c75604cdace1d21 | 073dfce42b384c9438734daa8ee2b575ff100cc9 | /RCF/src/RCF/Protocol/Protocol.cpp | b6b68faa0df73a0f5b282ff783612d2b6027adac | []
| no_license | r0ssar00/iTunesSpeechBridge | a489426bbe30ac9bf9c7ca09a0b1acd624c1d9bf | 71a27a52e66f90ade339b2b8a7572b53577e2aaf | refs/heads/master | 2020-12-24T17:45:17.838301 | 2009-08-24T22:04:48 | 2009-08-24T22:04:48 | 285,393 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 702 | cpp |
//******************************************************************************
// RCF - Remote Call Framework
// Copyright (c) 2005 - 2009, Jarl Lindrud. All rights reserved.
// Consult your license for conditions of use.
// Version: 1.1
// Contact: jarl.lindrud <at> gmail.com
//******************************************************************************
#include <RCF/Protocol/Protocol.hpp>
#include <RCF/SerializationDefs.hpp>
#include <RCF/SerializationProtocol.hpp>
namespace RCF {
#ifdef RCF_USE_SF_SERIALIZATION
const int DefaultSerializationProtocol = SfBinary;
#else
const int DefaultSerializationProtocol = BsBinary;
#endif
} // namespace RCF
| [
"[email protected]"
]
| [
[
[
1,
26
]
]
]
|
311f821abc049cdf76acf26a32ce8c6f0310a62f | 8c54d89af1800c4c06959a3b7b62d04f883a11c0 | /cs752/Original/Raytracer/Camera.h | 2626d3be3d50cf98383624f2792cb83400d7a711 | []
| no_license | dknutsen/dokray | 567c79e7a69c80a97cd73bead151a12ad2d34f23 | 92acd2967542865963462aaf2299ab2427b89f31 | refs/heads/master | 2020-12-24T13:29:01.740250 | 2011-10-23T23:09:49 | 2011-10-23T23:09:49 | 2,639,353 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,038 | h | #ifndef Camera_h
#define Camera_h
#include "Vector.h"
#include "Point.h"
#include "Ray.h"
class RenderContext;
#define deg2rad 0.0174532925f
class Camera
{
public:
virtual void preprocess(float aspect) = 0;
virtual void generateRay(Ray& ray, const RenderContext& rc, float x, float y)const = 0;
virtual Point getEye()=0;
};
class PinholeCamera : public Camera
{
private:
Point eye;
Point lat;
Vector up;
float fov;
Vector U, V, L;
public:
PinholeCamera(Point eye, Point lat, Vector up, float fov);
virtual Point getEye();
virtual void preprocess(float aspect);
virtual void generateRay(Ray& ray, const RenderContext& rc, float x, float y)const;
/*Ray rays[xres*yres];
float step = 2.f/(float)resx;
float xstart = -1.f + 0.5*step;
float ystart = -(float)resy*0.5 + 0.5*step;
for(int i=0; i<resx; i++){
for(int j=0; j<resy; j++){
rays[i+j*resx] = Ray(Point(eye),
(L + (xstart+i*step)*U + (ystart*j+step)*V).normal());
}
}*/
};
#endif | [
"[email protected]"
]
| [
[
[
1,
52
]
]
]
|
96dc31c5b2842618cb2fd2e456cf63271a381c6a | b9115b524856b1595a21004603ce52bc25440515 | /simple-VN/header_files/CGame.hpp | cc47bb8dfec5f2fe6560b9565f6c9eed16afced7 | []
| no_license | martu/simple-VN | 74a3146b3f03d1684fa4533ba58b88c7bb61057c | ed175b8228433d942a62eb8229150326c831bbd7 | refs/heads/master | 2021-01-10T18:46:04.218361 | 2010-10-11T23:09:53 | 2010-10-11T23:09:53 | 962,351 | 4 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,150 | hpp | /*
* CGame.hpp
*
* Created on: 21.08.2010
* Author: Martu
*/
#ifndef CGAME_HPP_
#define CGAME_HPP_
#include "CScreen.hpp"
#include "CConversation.hpp"
#include "CMenuButton.hpp"
#include <map>
// the main game class. here runs the actual game
class CGame : public CScreen
{
private:
// CHARACTERS //
map<int, SCharacter *> m_Characters; // vector of all characters in the game
// PLAYER //
vector<string> m_PlayerFlags; // Flags from the player
// TextArea //
CTextArea m_TextArea; // Area which displays the Text, used in the conversation
// CONVERSATION //
CConversation m_Conversation;
// GUI //
vector<CMenuButton *> m_GuiButtons; // Buttons for the Gui
// GLOBAL VARIABLES //
bool m_bHidden; // If the Textarea and the GUI is hidden or not
// PRIVATE FUNCTIONS //
void InitScenes (); //Loads the Scenes (ONLY the Data, NOT the actual Images and so on)
void InitCharacters (); // Loads the characters
void InitGui (); // Initializes the Gui
void Update ();
void Render ();
public:
CGame ();
~CGame ();
int Run ();
};
#endif /* CGAME_HPP_ */
| [
"[email protected]"
]
| [
[
[
1,
51
]
]
]
|
d1e016e7748f3f99e6b756a32178d1b55c1e2e90 | 457cfb51e6b1053c852602f57acc9087629e966d | /source/BLUE/Material.h | 30660db62c14c59790ee02ce39dd105153ba7861 | []
| no_license | bluespeck/BLUE | b05eeff4958b2bf30adb0aeb2432f1c2f6c21d96 | 430d9dc0e64837007f35ce98fbface014be93678 | refs/heads/master | 2021-01-13T01:50:57.300012 | 2010-11-15T16:37:10 | 2010-11-15T16:37:10 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 354 | h | #pragma once
#include <tchar.h>
#include "Vector3.h"
#include "Color.h"
namespace BLUE
{
class CMaterial
{
public:
TCHAR m_name[MAX_PATH];
CColor m_vAmbient;
CColor m_vDiffuse;
CColor m_vSpecular;
int m_nShininess;
float m_fAlpha;
bool m_bSpecular;
public:
CMaterial();
~CMaterial(void);
};
} //end namespace BLUE | [
"[email protected]"
]
| [
[
[
1,
27
]
]
]
|
1bc52f92853f080f08dda9c826ffea795a4ce5a9 | bdb1e38df8bf74ac0df4209a77ddea841045349e | /CapsuleSortor/Version 1.0 -2.0/CapsuleSortor-10-11-11/ToolSrc/TToInteger.h | 50d803201bbe7d98d487963fe94aedae27d9eb49 | []
| no_license | Strongc/my001project | e0754f23c7818df964289dc07890e29144393432 | 07d6e31b9d4708d2ef691d9bedccbb818ea6b121 | refs/heads/master | 2021-01-19T07:02:29.673281 | 2010-12-17T03:10:52 | 2010-12-17T03:10:52 | 49,062,858 | 0 | 1 | null | 2016-01-05T11:53:07 | 2016-01-05T11:53:07 | null | GB18030 | C++ | false | false | 1,103 | h | #ifndef TTOINTEGER_H
#define TTOINTEGER_H
// ToInteger.h : interface and implement of the ToInteger class
//
// High-speed convertion from double to int
//
// Copyright (c) 2007 zhao_fsh Zibo Creative Computor CO.,LTD
//
//////////////////////////////////////////////////////////////////////////
//
// 下述方法全都基于以下几个假设
// (1)在x86上;
// (2)符合IEEE的浮点数标准;
// (3)int为32位,float为32位,double为64位。
// 四舍五入到整型
class TToInteger
{
public:
static int Round(double value);
static int Floor(double value);
static int Ceil (double value);
private:
TToInteger();
};
inline int TToInteger::Round(double value)
{
double magic = 6755399441055744.0;
value += magic;
return *(int*)&value;
}
// 截取到整数
inline int TToInteger::Floor(double value)
{
double magic_delta=0.499999999999;
return Round(value-magic_delta);
}
// 进位到整数
inline int TToInteger::Ceil (double value)
{
double magic_delta=0.499999999999;
return Round(value+magic_delta);
}
#endif //TTOINTEGER_H | [
"vincen.cn@66f52ff4-a261-11de-b161-9f508301ba8e"
]
| [
[
[
1,
48
]
]
]
|
0edb91f160c2a5c06a5735a7e2bf38d5bc0994d3 | 6581dacb25182f7f5d7afb39975dc622914defc7 | /SQLiteBrowser/tags/start/sqlitebrowser/sqlitebrowser/browsermain.cpp | 66ebff4164b6484d9a5e70b272872fc265f391d7 | []
| no_license | dice2019/alexlabonline | caeccad28bf803afb9f30b9e3cc663bb2909cc4f | 4c433839965ed0cff99dad82f0ba1757366be671 | refs/heads/master | 2021-01-16T19:37:24.002905 | 2011-09-21T15:20:16 | 2011-09-21T15:20:16 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 535 | cpp | /*
** This file is part of SQLite Database Browser
** http://sqlitebrowser.sourceforge.net
**
** Originally developed by Mauricio Piacentini, Tabuleiro
**
** The author disclaims copyright to this source code.
** Consult the LICENSING file for known restrictions
**
*/
#include <qapplication.h>
#include "form1.h"
int main( int argc, char ** argv )
{
QApplication a( argc, argv );
mainForm w;
w.show();
a.connect( &a, SIGNAL( lastWindowClosed() ), &a, SLOT( quit() ) );
return a.exec();
}
| [
"damoguyan8844@3a4e9f68-f5c2-36dc-e45a-441593085838"
]
| [
[
[
1,
22
]
]
]
|
d2f42a743a2c91868fcd9c210302ee1187a6c6bb | 02c2e62bcb9a54738bfbd95693978b8709e88fdb | /opencv/cxdrawing.cpp | 9b95361d8bb639aac54cd7d43ddf4489eca03f4f | []
| no_license | ThadeuFerreira/sift-coprojeto | 7ab823926e135f0ac388ae267c40e7069e39553a | bba43ef6fa37561621eb5f2126e5aa7d1c3f7024 | refs/heads/master | 2021-01-10T15:15:21.698124 | 2009-05-08T17:38:51 | 2009-05-08T17:38:51 | 45,042,655 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 83,470 | cpp | /*M///////////////////////////////////////////////////////////////////////////////////////
//
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
//
// By downloading, copying, installing or using the software you agree to this license.
// If you do not agree to this license, do not download, install,
// copy or use the software.
//
//
// Intel License Agreement
// For Open Source Computer Vision Library
//
// Copyright (C) 2000, Intel Corporation, all rights reserved.
// Third party copyrights are property of their respective owners.
//
// Redistribution and use in source and binary forms, with or without modification,
// are permitted provided that the following conditions are met:
//
// * Redistribution's of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
//
// * Redistribution's 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.
//
// * The name of Intel Corporation may not be used to endorse or promote products
// derived from this software without specific prior written permission.
//
// This software is provided by the copyright holders and contributors "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 Intel Corporation or contributors 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.
//
//M*/
#include "_cxcore.h"
#define XY_SHIFT 16
#define XY_ONE (1 << XY_SHIFT)
#define CV_DRAWING_STORAGE_BLOCK ((1 << 12) - 256)
typedef struct CvPolyEdge
{
int x, dx;
union
{
struct CvPolyEdge *next;
int y0;
};
int y1;
}
CvPolyEdge;
static void
icvCollectPolyEdges( CvMat* img, CvSeq* v, CvContour* edges,
const void* color, int line_type,
int shift, CvPoint offset=cvPoint(0,0) );
static void
icvFillEdgeCollection( CvMat* img, CvContour* edges, const void* color );
static void
icvPolyLine( CvMat* img, CvPoint *v, int count, int closed,
const void* color, int thickness, int line_type, int shift );
static void
icvFillConvexPoly( CvMat* img, CvPoint* v, int npts,
const void* color, int line_type, int shift );
/****************************************************************************************\
* Lines *
\****************************************************************************************/
CV_IMPL int
cvClipLine( CvSize img_size, CvPoint* pt1, CvPoint* pt2 )
{
int result = 0;
CV_FUNCNAME( "cvClipLine" );
__BEGIN__;
int x1, y1, x2, y2;
int c1, c2;
int right = img_size.width-1, bottom = img_size.height-1;
if( !pt1 || !pt2 )
CV_ERROR( CV_StsNullPtr, "One of point pointers is NULL" );
if( right < 0 || bottom < 0 )
CV_ERROR( CV_StsOutOfRange, "Image width or height are negative" );
x1 = pt1->x; y1 = pt1->y; x2 = pt2->x; y2 = pt2->y;
c1 = (x1 < 0) + (x1 > right) * 2 + (y1 < 0) * 4 + (y1 > bottom) * 8;
c2 = (x2 < 0) + (x2 > right) * 2 + (y2 < 0) * 4 + (y2 > bottom) * 8;
if( (c1 & c2) == 0 && (c1 | c2) != 0 )
{
int a;
if( c1 & 12 )
{
a = c1 < 8 ? 0 : bottom;
x1 += (int) (((int64) (a - y1)) * (x2 - x1) / (y2 - y1));
y1 = a;
c1 = (x1 < 0) + (x1 > right) * 2;
}
if( c2 & 12 )
{
a = c2 < 8 ? 0 : bottom;
x2 += (int) (((int64) (a - y2)) * (x2 - x1) / (y2 - y1));
y2 = a;
c2 = (x2 < 0) + (x2 > right) * 2;
}
if( (c1 & c2) == 0 && (c1 | c2) != 0 )
{
if( c1 )
{
a = c1 == 1 ? 0 : right;
y1 += (int) (((int64) (a - x1)) * (y2 - y1) / (x2 - x1));
x1 = a;
c1 = 0;
}
if( c2 )
{
a = c2 == 1 ? 0 : right;
y2 += (int) (((int64) (a - x2)) * (y2 - y1) / (x2 - x1));
x2 = a;
c2 = 0;
}
}
assert( (c1 & c2) != 0 || (x1 | y1 | x2 | y2) >= 0 );
pt1->x = x1;
pt1->y = y1;
pt2->x = x2;
pt2->y = y2;
}
result = ( c1 | c2 ) == 0;
__END__;
return result;
}
/*
Initializes line iterator.
Returns number of points on the line or negative number if error.
*/
CV_IMPL int
cvInitLineIterator( const CvArr* img, CvPoint pt1, CvPoint pt2,
CvLineIterator* iterator, int connectivity,
int left_to_right )
{
int count = -1;
CV_FUNCNAME( "cvInitLineIterator" );
__BEGIN__;
CvMat stub, *mat = (CvMat*)img;
int dx, dy, s;
int bt_pix, bt_pix0, step;
if( !CV_IS_MAT(mat) )
CV_CALL( mat = cvGetMat( mat, &stub ));
if( !iterator )
CV_ERROR( CV_StsNullPtr, "Pointer to the iterator state is NULL" );
if( connectivity != 8 && connectivity != 4 )
CV_ERROR( CV_StsBadArg, "Connectivity must be 8 or 4" );
if( (unsigned)pt1.x >= (unsigned)(mat->width) ||
(unsigned)pt2.x >= (unsigned)(mat->width) ||
(unsigned)pt1.y >= (unsigned)(mat->height) ||
(unsigned)pt2.y >= (unsigned)(mat->height) )
CV_ERROR( CV_StsBadPoint,
"One of the ending points is outside of the image, use cvClipLine" );
bt_pix0 = bt_pix = icvPixSize[CV_MAT_TYPE(mat->type)];
step = mat->step;
dx = pt2.x - pt1.x;
dy = pt2.y - pt1.y;
s = dx < 0 ? -1 : 0;
if( left_to_right )
{
dx = (dx ^ s) - s;
dy = (dy ^ s) - s;
pt1.x ^= (pt1.x ^ pt2.x) & s;
pt1.y ^= (pt1.y ^ pt2.y) & s;
}
else
{
dx = (dx ^ s) - s;
bt_pix = (bt_pix ^ s) - s;
}
iterator->ptr = (uchar*)(mat->data.ptr + pt1.y * step + pt1.x * bt_pix0);
s = dy < 0 ? -1 : 0;
dy = (dy ^ s) - s;
step = (step ^ s) - s;
s = dy > dx ? -1 : 0;
/* conditional swaps */
dx ^= dy & s;
dy ^= dx & s;
dx ^= dy & s;
bt_pix ^= step & s;
step ^= bt_pix & s;
bt_pix ^= step & s;
if( connectivity == 8 )
{
assert( dx >= 0 && dy >= 0 );
iterator->err = dx - (dy + dy);
iterator->plus_delta = dx + dx;
iterator->minus_delta = -(dy + dy);
iterator->plus_step = step;
iterator->minus_step = bt_pix;
count = dx + 1;
}
else /* connectivity == 4 */
{
assert( dx >= 0 && dy >= 0 );
iterator->err = 0;
iterator->plus_delta = (dx + dx) + (dy + dy);
iterator->minus_delta = -(dy + dy);
iterator->plus_step = step - bt_pix;
iterator->minus_step = bt_pix;
count = dx + dy + 1;
}
__END__;
return count;
}
static void
icvLine( CvMat* mat, CvPoint pt1, CvPoint pt2,
const void* color, int connectivity = 8 )
{
if( cvClipLine( cvGetMatSize(mat), &pt1, &pt2 ))
{
CvLineIterator iterator;
int pix_size = icvPixSize[CV_MAT_TYPE(mat->type)];
int i, count;
if( connectivity == 0 )
connectivity = 8;
if( connectivity == 1 )
connectivity = 4;
count = cvInitLineIterator( mat, pt1, pt2, &iterator, connectivity, 1 );
for( i = 0; i < count; i++ )
{
CV_MEMCPY_AUTO( iterator.ptr, color, pix_size );
CV_NEXT_LINE_POINT( iterator );
}
}
}
/* Correction table depent on the slope */
static const uchar icvSlopeCorrTable[] = {
181, 181, 181, 182, 182, 183, 184, 185, 187, 188, 190, 192, 194, 196, 198, 201,
203, 206, 209, 211, 214, 218, 221, 224, 227, 231, 235, 238, 242, 246, 250, 254
};
/* Gaussian for antialiasing filter */
static const int icvFilterTable[] = {
168, 177, 185, 194, 202, 210, 218, 224, 231, 236, 241, 246, 249, 252, 254, 254,
254, 254, 252, 249, 246, 241, 236, 231, 224, 218, 210, 202, 194, 185, 177, 168,
158, 149, 140, 131, 122, 114, 105, 97, 89, 82, 75, 68, 62, 56, 50, 45,
40, 36, 32, 28, 25, 22, 19, 16, 14, 12, 11, 9, 8, 7, 5, 5
};
static void
icvLineAA( CvMat* img, CvPoint pt1, CvPoint pt2,
const void* color )
{
int dx, dy;
int ecount, scount = 0;
int slope;
int ax, ay;
int x_step, y_step;
int i, j;
int ep_table[9];
int cb = ((uchar*)color)[0], cg = ((uchar*)color)[1], cr = ((uchar*)color)[2];
int _cb, _cg, _cr;
int nch = CV_MAT_CN( img->type );
uchar* ptr = (uchar*)(img->data.ptr);
int step = img->step;
CvSize size = cvGetMatSize( img );
assert( img && (nch == 1 || nch == 3) && CV_MAT_DEPTH(img->type) == CV_8U );
pt1.x -= XY_ONE*2;
pt1.y -= XY_ONE*2;
pt2.x -= XY_ONE*2;
pt2.y -= XY_ONE*2;
ptr += img->step*2 + 2*nch;
size.width = ((size.width - 5) << XY_SHIFT) + 1;
size.height = ((size.height - 5) << XY_SHIFT) + 1;
if( !cvClipLine( size, &pt1, &pt2 ))
return;
dx = pt2.x - pt1.x;
dy = pt2.y - pt1.y;
j = dx < 0 ? -1 : 0;
ax = (dx ^ j) - j;
i = dy < 0 ? -1 : 0;
ay = (dy ^ i) - i;
if( ax > ay )
{
dx = ax;
dy = (dy ^ j) - j;
pt1.x ^= pt2.x & j;
pt2.x ^= pt1.x & j;
pt1.x ^= pt2.x & j;
pt1.y ^= pt2.y & j;
pt2.y ^= pt1.y & j;
pt1.y ^= pt2.y & j;
x_step = XY_ONE;
y_step = (int) (((int64) dy << XY_SHIFT) / (ax | 1));
pt2.x += XY_ONE;
ecount = (pt2.x >> XY_SHIFT) - (pt1.x >> XY_SHIFT);
j = -(pt1.x & (XY_ONE - 1));
pt1.y += (int) ((((int64) y_step) * j) >> XY_SHIFT) + (XY_ONE >> 1);
slope = (y_step >> (XY_SHIFT - 5)) & 0x3f;
slope ^= (y_step < 0 ? 0x3f : 0);
/* Get 4-bit fractions for end-point adjustments */
i = (pt1.x >> (XY_SHIFT - 7)) & 0x78;
j = (pt2.x >> (XY_SHIFT - 7)) & 0x78;
}
else
{
dy = ay;
dx = (dx ^ i) - i;
pt1.x ^= pt2.x & i;
pt2.x ^= pt1.x & i;
pt1.x ^= pt2.x & i;
pt1.y ^= pt2.y & i;
pt2.y ^= pt1.y & i;
pt1.y ^= pt2.y & i;
x_step = (int) (((int64) dx << XY_SHIFT) / (ay | 1));
y_step = XY_ONE;
pt2.y += XY_ONE;
ecount = (pt2.y >> XY_SHIFT) - (pt1.y >> XY_SHIFT);
j = -(pt1.y & (XY_ONE - 1));
pt1.x += (int) ((((int64) x_step) * j) >> XY_SHIFT) + (XY_ONE >> 1);
slope = (x_step >> (XY_SHIFT - 5)) & 0x3f;
slope ^= (x_step < 0 ? 0x3f : 0);
/* Get 4-bit fractions for end-point adjustments */
i = (pt1.y >> (XY_SHIFT - 7)) & 0x78;
j = (pt2.y >> (XY_SHIFT - 7)) & 0x78;
}
slope = (slope & 0x20) ? 0x100 : icvSlopeCorrTable[slope];
/* Calc end point correction table */
{
int t0 = slope << 7;
int t1 = ((0x78 - i) | 4) * slope;
int t2 = (j | 4) * slope;
ep_table[0] = 0;
ep_table[8] = slope;
ep_table[1] = ep_table[3] = ((((j - i) & 0x78) | 4) * slope >> 8) & 0x1ff;
ep_table[2] = (t1 >> 8) & 0x1ff;
ep_table[4] = ((((j - i) + 0x80) | 4) * slope >> 8) & 0x1ff;
ep_table[5] = ((t1 + t0) >> 8) & 0x1ff;
ep_table[6] = (t2 >> 8) & 0x1ff;
ep_table[7] = ((t2 + t0) >> 8) & 0x1ff;
}
if( nch == 3 )
{
#define ICV_PUT_POINT() \
{ \
_cb = tptr[0]; \
_cb += ((cb - _cb)*a + 127)>> 8;\
_cg = tptr[1]; \
_cg += ((cg - _cg)*a + 127)>> 8;\
_cr = tptr[2]; \
_cr += ((cr - _cr)*a + 127)>> 8;\
tptr[0] = (uchar)_cb; \
tptr[1] = (uchar)_cg; \
tptr[2] = (uchar)_cr; \
}
if( ax > ay )
{
ptr += (pt1.x >> XY_SHIFT) * 3;
while( ecount >= 0 )
{
uchar *tptr = ptr + ((pt1.y >> XY_SHIFT) - 1) * step;
int ep_corr = ep_table[(((scount >= 2) + 1) & (scount | 2)) * 3 +
(((ecount >= 2) + 1) & (ecount | 2))];
int a, dist = (pt1.y >> (XY_SHIFT - 5)) & 31;
a = (ep_corr * icvFilterTable[dist + 32] >> 8) & 0xff;
ICV_PUT_POINT();
ICV_PUT_POINT();
tptr += step;
a = (ep_corr * icvFilterTable[dist] >> 8) & 0xff;
ICV_PUT_POINT();
ICV_PUT_POINT();
tptr += step;
a = (ep_corr * icvFilterTable[63 - dist] >> 8) & 0xff;
ICV_PUT_POINT();
ICV_PUT_POINT();
pt1.y += y_step;
ptr += 3;
scount++;
ecount--;
}
}
else
{
ptr += (pt1.y >> XY_SHIFT) * step;
while( ecount >= 0 )
{
uchar *tptr = ptr + ((pt1.x >> XY_SHIFT) - 1) * 3;
int ep_corr = ep_table[(((scount >= 2) + 1) & (scount | 2)) * 3 +
(((ecount >= 2) + 1) & (ecount | 2))];
int a, dist = (pt1.x >> (XY_SHIFT - 5)) & 31;
a = (ep_corr * icvFilterTable[dist + 32] >> 8) & 0xff;
ICV_PUT_POINT();
ICV_PUT_POINT();
tptr += 3;
a = (ep_corr * icvFilterTable[dist] >> 8) & 0xff;
ICV_PUT_POINT();
ICV_PUT_POINT();
tptr += 3;
a = (ep_corr * icvFilterTable[63 - dist] >> 8) & 0xff;
ICV_PUT_POINT();
ICV_PUT_POINT();
pt1.x += x_step;
ptr += step;
scount++;
ecount--;
}
}
#undef ICV_PUT_POINT
}
else
{
#define ICV_PUT_POINT() \
{ \
_cb = tptr[0]; \
_cb += ((cb - _cb)*a + 127)>> 8;\
tptr[0] = (uchar)_cb; \
}
if( ax > ay )
{
ptr += (pt1.x >> XY_SHIFT);
while( ecount >= 0 )
{
uchar *tptr = ptr + ((pt1.y >> XY_SHIFT) - 1) * step;
int ep_corr = ep_table[(((scount >= 2) + 1) & (scount | 2)) * 3 +
(((ecount >= 2) + 1) & (ecount | 2))];
int a, dist = (pt1.y >> (XY_SHIFT - 5)) & 31;
a = (ep_corr * icvFilterTable[dist + 32] >> 8) & 0xff;
ICV_PUT_POINT();
ICV_PUT_POINT();
tptr += step;
a = (ep_corr * icvFilterTable[dist] >> 8) & 0xff;
ICV_PUT_POINT();
ICV_PUT_POINT();
tptr += step;
a = (ep_corr * icvFilterTable[63 - dist] >> 8) & 0xff;
ICV_PUT_POINT();
ICV_PUT_POINT();
pt1.y += y_step;
ptr++;
scount++;
ecount--;
}
}
else
{
ptr += (pt1.y >> XY_SHIFT) * step;
while( ecount >= 0 )
{
uchar *tptr = ptr + ((pt1.x >> XY_SHIFT) - 1);
int ep_corr = ep_table[(((scount >= 2) + 1) & (scount | 2)) * 3 +
(((ecount >= 2) + 1) & (ecount | 2))];
int a, dist = (pt1.x >> (XY_SHIFT - 5)) & 31;
a = (ep_corr * icvFilterTable[dist + 32] >> 8) & 0xff;
ICV_PUT_POINT();
ICV_PUT_POINT();
tptr++;
a = (ep_corr * icvFilterTable[dist] >> 8) & 0xff;
ICV_PUT_POINT();
ICV_PUT_POINT();
tptr++;
a = (ep_corr * icvFilterTable[63 - dist] >> 8) & 0xff;
ICV_PUT_POINT();
ICV_PUT_POINT();
pt1.x += x_step;
ptr += step;
scount++;
ecount--;
}
}
#undef ICV_PUT_POINT
}
}
static void
icvLine2( CvMat* img, CvPoint pt1, CvPoint pt2, const void* color )
{
int dx, dy;
int ecount;
int ax, ay;
int i, j;
int x_step, y_step;
int cb = ((uchar*)color)[0], cg = ((uchar*)color)[1], cr = ((uchar*)color)[2];
int pix_size = CV_ELEM_SIZE( img->type );
uchar *ptr = (uchar*)(img->data.ptr), *tptr;
int step = img->step;
CvSize size = cvGetMatSize( img );
//assert( img && (nch == 1 || nch == 3) && CV_MAT_DEPTH(img->type) == CV_8U );
pt1.x -= XY_ONE*2;
pt1.y -= XY_ONE*2;
pt2.x -= XY_ONE*2;
pt2.y -= XY_ONE*2;
ptr += img->step*2 + 2*pix_size;
size.width = ((size.width - 5) << XY_SHIFT) + 1;
size.height = ((size.height - 5) << XY_SHIFT) + 1;
if( !cvClipLine( size, &pt1, &pt2 ))
return;
dx = pt2.x - pt1.x;
dy = pt2.y - pt1.y;
j = dx < 0 ? -1 : 0;
ax = (dx ^ j) - j;
i = dy < 0 ? -1 : 0;
ay = (dy ^ i) - i;
if( ax > ay )
{
dx = ax;
dy = (dy ^ j) - j;
pt1.x ^= pt2.x & j;
pt2.x ^= pt1.x & j;
pt1.x ^= pt2.x & j;
pt1.y ^= pt2.y & j;
pt2.y ^= pt1.y & j;
pt1.y ^= pt2.y & j;
x_step = XY_ONE;
y_step = (int) (((int64) dy << XY_SHIFT) / (ax | 1));
ecount = (pt2.x - pt1.x) >> XY_SHIFT;
}
else
{
dy = ay;
dx = (dx ^ i) - i;
pt1.x ^= pt2.x & i;
pt2.x ^= pt1.x & i;
pt1.x ^= pt2.x & i;
pt1.y ^= pt2.y & i;
pt2.y ^= pt1.y & i;
pt1.y ^= pt2.y & i;
x_step = (int) (((int64) dx << XY_SHIFT) / (ay | 1));
y_step = XY_ONE;
ecount = (pt2.y - pt1.y) >> XY_SHIFT;
}
pt1.x += (XY_ONE >> 1);
pt1.y += (XY_ONE >> 1);
if( pix_size == 3 )
{
#define ICV_PUT_POINT() \
{ \
tptr[0] = (uchar)cb; \
tptr[1] = (uchar)cg; \
tptr[2] = (uchar)cr; \
}
tptr = ptr + ((pt2.x + (XY_ONE >> 1))>> XY_SHIFT)*3 +
((pt2.y + (XY_ONE >> 1)) >> XY_SHIFT)*step;
ICV_PUT_POINT();
if( ax > ay )
{
ptr += (pt1.x >> XY_SHIFT) * 3;
while( ecount >= 0 )
{
tptr = ptr + (pt1.y >> XY_SHIFT) * step;
ICV_PUT_POINT();
pt1.y += y_step;
ptr += 3;
ecount--;
}
}
else
{
ptr += (pt1.y >> XY_SHIFT) * step;
while( ecount >= 0 )
{
tptr = ptr + (pt1.x >> XY_SHIFT) * 3;
ICV_PUT_POINT();
pt1.x += x_step;
ptr += step;
ecount--;
}
}
#undef ICV_PUT_POINT
}
else if( pix_size == 1 )
{
#define ICV_PUT_POINT() \
{ \
tptr[0] = (uchar)cb; \
}
tptr = ptr + ((pt2.x + (XY_ONE >> 1))>> XY_SHIFT) +
((pt2.y + (XY_ONE >> 1)) >> XY_SHIFT)*step;
ICV_PUT_POINT();
if( ax > ay )
{
ptr += (pt1.x >> XY_SHIFT);
while( ecount >= 0 )
{
tptr = ptr + (pt1.y >> XY_SHIFT) * step;
ICV_PUT_POINT();
pt1.y += y_step;
ptr++;
ecount--;
}
}
else
{
ptr += (pt1.y >> XY_SHIFT) * step;
while( ecount >= 0 )
{
tptr = ptr + (pt1.x >> XY_SHIFT);
ICV_PUT_POINT();
pt1.x += x_step;
ptr += step;
ecount--;
}
}
#undef ICV_PUT_POINT
}
else
{
#define ICV_PUT_POINT() \
for( j = 0; j < pix_size; j++ ) \
tptr[j] = ((uchar*)color)[j];
tptr = ptr + ((pt2.x + (XY_ONE >> 1))>> XY_SHIFT)*pix_size +
((pt2.y + (XY_ONE >> 1)) >> XY_SHIFT)*step;
ICV_PUT_POINT();
if( ax > ay )
{
ptr += (pt1.x >> XY_SHIFT) * pix_size;
while( ecount >= 0 )
{
tptr = ptr + (pt1.y >> XY_SHIFT) * step;
ICV_PUT_POINT();
pt1.y += y_step;
ptr += pix_size;
ecount--;
}
}
else
{
ptr += (pt1.y >> XY_SHIFT) * step;
while( ecount >= 0 )
{
tptr = ptr + (pt1.x >> XY_SHIFT) * pix_size;
ICV_PUT_POINT();
pt1.x += x_step;
ptr += step;
ecount--;
}
}
#undef ICV_PUT_POINT
}
}
/****************************************************************************************\
* Antialiazed Elliptic Arcs via Antialiazed Lines *
\****************************************************************************************/
static const float icvSinTable[] =
{ 0.0000000f, 0.0174524f, 0.0348995f, 0.0523360f, 0.0697565f, 0.0871557f,
0.1045285f, 0.1218693f, 0.1391731f, 0.1564345f, 0.1736482f, 0.1908090f,
0.2079117f, 0.2249511f, 0.2419219f, 0.2588190f, 0.2756374f, 0.2923717f,
0.3090170f, 0.3255682f, 0.3420201f, 0.3583679f, 0.3746066f, 0.3907311f,
0.4067366f, 0.4226183f, 0.4383711f, 0.4539905f, 0.4694716f, 0.4848096f,
0.5000000f, 0.5150381f, 0.5299193f, 0.5446390f, 0.5591929f, 0.5735764f,
0.5877853f, 0.6018150f, 0.6156615f, 0.6293204f, 0.6427876f, 0.6560590f,
0.6691306f, 0.6819984f, 0.6946584f, 0.7071068f, 0.7193398f, 0.7313537f,
0.7431448f, 0.7547096f, 0.7660444f, 0.7771460f, 0.7880108f, 0.7986355f,
0.8090170f, 0.8191520f, 0.8290376f, 0.8386706f, 0.8480481f, 0.8571673f,
0.8660254f, 0.8746197f, 0.8829476f, 0.8910065f, 0.8987940f, 0.9063078f,
0.9135455f, 0.9205049f, 0.9271839f, 0.9335804f, 0.9396926f, 0.9455186f,
0.9510565f, 0.9563048f, 0.9612617f, 0.9659258f, 0.9702957f, 0.9743701f,
0.9781476f, 0.9816272f, 0.9848078f, 0.9876883f, 0.9902681f, 0.9925462f,
0.9945219f, 0.9961947f, 0.9975641f, 0.9986295f, 0.9993908f, 0.9998477f,
1.0000000f, 0.9998477f, 0.9993908f, 0.9986295f, 0.9975641f, 0.9961947f,
0.9945219f, 0.9925462f, 0.9902681f, 0.9876883f, 0.9848078f, 0.9816272f,
0.9781476f, 0.9743701f, 0.9702957f, 0.9659258f, 0.9612617f, 0.9563048f,
0.9510565f, 0.9455186f, 0.9396926f, 0.9335804f, 0.9271839f, 0.9205049f,
0.9135455f, 0.9063078f, 0.8987940f, 0.8910065f, 0.8829476f, 0.8746197f,
0.8660254f, 0.8571673f, 0.8480481f, 0.8386706f, 0.8290376f, 0.8191520f,
0.8090170f, 0.7986355f, 0.7880108f, 0.7771460f, 0.7660444f, 0.7547096f,
0.7431448f, 0.7313537f, 0.7193398f, 0.7071068f, 0.6946584f, 0.6819984f,
0.6691306f, 0.6560590f, 0.6427876f, 0.6293204f, 0.6156615f, 0.6018150f,
0.5877853f, 0.5735764f, 0.5591929f, 0.5446390f, 0.5299193f, 0.5150381f,
0.5000000f, 0.4848096f, 0.4694716f, 0.4539905f, 0.4383711f, 0.4226183f,
0.4067366f, 0.3907311f, 0.3746066f, 0.3583679f, 0.3420201f, 0.3255682f,
0.3090170f, 0.2923717f, 0.2756374f, 0.2588190f, 0.2419219f, 0.2249511f,
0.2079117f, 0.1908090f, 0.1736482f, 0.1564345f, 0.1391731f, 0.1218693f,
0.1045285f, 0.0871557f, 0.0697565f, 0.0523360f, 0.0348995f, 0.0174524f,
0.0000000f, -0.0174524f, -0.0348995f, -0.0523360f, -0.0697565f, -0.0871557f,
-0.1045285f, -0.1218693f, -0.1391731f, -0.1564345f, -0.1736482f, -0.1908090f,
-0.2079117f, -0.2249511f, -0.2419219f, -0.2588190f, -0.2756374f, -0.2923717f,
-0.3090170f, -0.3255682f, -0.3420201f, -0.3583679f, -0.3746066f, -0.3907311f,
-0.4067366f, -0.4226183f, -0.4383711f, -0.4539905f, -0.4694716f, -0.4848096f,
-0.5000000f, -0.5150381f, -0.5299193f, -0.5446390f, -0.5591929f, -0.5735764f,
-0.5877853f, -0.6018150f, -0.6156615f, -0.6293204f, -0.6427876f, -0.6560590f,
-0.6691306f, -0.6819984f, -0.6946584f, -0.7071068f, -0.7193398f, -0.7313537f,
-0.7431448f, -0.7547096f, -0.7660444f, -0.7771460f, -0.7880108f, -0.7986355f,
-0.8090170f, -0.8191520f, -0.8290376f, -0.8386706f, -0.8480481f, -0.8571673f,
-0.8660254f, -0.8746197f, -0.8829476f, -0.8910065f, -0.8987940f, -0.9063078f,
-0.9135455f, -0.9205049f, -0.9271839f, -0.9335804f, -0.9396926f, -0.9455186f,
-0.9510565f, -0.9563048f, -0.9612617f, -0.9659258f, -0.9702957f, -0.9743701f,
-0.9781476f, -0.9816272f, -0.9848078f, -0.9876883f, -0.9902681f, -0.9925462f,
-0.9945219f, -0.9961947f, -0.9975641f, -0.9986295f, -0.9993908f, -0.9998477f,
-1.0000000f, -0.9998477f, -0.9993908f, -0.9986295f, -0.9975641f, -0.9961947f,
-0.9945219f, -0.9925462f, -0.9902681f, -0.9876883f, -0.9848078f, -0.9816272f,
-0.9781476f, -0.9743701f, -0.9702957f, -0.9659258f, -0.9612617f, -0.9563048f,
-0.9510565f, -0.9455186f, -0.9396926f, -0.9335804f, -0.9271839f, -0.9205049f,
-0.9135455f, -0.9063078f, -0.8987940f, -0.8910065f, -0.8829476f, -0.8746197f,
-0.8660254f, -0.8571673f, -0.8480481f, -0.8386706f, -0.8290376f, -0.8191520f,
-0.8090170f, -0.7986355f, -0.7880108f, -0.7771460f, -0.7660444f, -0.7547096f,
-0.7431448f, -0.7313537f, -0.7193398f, -0.7071068f, -0.6946584f, -0.6819984f,
-0.6691306f, -0.6560590f, -0.6427876f, -0.6293204f, -0.6156615f, -0.6018150f,
-0.5877853f, -0.5735764f, -0.5591929f, -0.5446390f, -0.5299193f, -0.5150381f,
-0.5000000f, -0.4848096f, -0.4694716f, -0.4539905f, -0.4383711f, -0.4226183f,
-0.4067366f, -0.3907311f, -0.3746066f, -0.3583679f, -0.3420201f, -0.3255682f,
-0.3090170f, -0.2923717f, -0.2756374f, -0.2588190f, -0.2419219f, -0.2249511f,
-0.2079117f, -0.1908090f, -0.1736482f, -0.1564345f, -0.1391731f, -0.1218693f,
-0.1045285f, -0.0871557f, -0.0697565f, -0.0523360f, -0.0348995f, -0.0174524f,
-0.0000000f, 0.0174524f, 0.0348995f, 0.0523360f, 0.0697565f, 0.0871557f,
0.1045285f, 0.1218693f, 0.1391731f, 0.1564345f, 0.1736482f, 0.1908090f,
0.2079117f, 0.2249511f, 0.2419219f, 0.2588190f, 0.2756374f, 0.2923717f,
0.3090170f, 0.3255682f, 0.3420201f, 0.3583679f, 0.3746066f, 0.3907311f,
0.4067366f, 0.4226183f, 0.4383711f, 0.4539905f, 0.4694716f, 0.4848096f,
0.5000000f, 0.5150381f, 0.5299193f, 0.5446390f, 0.5591929f, 0.5735764f,
0.5877853f, 0.6018150f, 0.6156615f, 0.6293204f, 0.6427876f, 0.6560590f,
0.6691306f, 0.6819984f, 0.6946584f, 0.7071068f, 0.7193398f, 0.7313537f,
0.7431448f, 0.7547096f, 0.7660444f, 0.7771460f, 0.7880108f, 0.7986355f,
0.8090170f, 0.8191520f, 0.8290376f, 0.8386706f, 0.8480481f, 0.8571673f,
0.8660254f, 0.8746197f, 0.8829476f, 0.8910065f, 0.8987940f, 0.9063078f,
0.9135455f, 0.9205049f, 0.9271839f, 0.9335804f, 0.9396926f, 0.9455186f,
0.9510565f, 0.9563048f, 0.9612617f, 0.9659258f, 0.9702957f, 0.9743701f,
0.9781476f, 0.9816272f, 0.9848078f, 0.9876883f, 0.9902681f, 0.9925462f,
0.9945219f, 0.9961947f, 0.9975641f, 0.9986295f, 0.9993908f, 0.9998477f,
1.0000000f
};
static void
icvSinCos( int angle, float *cosval, float *sinval )
{
angle += (angle < 0 ? 360 : 0);
*sinval = icvSinTable[angle];
*cosval = icvSinTable[450 - angle];
}
/*
constructs polygon that represents elliptic arc.
*/
CV_IMPL int
cvEllipse2Poly( CvPoint center, CvSize axes, int angle,
int arc_start, int arc_end, CvPoint* pts, int delta )
{
float alpha, beta;
double size_a = axes.width, size_b = axes.height;
double cx = center.x, cy = center.y;
CvPoint *pts_origin = pts;
int i;
while( angle < 0 )
angle += 360;
while( angle > 360 )
angle -= 360;
if( arc_start > arc_end )
{
i = arc_start;
arc_start = arc_end;
arc_end = i;
}
while( arc_start < 0 )
{
arc_start += 360;
arc_end += 360;
}
while( arc_end > 360 )
{
arc_end -= 360;
arc_start -= 360;
}
if( arc_end - arc_start > 360 )
{
arc_start = 0;
arc_end = 360;
}
icvSinCos( angle, &alpha, &beta );
for( i = arc_start; i < arc_end + delta; i += delta )
{
double x, y;
angle = i;
if( angle > arc_end )
angle = arc_end;
if( angle < 0 )
angle += 360;
x = size_a * icvSinTable[450-angle];
y = size_b * icvSinTable[angle];
pts->x = cvRound( cx + x * alpha - y * beta );
pts->y = cvRound( cy - x * beta - y * alpha );
pts += i == arc_start || pts->x != pts[-1].x || pts->y != pts[-1].y;
}
i = (int)(pts - pts_origin);
for( ; i < 2; i++ )
pts_origin[i] = pts_origin[i-1];
return i;
}
static void
icvEllipseEx( CvMat* img, CvPoint center, CvSize axes,
int angle, int arc_start, int arc_end,
const void* color, int thickness, int line_type )
{
CvMemStorage* st = 0;
CV_FUNCNAME( "icvEllipseEx" );
__BEGIN__;
CvPoint v[1 << 8];
int count, delta;
if( axes.width < 0 || axes.height < 0 )
CV_ERROR( CV_StsBadSize, "" );
delta = (MAX(axes.width,axes.height)+(XY_ONE>>1))>>XY_SHIFT;
delta = delta < 3 ? 90 : delta < 10 ? 30 : delta < 15 ? 18 : 5;
count = cvEllipse2Poly( center, axes, angle, arc_start, arc_end, v, delta );
if( thickness >= 0 )
{
icvPolyLine( img, v, count, 0, color, thickness, line_type, XY_SHIFT );
}
else if( arc_end - arc_start >= 360 )
{
icvFillConvexPoly( img, v, count, color, line_type, XY_SHIFT );
}
else
{
CvContour* edges;
CvSeq vtx;
CvSeqBlock block;
CV_CALL( st = cvCreateMemStorage( CV_DRAWING_STORAGE_BLOCK ));
CV_CALL( edges = (CvContour*)cvCreateSeq( 0, sizeof(CvContour), sizeof(CvPolyEdge), st ));
v[count++] = center;
CV_CALL( cvMakeSeqHeaderForArray( CV_32SC2, sizeof(CvSeq), sizeof(CvPoint),
v, count, &vtx, &block ));
CV_CALL( icvCollectPolyEdges( img, &vtx, edges, color, line_type, XY_SHIFT ));
CV_CALL( icvFillEdgeCollection( img, edges, color ));
}
__END__;
if( st )
cvReleaseMemStorage( &st );
}
/****************************************************************************************\
* Polygons filling *
\****************************************************************************************/
/* helper macros: filling horizontal row */
#define ICV_HLINE( ptr, xl, xr, color, pix_size ) \
{ \
uchar* hline_ptr = (uchar*)(ptr) + (xl)*(pix_size); \
uchar* hline_max_ptr = (uchar*)(ptr) + (xr)*(pix_size); \
\
for( ; hline_ptr <= hline_max_ptr; hline_ptr += (pix_size))\
{ \
int hline_j; \
for( hline_j = 0; hline_j < (pix_size); hline_j++ ) \
{ \
hline_ptr[hline_j] = ((uchar*)color)[hline_j]; \
} \
} \
}
/* filling convex polygon. v - array of vertices, ntps - number of points */
static void
icvFillConvexPoly( CvMat* img, CvPoint *v, int npts, const void* color, int line_type, int shift )
{
struct
{
int idx, di;
int x, dx, ye;
}
edge[2];
int delta = shift ? 1 << (shift - 1) : 0;
int i, y, imin = 0, left = 0, right = 1, x1, x2;
int edges = npts;
int xmin, xmax, ymin, ymax;
uchar* ptr = img->data.ptr;
CvSize size = cvGetMatSize( img );
int pix_size = icvPixSize[CV_MAT_TYPE(img->type)];
CvPoint p0;
int delta1, delta2;
if( line_type < CV_AA )
delta1 = delta2 = XY_ONE >> 1;
//delta1 = 0, delta2 = XY_ONE - 1;
else
delta1 = XY_ONE - 1, delta2 = 0;
p0 = v[npts - 1];
p0.x <<= XY_SHIFT - shift;
p0.y <<= XY_SHIFT - shift;
assert( 0 <= shift && shift <= XY_SHIFT );
xmin = xmax = v[0].x;
ymin = ymax = v[0].y;
for( i = 0; i < npts; i++ )
{
CvPoint p = v[i];
if( p.y < ymin )
{
ymin = p.y;
imin = i;
}
ymax = MAX( ymax, p.y );
xmax = MAX( xmax, p.x );
xmin = MIN( xmin, p.x );
p.x <<= XY_SHIFT - shift;
p.y <<= XY_SHIFT - shift;
if( line_type <= 8 )
{
if( shift == 0 )
{
CvPoint pt0, pt1;
pt0.x = p0.x >> XY_SHIFT;
pt0.y = p0.y >> XY_SHIFT;
pt1.x = p.x >> XY_SHIFT;
pt1.y = p.y >> XY_SHIFT;
icvLine( img, pt0, pt1, color, line_type );
}
else
icvLine2( img, p0, p, color );
}
else
icvLineAA( img, p0, p, color );
p0 = p;
}
xmin = (xmin + delta) >> shift;
xmax = (xmax + delta) >> shift;
ymin = (ymin + delta) >> shift;
ymax = (ymax + delta) >> shift;
if( npts < 3 || xmax < 0 || ymax < 0 || xmin >= size.width || ymin >= size.height )
return;
ymax = MIN( ymax, size.height - 1 );
edge[0].idx = edge[1].idx = imin;
edge[0].ye = edge[1].ye = y = ymin;
edge[0].di = 1;
edge[1].di = npts - 1;
ptr += img->step*y;
do
{
if( line_type < CV_AA || y < ymax || y == ymin )
{
for( i = 0; i < 2; i++ )
{
if( y >= edge[i].ye )
{
int idx = edge[i].idx, di = edge[i].di;
int xs = 0, xe, ye, ty = 0;
for(;;)
{
ty = (v[idx].y + delta) >> shift;
if( ty > y || edges == 0 )
break;
xs = v[idx].x;
idx += di;
idx -= ((idx < npts) - 1) & npts; /* idx -= idx >= npts ? npts : 0 */
edges--;
}
ye = ty;
xs <<= XY_SHIFT - shift;
xe = v[idx].x << (XY_SHIFT - shift);
/* no more edges */
if( y >= ye )
return;
edge[i].ye = ye;
edge[i].dx = ((xe - xs)*2 + (ye - y)) / (2 * (ye - y));
edge[i].x = xs;
edge[i].idx = idx;
}
}
}
if( edge[left].x > edge[right].x )
{
left ^= 1;
right ^= 1;
}
x1 = edge[left].x;
x2 = edge[right].x;
if( y >= 0 )
{
int xx1 = (x1 + delta1) >> XY_SHIFT;
int xx2 = (x2 + delta2) >> XY_SHIFT;
if( xx2 >= 0 && xx1 < size.width )
{
if( xx1 < 0 )
xx1 = 0;
if( xx2 >= size.width )
xx2 = size.width - 1;
ICV_HLINE( ptr, xx1, xx2, color, pix_size );
}
}
x1 += edge[left].dx;
x2 += edge[right].dx;
edge[left].x = x1;
edge[right].x = x2;
ptr += img->step;
}
while( ++y <= ymax );
}
/******** Arbitrary polygon **********/
static void
icvCollectPolyEdges( CvMat* img, CvSeq* v, CvContour* edges,
const void* color, int line_type, int shift,
CvPoint offset )
{
int i, count = v->total;
CvRect bounds = edges->rect;
int delta = offset.y + (shift ? 1 << (shift - 1) : 0);
int elem_type = CV_MAT_TYPE(v->flags);
CvSeqReader reader;
CvSeqWriter writer;
cvStartReadSeq( v, &reader );
cvStartAppendToSeq( (CvSeq*)edges, &writer );
for( i = 0; i < count; i++ )
{
CvPoint pt0, pt1, t0, t1;
CvPolyEdge edge;
CV_READ_EDGE( pt0, pt1, reader );
if( elem_type == CV_32SC2 )
{
pt0.x = (pt0.x + offset.x) << (XY_SHIFT - shift);
pt0.y = (pt0.y + delta) >> shift;
pt1.x = (pt1.x + offset.y) << (XY_SHIFT - shift);
pt1.y = (pt1.y + delta) >> shift;
}
else
{
assert( shift == 0 );
pt0.x = cvRound(((float&)pt0.x + offset.x) * XY_ONE);
pt0.y = cvRound((float&)pt0.y + offset.y);
pt1.x = cvRound(((float&)pt1.x + offset.x) * XY_ONE);
pt1.y = cvRound((float&)pt1.y + offset.y);
}
if( line_type < CV_AA )
{
t0.y = pt0.y; t1.y = pt1.y;
t0.x = (pt0.x + (XY_ONE >> 1)) >> XY_SHIFT;
t1.x = (pt1.x + (XY_ONE >> 1)) >> XY_SHIFT;
icvLine( img, t0, t1, color, line_type );
}
else
{
t0.x = pt0.x; t1.x = pt1.x;
t0.y = pt0.y << XY_SHIFT;
t1.y = pt1.y << XY_SHIFT;
icvLineAA( img, t0, t1, color );
}
if( pt0.y == pt1.y )
continue;
if( pt0.y > pt1.y )
CV_SWAP( pt0, pt1, t0 );
bounds.y = MIN( bounds.y, pt0.y );
bounds.height = MAX( bounds.height, pt1.y );
if( pt0.x < pt1.x )
{
bounds.x = MIN( bounds.x, pt0.x );
bounds.width = MAX( bounds.width, pt1.x );
}
else
{
bounds.x = MIN( bounds.x, pt1.x );
bounds.width = MAX( bounds.width, pt0.x );
}
edge.y0 = pt0.y;
edge.y1 = pt1.y;
edge.x = pt0.x;
edge.dx = (pt1.x - pt0.x) / (pt1.y - pt0.y);
assert( edge.y0 < edge.y1 );
CV_WRITE_SEQ_ELEM( edge, writer );
}
edges->rect = bounds;
cvEndWriteSeq( &writer );
}
static int
icvCmpEdges( const void* _e1, const void* _e2, void* /*userdata*/ )
{
CvPolyEdge *e1 = (CvPolyEdge*)_e1, *e2 = (CvPolyEdge*)_e2;
return e1->y0 - e2->y0 ? e1->y0 - e2->y0 :
e1->x - e2->x ? e1->x - e2->x : e1->dx - e2->dx;
}
/**************** helper macros and functions for sequence/contour processing ***********/
static void
icvFillEdgeCollection( CvMat* img, CvContour* edges, const void* color )
{
CvPolyEdge tmp;
int i, y, total = edges->total;
CvSeqReader reader;
CvSize size = cvGetMatSize(img);
CvPolyEdge* e;
int y_max = INT_MIN;
int pix_size = icvPixSize[CV_MAT_TYPE(img->type)];
__BEGIN__;
memset( &tmp, 0, sizeof(tmp));
/* check parameters */
if( edges->total < 2 || edges->rect.height < 0 || edges->rect.y >= size.height ||
edges->rect.width < 0 || edges->rect.x >= size.width )
EXIT;
cvSeqSort( (CvSeq*)edges, icvCmpEdges, 0 );
cvStartReadSeq( (CvSeq*)edges, &reader );
#ifdef _DEBUG
e = &tmp;
tmp.y0 = INT_MIN;
#endif
for( i = 0; i < total; i++ )
{
CvPolyEdge* e1 = (CvPolyEdge*)(reader.ptr);
#ifdef _DEBUG
assert( e1->y0 < e1->y1 && (i == 0 || icvCmpEdges( e, e1, 0 ) <= 0) );
e = e1;
#endif
y_max = MAX( y_max, e1->y1 );
CV_NEXT_SEQ_ELEM( sizeof(CvPolyEdge), reader );
}
/* start drawing */
tmp.y0 = INT_MAX;
cvSeqPush( (CvSeq*)edges, &tmp );
i = 0;
tmp.next = 0;
cvStartReadSeq( (CvSeq*)edges, &reader );
e = (CvPolyEdge*)(reader.ptr);
y_max = MIN( y_max, size.height );
for( y = e->y0; y < y_max; y++ )
{
CvPolyEdge *last, *prelast, *keep_prelast;
int sort_flag = 0;
int draw = 0;
int clipline = y < 0;
prelast = &tmp;
last = tmp.next;
while( last || e->y0 == y )
{
if( last && last->y1 == y )
{
/* exlude edge if y reachs its lower point */
prelast->next = last->next;
last = last->next;
continue;
}
keep_prelast = prelast;
if( last && (e->y0 > y || last->x < e->x) )
{
/* go to the next edge in active list */
prelast = last;
last = last->next;
}
else if( i < total )
{
/* insert new edge into active list if y reachs its upper point */
prelast->next = e;
e->next = last;
prelast = e;
CV_NEXT_SEQ_ELEM( edges->elem_size, reader );
e = (CvPolyEdge*)(reader.ptr);
i++;
}
else
break;
if( draw )
{
if( !clipline )
{
/* convert x's from fixed-point to image coordinates */
uchar *timg = (uchar*)(img->data.ptr) + y * img->step;
int x1 = keep_prelast->x;
int x2 = prelast->x;
if( x1 > x2 )
{
int t = x1;
x1 = x2;
x2 = t;
}
x1 = (x1 + XY_ONE - 1) >> XY_SHIFT;
x2 = x2 >> XY_SHIFT;
/* clip and draw the line */
if( x1 < size.width && x2 >= 0 )
{
if( x1 < 0 )
x1 = 0;
if( x2 >= size.width )
x2 = size.width - 1;
ICV_HLINE( timg, x1, x2, color, pix_size );
}
}
keep_prelast->x += keep_prelast->dx;
prelast->x += prelast->dx;
}
draw ^= 1;
}
/* sort edges (bubble sort on list) */
keep_prelast = 0;
do
{
prelast = &tmp;
last = tmp.next;
while( last != keep_prelast && last->next != 0 )
{
CvPolyEdge *te = last->next;
/* swap edges */
if( last->x > te->x )
{
prelast->next = te;
last->next = te->next;
te->next = last;
prelast = te;
sort_flag = 1;
}
else
{
prelast = last;
last = te;
}
}
keep_prelast = prelast;
}
while( sort_flag && keep_prelast != tmp.next && keep_prelast != &tmp );
}
__END__;
}
/* draws simple or filled circle */
static void
icvCircle( CvMat* img, CvPoint center, int radius, const void* color, int fill )
{
CvSize size = cvGetMatSize( img );
int step = img->step;
int pix_size = icvPixSize[CV_MAT_TYPE(img->type)];
uchar* ptr = (uchar*)(img->data.ptr);
int err = 0, dx = radius, dy = 0, plus = 1, minus = (radius << 1) - 1;
int inside = center.x >= radius && center.x < size.width - radius &&
center.y >= radius && center.y < size.height - radius;
#define ICV_PUT_POINT( ptr, x ) \
CV_MEMCPY_CHAR( ptr + (x)*pix_size, color, pix_size );
while( dx >= dy )
{
int mask;
int y11 = center.y - dy, y12 = center.y + dy, y21 = center.y - dx, y22 = center.y + dx;
int x11 = center.x - dx, x12 = center.x + dx, x21 = center.x - dy, x22 = center.x + dy;
if( inside )
{
uchar *tptr0 = ptr + y11 * step;
uchar *tptr1 = ptr + y12 * step;
if( !fill )
{
ICV_PUT_POINT( tptr0, x11 );
ICV_PUT_POINT( tptr1, x11 );
ICV_PUT_POINT( tptr0, x12 );
ICV_PUT_POINT( tptr1, x12 );
}
else
{
ICV_HLINE( tptr0, x11, x12, color, pix_size );
ICV_HLINE( tptr1, x11, x12, color, pix_size );
}
tptr0 = ptr + y21 * step;
tptr1 = ptr + y22 * step;
if( !fill )
{
ICV_PUT_POINT( tptr0, x21 );
ICV_PUT_POINT( tptr1, x21 );
ICV_PUT_POINT( tptr0, x22 );
ICV_PUT_POINT( tptr1, x22 );
}
else
{
ICV_HLINE( tptr0, x21, x22, color, pix_size );
ICV_HLINE( tptr1, x21, x22, color, pix_size );
}
}
else if( x11 < size.width && x12 >= 0 && y21 < size.height && y22 >= 0 )
{
if( fill )
{
x11 = MAX( x11, 0 );
x12 = MIN( x12, size.width - 1 );
}
if( (unsigned)y11 < (unsigned)size.height )
{
uchar *tptr = ptr + y11 * step;
if( !fill )
{
if( x11 >= 0 )
ICV_PUT_POINT( tptr, x11 );
if( x12 < size.width )
ICV_PUT_POINT( tptr, x12 );
}
else
ICV_HLINE( tptr, x11, x12, color, pix_size );
}
if( (unsigned)y12 < (unsigned)size.height )
{
uchar *tptr = ptr + y12 * step;
if( !fill )
{
if( x11 >= 0 )
ICV_PUT_POINT( tptr, x11 );
if( x12 < size.width )
ICV_PUT_POINT( tptr, x12 );
}
else
ICV_HLINE( tptr, x11, x12, color, pix_size );
}
if( x21 < size.width && x22 >= 0 )
{
if( fill )
{
x21 = MAX( x21, 0 );
x22 = MIN( x22, size.width - 1 );
}
if( (unsigned)y21 < (unsigned)size.height )
{
uchar *tptr = ptr + y21 * step;
if( !fill )
{
if( x21 >= 0 )
ICV_PUT_POINT( tptr, x21 );
if( x22 < size.width )
ICV_PUT_POINT( tptr, x22 );
}
else
ICV_HLINE( tptr, x21, x22, color, pix_size );
}
if( (unsigned)y22 < (unsigned)size.height )
{
uchar *tptr = ptr + y22 * step;
if( !fill )
{
if( x21 >= 0 )
ICV_PUT_POINT( tptr, x21 );
if( x22 < size.width )
ICV_PUT_POINT( tptr, x22 );
}
else
ICV_HLINE( tptr, x21, x22, color, pix_size );
}
}
}
dy++;
err += plus;
plus += 2;
mask = (err <= 0) - 1;
err -= minus & mask;
dx += mask;
minus -= mask & 2;
}
#undef ICV_PUT_POINT
}
static void
icvThickLine( CvMat* img, CvPoint p0, CvPoint p1, const void* color,
int thickness, int line_type, int flags, int shift )
{
static const double INV_XY_ONE = 1./XY_ONE;
p0.x <<= XY_SHIFT - shift;
p0.y <<= XY_SHIFT - shift;
p1.x <<= XY_SHIFT - shift;
p1.y <<= XY_SHIFT - shift;
if( thickness <= 1 )
{
if( line_type < CV_AA )
{
if( line_type == 1 || line_type == 4 || shift == 0 )
{
p0.x = (p0.x + (XY_ONE>>1)) >> XY_SHIFT;
p0.y = (p0.y + (XY_ONE>>1)) >> XY_SHIFT;
p1.x = (p1.x + (XY_ONE>>1)) >> XY_SHIFT;
p1.y = (p1.y + (XY_ONE>>1)) >> XY_SHIFT;
icvLine( img, p0, p1, color, line_type );
}
else
icvLine2( img, p0, p1, color );
}
else
icvLineAA( img, p0, p1, color );
}
else
{
CvPoint pt[4], dp = {0,0};
double dx = (p0.x - p1.x)*INV_XY_ONE, dy = (p1.y - p0.y)*INV_XY_ONE;
double r = dx * dx + dy * dy;
int i;
thickness <<= XY_SHIFT - 1;
if( fabs(r) > DBL_EPSILON )
{
r = thickness * cvInvSqrt( (float) r );
dp.x = cvRound( dy * r );
dp.y = cvRound( dx * r );
}
pt[0].x = p0.x + dp.x;
pt[0].y = p0.y + dp.y;
pt[1].x = p0.x - dp.x;
pt[1].y = p0.y - dp.y;
pt[2].x = p1.x - dp.x;
pt[2].y = p1.y - dp.y;
pt[3].x = p1.x + dp.x;
pt[3].y = p1.y + dp.y;
icvFillConvexPoly( img, pt, 4, color, line_type, XY_SHIFT );
for( i = 0; i < 2; i++ )
{
if( flags & (i+1) )
{
if( line_type < CV_AA )
{
CvPoint center;
center.x = (p0.x + (XY_ONE>>1)) >> XY_SHIFT;
center.y = (p0.y + (XY_ONE>>1)) >> XY_SHIFT;
icvCircle( img, center, thickness >> XY_SHIFT, color, 1 );
}
else
{
icvEllipseEx( img, p0, cvSize(thickness, thickness),
0, 0, 360, color, -1, line_type );
}
}
p0 = p1;
}
}
}
static void
icvPolyLine( CvMat* img, CvPoint *v, int count, int is_closed,
const void* color, int thickness,
int line_type, int shift )
{
CV_FUNCNAME("icvPolyLine");
__BEGIN__;
if( count > 0 )
{
int i = is_closed ? count - 1 : 0;
int flags = 2 + !is_closed;
CvPoint p0;
assert( 0 <= shift && shift <= XY_SHIFT );
assert( img && thickness >= 0 );
assert( v && count >= 0 );
if( !v )
CV_ERROR( CV_StsNullPtr, "" );
p0 = v[i];
for( i = !is_closed; i < count; i++ )
{
CvPoint p = v[i];
icvThickLine( img, p0, p, color, thickness, line_type, flags, shift );
p0 = p;
flags = 2;
}
}
__END__;
}
/****************************************************************************************\
* External functions *
\****************************************************************************************/
CV_IMPL CvScalar cvColorToScalar( double packed_color, int type )
{
CvScalar scalar;
if( CV_MAT_DEPTH( type ) == CV_8U )
{
int icolor = cvRound( packed_color );
if( CV_MAT_CN( type ) > 1 )
{
scalar.val[0] = icolor & 255;
scalar.val[1] = (icolor >> 8) & 255;
scalar.val[2] = (icolor >> 16) & 255;
scalar.val[3] = (icolor >> 24) & 255;
}
else
{
scalar.val[0] = CV_CAST_8U( icolor );
scalar.val[1] = scalar.val[2] = scalar.val[3] = 0;
}
}
else if( CV_MAT_DEPTH( type ) == CV_8S )
{
int icolor = cvRound( packed_color );
if( CV_MAT_CN( type ) > 1 )
{
scalar.val[0] = (char)icolor;
scalar.val[1] = (char)(icolor >> 8);
scalar.val[2] = (char)(icolor >> 16);
scalar.val[3] = (char)(icolor >> 24);
}
else
{
scalar.val[0] = CV_CAST_8S( icolor );
scalar.val[1] = scalar.val[2] = scalar.val[3] = 0;
}
}
else
{
int cn = CV_MAT_CN( type );
switch( cn )
{
case 1:
scalar.val[0] = packed_color;
scalar.val[1] = scalar.val[2] = scalar.val[3] = 0;
break;
case 2:
scalar.val[0] = scalar.val[1] = packed_color;
scalar.val[2] = scalar.val[3] = 0;
break;
case 3:
scalar.val[0] = scalar.val[1] = scalar.val[2] = packed_color;
scalar.val[3] = 0;
break;
default:
scalar.val[0] = scalar.val[1] =
scalar.val[2] = scalar.val[3] = packed_color;
break;
}
}
return scalar;
}
CV_IMPL void
cvLine( void* img, CvPoint pt1, CvPoint pt2, CvScalar color,
int thickness, int line_type, int shift )
{
CV_FUNCNAME( "cvLine" );
__BEGIN__;
int coi = 0;
CvMat stub, *mat = (CvMat*)img;
double buf[4];
CV_CALL( mat = cvGetMat( img, &stub, &coi ));
if( line_type == CV_AA && CV_MAT_DEPTH(mat->type) != CV_8U )
line_type = 8;
if( coi != 0 )
CV_ERROR( CV_BadCOI, cvUnsupportedFormat );
if( (unsigned)thickness > 255 )
CV_ERROR( CV_StsOutOfRange, "" );
if( shift < 0 || XY_SHIFT < shift )
CV_ERROR( CV_StsOutOfRange, "shift must be between 0 and 16" );
CV_CALL( cvScalarToRawData( &color, buf, mat->type, 0 ));
icvThickLine( mat, pt1, pt2, buf, thickness, line_type, 3, shift );
__END__;
}
CV_IMPL void
cvRectangle( void* img, CvPoint pt1, CvPoint pt2,
CvScalar color, int thickness,
int line_type, int shift )
{
CvPoint pt[4];
CV_FUNCNAME("cvRectangle");
__BEGIN__;
int coi = 0;
CvMat stub, *mat = (CvMat*)img;
double buf[4];
if( thickness < -1 || thickness > 255 )
CV_ERROR( CV_StsOutOfRange, "" );
CV_CALL( mat = cvGetMat( img, &stub, &coi ));
if( line_type == CV_AA && CV_MAT_DEPTH(mat->type) != CV_8U )
line_type = 8;
if( coi != 0 )
CV_ERROR( CV_BadCOI, cvUnsupportedFormat );
if( shift < 0 || XY_SHIFT < shift )
CV_ERROR( CV_StsOutOfRange, "shift must be between 0 and 16" );
CV_CALL( cvScalarToRawData( &color, buf, mat->type, 0 ));
pt[0] = pt1;
pt[1].x = pt2.x;
pt[1].y = pt1.y;
pt[2] = pt2;
pt[3].x = pt1.x;
pt[3].y = pt2.y;
if( thickness >= 0 )
icvPolyLine( mat, pt, 4, 1, buf, thickness, line_type, shift );
else
icvFillConvexPoly( mat, pt, 4, buf, line_type, shift );
__END__;
}
CV_IMPL void
cvCircle( void *img, CvPoint center, int radius,
CvScalar color, int thickness, int line_type, int shift )
{
CV_FUNCNAME( "cvCircle" );
__BEGIN__;
int coi = 0;
CvMat stub, *mat = (CvMat*)img;
double buf[4];
CV_CALL( mat = cvGetMat( mat, &stub, &coi ));
if( line_type == CV_AA && CV_MAT_DEPTH(mat->type) != CV_8U )
line_type = 8;
if( coi != 0 )
CV_ERROR( CV_BadCOI, cvUnsupportedFormat );
if( radius < 0 )
CV_ERROR( CV_StsOutOfRange, "" );
if( thickness < -1 || thickness > 255 )
CV_ERROR( CV_StsOutOfRange, "" );
if( shift < 0 || XY_SHIFT < shift )
CV_ERROR( CV_StsOutOfRange, "shift must be between 0 and 16" );
CV_CALL( cvScalarToRawData( &color, buf, mat->type, 0 ));
if( thickness > 1 || line_type >= CV_AA )
{
center.x <<= XY_SHIFT - shift;
center.y <<= XY_SHIFT - shift;
radius <<= XY_SHIFT - shift;
icvEllipseEx( mat, center, cvSize( radius, radius ),
0, 0, 360, buf, thickness, line_type );
}
else
{
icvCircle( mat, center, radius, buf, thickness < 0 );
}
__END__;
}
CV_IMPL void
cvEllipse( void *img, CvPoint center, CvSize axes,
double angle, double start_angle, double end_angle,
CvScalar color, int thickness, int line_type, int shift )
{
CV_FUNCNAME( "cvEllipse" );
__BEGIN__;
int coi = 0;
CvMat stub, *mat = (CvMat*)img;
double buf[4];
CV_CALL( mat = cvGetMat( mat, &stub, &coi ));
if( line_type == CV_AA && CV_MAT_DEPTH(mat->type) != CV_8U )
line_type = 8;
if( coi != 0 )
CV_ERROR( CV_BadCOI, cvUnsupportedFormat );
if( axes.width < 0 || axes.height < 0 )
CV_ERROR( CV_StsOutOfRange, "" );
if( thickness < -1 || thickness > 255 )
CV_ERROR( CV_StsOutOfRange, "" );
if( shift < 0 || XY_SHIFT < shift )
CV_ERROR( CV_StsOutOfRange, "shift must be between 0 and 16" );
CV_CALL( cvScalarToRawData( &color, buf, mat->type, 0 ));
{
int _angle = cvRound(angle);
int _start_angle = cvRound(start_angle);
int _end_angle = cvRound(end_angle);
center.x <<= XY_SHIFT - shift;
center.y <<= XY_SHIFT - shift;
axes.width <<= XY_SHIFT - shift;
axes.height <<= XY_SHIFT - shift;
CV_CALL( icvEllipseEx( mat, center, axes, _angle, _start_angle,
_end_angle, buf, thickness, line_type ));
}
__END__;
}
CV_IMPL void
cvFillConvexPoly( void *img, CvPoint *pts, int npts, CvScalar color, int line_type, int shift )
{
CV_FUNCNAME( "cvFillConvexPoly" );
__BEGIN__;
int coi = 0;
CvMat stub, *mat = (CvMat*)img;
double buf[4];
CV_CALL( mat = cvGetMat( mat, &stub, &coi ));
if( line_type == CV_AA && CV_MAT_DEPTH(mat->type) != CV_8U )
line_type = 8;
if( coi != 0 )
CV_ERROR( CV_BadCOI, cvUnsupportedFormat );
if( !pts )
CV_ERROR( CV_StsNullPtr, "" );
if( npts <= 0 )
CV_ERROR( CV_StsOutOfRange, "" );
if( shift < 0 || XY_SHIFT < shift )
CV_ERROR( CV_StsOutOfRange, "shift must be between 0 and 16" );
CV_CALL( cvScalarToRawData( &color, buf, mat->type, 0 ));
icvFillConvexPoly( mat, pts, npts, buf, line_type, shift );
__END__;
}
CV_IMPL void
cvFillPoly( void *img, CvPoint **pts, int *npts, int contours,
CvScalar color, int line_type, int shift )
{
CvMemStorage* st = 0;
CV_FUNCNAME( "cvFillPoly" );
__BEGIN__;
int coi = 0;
CvMat stub, *mat = (CvMat*)img;
double buf[4];
CV_CALL( mat = cvGetMat( mat, &stub, &coi ));
if( line_type == CV_AA && CV_MAT_DEPTH(mat->type) != CV_8U )
line_type = 8;
if( coi != 0 )
CV_ERROR( CV_BadCOI, cvUnsupportedFormat );
if( contours <= 0 )
CV_ERROR( CV_StsBadArg, "" );
if( !pts )
CV_ERROR( CV_StsNullPtr, "" );
if( npts <= 0 )
CV_ERROR( CV_StsNullPtr, "" );
if( shift < 0 || XY_SHIFT < shift )
CV_ERROR( CV_StsOutOfRange, "shift must be between 0 and 16" );
CV_CALL( cvScalarToRawData( &color, buf, mat->type, 0 ));
{
CvContour* edges = 0;
CvSeq vtx;
CvSeqBlock block;
CV_CALL( st = cvCreateMemStorage( CV_DRAWING_STORAGE_BLOCK ));
CV_CALL( edges = (CvContour*)cvCreateSeq( 0, sizeof(CvContour),
sizeof(CvPolyEdge), st ));
for( int i = 0; i < contours; i++ )
{
if( !pts[i] )
CV_ERROR( CV_StsNullPtr, "" );
if( npts[i] < 0 )
CV_ERROR( CV_StsOutOfRange, "" );
cvMakeSeqHeaderForArray( CV_32SC2, sizeof(CvSeq), sizeof(CvPoint),
pts[i], npts[i], &vtx, &block );
CV_CALL( icvCollectPolyEdges( mat, &vtx, edges, buf, line_type, shift ));
}
CV_CALL( icvFillEdgeCollection( mat, edges, buf ));
}
__END__;
cvReleaseMemStorage( &st );
}
CV_IMPL void
cvPolyLine( void *img, CvPoint **pts, int *npts,
int contours, int closed, CvScalar color,
int thickness, int line_type, int shift )
{
CV_FUNCNAME( "cvPolyLine" );
__BEGIN__;
int coi = 0, i;
CvMat stub, *mat = (CvMat*)img;
double buf[4];
CV_CALL( mat = cvGetMat( mat, &stub, &coi ));
if( line_type == CV_AA && CV_MAT_DEPTH(mat->type) != CV_8U )
line_type = 8;
if( coi != 0 )
CV_ERROR( CV_BadCOI, cvUnsupportedFormat );
if( contours <= 0 )
CV_ERROR( CV_StsBadArg, "" );
if( thickness < -1 || thickness > 255 )
CV_ERROR( CV_StsBadArg, "" );
if( !pts )
CV_ERROR( CV_StsNullPtr, "" );
if( npts <= 0 )
CV_ERROR( CV_StsNullPtr, "" );
if( shift < 0 || XY_SHIFT < shift )
CV_ERROR( CV_StsOutOfRange, "shift must be between 0 and 16" );
CV_CALL( cvScalarToRawData( &color, buf, mat->type, 0 ));
for( i = 0; i < contours; i++ )
icvPolyLine( mat, pts[i], npts[i], closed, buf, thickness, line_type, shift );
__END__;
}
#define CV_FONT_SIZE_SHIFT 8
#define CV_FONT_ITALIC_ALPHA (1 << 8)
#define CV_FONT_ITALIC_DIGIT (2 << 8)
#define CV_FONT_ITALIC_PUNCT (4 << 8)
#define CV_FONT_ITALIC_BRACES (8 << 8)
#define CV_FONT_HAVE_GREEK (16 << 8)
#define CV_FONT_HAVE_CYRILLIC (32 << 8)
static const int icvHersheyPlain[] = {
(5 + 4*16) + CV_FONT_HAVE_GREEK,
199, 214, 217, 233, 219, 197, 234, 216, 221, 222, 228, 225, 211, 224, 210, 220,
200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 212, 213, 191, 226, 192,
215, 190, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13,
14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 193, 84,
194, 85, 86, 87, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111,
112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126,
195, 223, 196, 88 };
static const int icvHersheyPlainItalic[] = {
(5 + 4*16) + CV_FONT_ITALIC_ALPHA + CV_FONT_HAVE_GREEK,
199, 214, 217, 233, 219, 197, 234, 216, 221, 222, 228, 225, 211, 224, 210, 220,
200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 212, 213, 191, 226, 192,
215, 190, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63,
64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 193, 84,
194, 85, 86, 87, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161,
162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176,
195, 223, 196, 88 };
static const int icvHersheyComplexSmall[] = {
(6 + 7*16) + CV_FONT_HAVE_GREEK,
1199, 1214, 1217, 1275, 1274, 1271, 1272, 1216, 1221, 1222, 1219, 1232, 1211, 1231, 1210, 1220,
1200, 1201, 1202, 1203, 1204, 1205, 1206, 1207, 1208, 1209, 1212, 2213, 1241, 1238, 1242,
1215, 1273, 1001, 1002, 1003, 1004, 1005, 1006, 1007, 1008, 1009, 1010, 1011, 1012, 1013,
1014, 1015, 1016, 1017, 1018, 1019, 1020, 1021, 1022, 1023, 1024, 1025, 1026, 1223, 1084,
1224, 1247, 586, 1249, 1101, 1102, 1103, 1104, 1105, 1106, 1107, 1108, 1109, 1110, 1111,
1112, 1113, 1114, 1115, 1116, 1117, 1118, 1119, 1120, 1121, 1122, 1123, 1124, 1125, 1126,
1225, 1229, 1226, 1246 };
static const int icvHersheyComplexSmallItalic[] = {
(6 + 7*16) + CV_FONT_ITALIC_ALPHA + CV_FONT_HAVE_GREEK,
1199, 1214, 1217, 1275, 1274, 1271, 1272, 1216, 1221, 1222, 1219, 1232, 1211, 1231, 1210, 1220,
1200, 1201, 1202, 1203, 1204, 1205, 1206, 1207, 1208, 1209, 1212, 1213, 1241, 1238, 1242,
1215, 1273, 1051, 1052, 1053, 1054, 1055, 1056, 1057, 1058, 1059, 1060, 1061, 1062, 1063,
1064, 1065, 1066, 1067, 1068, 1069, 1070, 1071, 1072, 1073, 1074, 1075, 1076, 1223, 1084,
1224, 1247, 586, 1249, 1151, 1152, 1153, 1154, 1155, 1156, 1157, 1158, 1159, 1160, 1161,
1162, 1163, 1164, 1165, 1166, 1167, 1168, 1169, 1170, 1171, 1172, 1173, 1174, 1175, 1176,
1225, 1229, 1226, 1246 };
static const int icvHersheySimplex[] = {
(9 + 12*16) + CV_FONT_HAVE_GREEK,
2199, 714, 717, 733, 719, 697, 734, 716, 721, 722, 728, 725, 711, 724, 710, 720,
700, 701, 702, 703, 704, 705, 706, 707, 708, 709, 712, 713, 691, 726, 692,
715, 690, 501, 502, 503, 504, 505, 506, 507, 508, 509, 510, 511, 512, 513,
514, 515, 516, 517, 518, 519, 520, 521, 522, 523, 524, 525, 526, 693, 584,
694, 2247, 586, 2249, 601, 602, 603, 604, 605, 606, 607, 608, 609, 610, 611,
612, 613, 614, 615, 616, 617, 618, 619, 620, 621, 622, 623, 624, 625, 626,
695, 723, 696, 2246 };
static const int icvHersheyDuplex[] = {
(9 + 12*16) + CV_FONT_HAVE_GREEK,
2199, 2714, 2728, 2732, 2719, 2733, 2718, 2727, 2721, 2722, 2723, 2725, 2711, 2724, 2710, 2720,
2700, 2701, 2702, 2703, 2704, 2705, 2706, 2707, 2708, 2709, 2712, 2713, 2730, 2726, 2731,
2715, 2734, 2501, 2502, 2503, 2504, 2505, 2506, 2507, 2508, 2509, 2510, 2511, 2512, 2513,
2514, 2515, 2516, 2517, 2518, 2519, 2520, 2521, 2522, 2523, 2524, 2525, 2526, 2223, 2084,
2224, 2247, 587, 2249, 2601, 2602, 2603, 2604, 2605, 2606, 2607, 2608, 2609, 2610, 2611,
2612, 2613, 2614, 2615, 2616, 2617, 2618, 2619, 2620, 2621, 2622, 2623, 2624, 2625, 2626,
2225, 2229, 2226, 2246 };
static const int icvHersheyComplex[] = {
(9 + 12*16) + CV_FONT_HAVE_GREEK + CV_FONT_HAVE_CYRILLIC,
2199, 2214, 2217, 2275, 2274, 2271, 2272, 2216, 2221, 2222, 2219, 2232, 2211, 2231, 2210, 2220,
2200, 2201, 2202, 2203, 2204, 2205, 2206, 2207, 2208, 2209, 2212, 2213, 2241, 2238, 2242,
2215, 2273, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013,
2014, 2015, 2016, 2017, 2018, 2019, 2020, 2021, 2022, 2023, 2024, 2025, 2026, 2223, 2084,
2224, 2247, 587, 2249, 2101, 2102, 2103, 2104, 2105, 2106, 2107, 2108, 2109, 2110, 2111,
2112, 2113, 2114, 2115, 2116, 2117, 2118, 2119, 2120, 2121, 2122, 2123, 2124, 2125, 2126,
2225, 2229, 2226, 2246 };
static const int icvHersheyComplexItalic[] = {
(9 + 12*16) + CV_FONT_ITALIC_ALPHA + CV_FONT_ITALIC_DIGIT + CV_FONT_ITALIC_PUNCT +
CV_FONT_HAVE_GREEK + CV_FONT_HAVE_CYRILLIC,
2199, 2764, 2778, 2782, 2769, 2783, 2768, 2777, 2771, 2772, 2219, 2232, 2211, 2231, 2210, 2220,
2750, 2751, 2752, 2753, 2754, 2755, 2756, 2757, 2758, 2759, 2212, 2213, 2241, 2238, 2242,
2765, 2273, 2051, 2052, 2053, 2054, 2055, 2056, 2057, 2058, 2059, 2060, 2061, 2062, 2063,
2064, 2065, 2066, 2067, 2068, 2069, 2070, 2071, 2072, 2073, 2074, 2075, 2076, 2223, 2084,
2224, 2247, 587, 2249, 2151, 2152, 2153, 2154, 2155, 2156, 2157, 2158, 2159, 2160, 2161,
2162, 2163, 2164, 2165, 2166, 2167, 2168, 2169, 2170, 2171, 2172, 2173, 2174, 2175, 2176,
2225, 2229, 2226, 2246 };
static const int icvHersheyTriplex[] = {
(9 + 12*16) + CV_FONT_HAVE_GREEK,
2199, 3214, 3228, 3232, 3219, 3233, 3218, 3227, 3221, 3222, 3223, 3225, 3211, 3224, 3210, 3220,
3200, 3201, 3202, 3203, 3204, 3205, 3206, 3207, 3208, 3209, 3212, 3213, 3230, 3226, 3231,
3215, 3234, 3001, 3002, 3003, 3004, 3005, 3006, 3007, 3008, 3009, 3010, 3011, 3012, 3013,
2014, 3015, 3016, 3017, 3018, 3019, 3020, 3021, 3022, 3023, 3024, 3025, 3026, 2223, 2084,
2224, 2247, 587, 2249, 3101, 3102, 3103, 3104, 3105, 3106, 3107, 3108, 3109, 3110, 3111,
3112, 3113, 3114, 3115, 3116, 3117, 3118, 3119, 3120, 3121, 3122, 3123, 3124, 3125, 3126,
2225, 2229, 2226, 2246 };
static const int icvHersheyTriplexItalic[] = {
(9 + 12*16) + CV_FONT_ITALIC_ALPHA + CV_FONT_ITALIC_DIGIT +
CV_FONT_ITALIC_PUNCT + CV_FONT_HAVE_GREEK,
2199, 3264, 3278, 3282, 3269, 3233, 3268, 3277, 3271, 3272, 3223, 3225, 3261, 3224, 3260, 3270,
3250, 3251, 3252, 3253, 3254, 3255, 3256, 3257, 3258, 3259, 3262, 3263, 3230, 3226, 3231,
3265, 3234, 3051, 3052, 3053, 3054, 3055, 3056, 3057, 3058, 3059, 3060, 3061, 3062, 3063,
2064, 3065, 3066, 3067, 3068, 3069, 3070, 3071, 3072, 3073, 3074, 3075, 3076, 2223, 2084,
2224, 2247, 587, 2249, 3151, 3152, 3153, 3154, 3155, 3156, 3157, 3158, 3159, 3160, 3161,
3162, 3163, 3164, 3165, 3166, 3167, 3168, 3169, 3170, 3171, 3172, 3173, 3174, 3175, 3176,
2225, 2229, 2226, 2246 };
static const int icvHersheyScriptSimplex[] = {
(9 + 12*16) + CV_FONT_ITALIC_ALPHA + CV_FONT_HAVE_GREEK,
2199, 714, 717, 733, 719, 697, 734, 716, 721, 722, 728, 725, 711, 724, 710, 720,
700, 701, 702, 703, 704, 705, 706, 707, 708, 709, 712, 713, 691, 726, 692,
715, 690, 551, 552, 553, 554, 555, 556, 557, 558, 559, 560, 561, 562, 563,
564, 565, 566, 567, 568, 569, 570, 571, 572, 573, 574, 575, 576, 693, 584,
694, 2247, 586, 2249, 651, 652, 653, 654, 655, 656, 657, 658, 659, 660, 661,
662, 663, 664, 665, 666, 667, 668, 669, 670, 671, 672, 673, 674, 675, 676,
695, 723, 696, 2246 };
static const int icvHersheyScriptComplex[] = {
(9 + 12*16) + CV_FONT_ITALIC_ALPHA + CV_FONT_ITALIC_DIGIT + CV_FONT_ITALIC_PUNCT + CV_FONT_HAVE_GREEK,
2199, 2764, 2778, 2782, 2769, 2783, 2768, 2777, 2771, 2772, 2219, 2232, 2211, 2231, 2210, 2220,
2750, 2751, 2752, 2753, 2754, 2755, 2756, 2757, 2758, 2759, 2212, 2213, 2241, 2238, 2242,
2215, 2273, 2551, 2552, 2553, 2554, 2555, 2556, 2557, 2558, 2559, 2560, 2561, 2562, 2563,
2564, 2565, 2566, 2567, 2568, 2569, 2570, 2571, 2572, 2573, 2574, 2575, 2576, 2223, 2084,
2224, 2247, 586, 2249, 2651, 2652, 2653, 2654, 2655, 2656, 2657, 2658, 2659, 2660, 2661,
2662, 2663, 2664, 2665, 2666, 2667, 2668, 2669, 2670, 2671, 2672, 2673, 2674, 2675, 2676,
2225, 2229, 2226, 2246 };
CV_IMPL void
cvPutText( void *img, const char *text, CvPoint org, const CvFont *font, CvScalar color )
{
CV_FUNCNAME( "cvPutText" );
__BEGIN__;
int view_x, view_y;
int coi = 0;
int top_bottom = 0, base_line;
int hscale, vscale, default_shear, italic_shear;
int thickness, line_type;
CvMat stub, *mat = (CvMat*)img;
double buf[4];
CvPoint pt[1 << 10];
int count;
int i;
const char **faces = icvHersheyGlyphs;
CV_CALL( mat = cvGetMat( mat, &stub, &coi ));
if( coi != 0 )
CV_ERROR( CV_BadCOI, cvUnsupportedFormat );
if( CV_IS_IMAGE_HDR(img) && ((IplImage*)img)->origin )
top_bottom = 1;
if( !text || !font || !font->ascii )
CV_ERROR( CV_StsNullPtr, "" );
CV_CALL( cvScalarToRawData( &color, buf, mat->type, 0 ));
base_line = -(font->ascii[0] & 15);
hscale = cvRound(font->hscale*XY_ONE);
vscale = cvRound(font->vscale*XY_ONE);
default_shear = cvRound(font->shear*font->vscale*XY_ONE);
italic_shear = !(font->font_face & CV_FONT_ITALIC) ? 0 : cvRound(font->vscale*.25*XY_ONE);
thickness = font->thickness;
line_type = font->line_type;
if( line_type == CV_AA && CV_MAT_DEPTH(mat->type) != CV_8U )
line_type = 8;
if( top_bottom )
vscale = -vscale;
view_x = org.x << XY_SHIFT;
view_y = (org.y << XY_SHIFT) + base_line*vscale;
for( i = 0; text[i] != '\0'; i++ )
{
int c = (uchar)text[i];
int dx, shear = default_shear;
const char* ptr;
CvPoint p;
if( c > 128 || c < ' ' )
c = '?';
if( italic_shear )
{
if( ('a' <= c && c <= 'z') || ('A' <= c && c <= 'Z'))
{
if( !(font->ascii[0] & CV_FONT_ITALIC_ALPHA) )
shear += italic_shear;
}
else if( '0' <= c && c <= '9' )
{
if( !(font->ascii[0] & CV_FONT_ITALIC_DIGIT) )
shear += italic_shear;
}
else if( c < 'A' )
{
if( !(font->ascii[0] & CV_FONT_ITALIC_PUNCT) )
shear += italic_shear;
}
else
{
shear += italic_shear;
}
}
ptr = faces[font->ascii[(c-' ')+1]];
p.x = (unsigned char)ptr[0] - 'R';
p.y = (unsigned char)ptr[1] - 'R';
dx = p.y*hscale;
view_x -= p.x*hscale;
count = 0;
for( ptr += 2;; )
{
if( *ptr == ' ' || !*ptr )
{
if( count > 1 )
icvPolyLine( mat, pt, count, 0, buf, thickness, line_type, XY_SHIFT );
if( !*ptr++ )
break;
count = 0;
}
else
{
p.x = (unsigned char)ptr[0] - 'R';
p.y = (unsigned char)ptr[1] - 'R';
ptr += 2;
pt[count].x = p.x*hscale - p.y*shear + view_x;
pt[count++].y = p.y*vscale + view_y;
}
}
view_x += dx;
}
__END__;
}
CV_IMPL void
cvInitFont( CvFont *font, int font_face, double hscale, double vscale,
double shear, int thickness, int line_type )
{
CV_FUNCNAME( "cvInitFont" );
__BEGIN__;
int is_italic = font_face & CV_FONT_ITALIC;
if( !font )
CV_ERROR( CV_StsNullPtr, "" );
if( hscale <= 0 || vscale <= 0 || thickness < 0 )
CV_ERROR( CV_StsOutOfRange, "" );
switch( (font_face & 7) )
{
case CV_FONT_HERSHEY_SIMPLEX:
font->ascii = icvHersheySimplex;
break;
case CV_FONT_HERSHEY_PLAIN:
font->ascii = !is_italic ? icvHersheyPlain : icvHersheyPlainItalic;
break;
case CV_FONT_HERSHEY_DUPLEX:
font->ascii = icvHersheyDuplex;
break;
case CV_FONT_HERSHEY_COMPLEX:
font->ascii = !is_italic ? icvHersheyComplex : icvHersheyComplexItalic;
break;
case CV_FONT_HERSHEY_TRIPLEX:
font->ascii = !is_italic ? icvHersheyTriplex : icvHersheyTriplexItalic;
break;
case CV_FONT_HERSHEY_COMPLEX_SMALL:
font->ascii = !is_italic ? icvHersheyComplexSmall : icvHersheyComplexSmallItalic;
break;
case CV_FONT_HERSHEY_SCRIPT_SIMPLEX:
font->ascii = icvHersheyScriptSimplex;
break;
case CV_FONT_HERSHEY_SCRIPT_COMPLEX:
font->ascii = icvHersheyScriptComplex;
break;
default:
CV_ERROR( CV_StsOutOfRange, "Unknown font type" );
}
font->font_face = font_face;
font->hscale = (float)hscale;
font->vscale = (float)vscale;
font->thickness = thickness;
font->shear = (float)shear;
font->greek = font->cyrillic = 0;
font->line_type = line_type;
__END__;
}
CV_IMPL void
cvGetTextSize( const char *text, const CvFont *font, CvSize *size, int *_base_line )
{
CV_FUNCNAME( "cvGetTextSize" );
__BEGIN__;
float view_x = 0;
int base_line, cap_line;
int i;
const char **faces = icvHersheyGlyphs;
if( !text || !font || !font->ascii || !size )
CV_ERROR( CV_StsNullPtr, "" );
base_line = (font->ascii[0] & 15);
cap_line = (font->ascii[0] >> 4) & 15;
if( _base_line )
*_base_line = cvRound(base_line*font->vscale);
size->height = cvRound((cap_line + base_line)*font->vscale + font->thickness);
for( i = 0; text[i] != '\0'; i++ )
{
int c = (uchar)text[i];
const char* ptr;
CvPoint p;
if( c > 128 || c < ' ' )
c = '?';
ptr = faces[font->ascii[(c-' ')+1]];
p.x = (unsigned char)ptr[0] - 'R';
p.y = (unsigned char)ptr[1] - 'R';
view_x += (p.y - p.x)*font->hscale;
}
size->width = cvRound(view_x + font->thickness);
__END__;
}
static const CvPoint icvCodeDeltas[8] =
{ {1, 0}, {1, -1}, {0, -1}, {-1, -1}, {-1, 0}, {-1, 1}, {0, 1}, {1, 1} };
#define CV_ADJUST_EDGE_COUNT( count, seq ) \
((count) -= ((count) == (seq)->total && !CV_IS_SEQ_CLOSED(seq)))
CV_IMPL void
cvDrawContours( void* img, CvSeq* contour,
CvScalar externalColor, CvScalar holeColor,
int maxLevel, int thickness,
int line_type, CvPoint offset )
{
CvSeq *contour0 = contour, *h_next = 0;
CvMemStorage* st = 0;
CvSeq* tseq = 0;
CvContour* edges = 0;
CvSeqWriter writer;
CvTreeNodeIterator iterator;
CV_FUNCNAME( "cvDrawContours" );
__BEGIN__;
int coi = 0;
CvMat stub, *mat = (CvMat*)img;
double ext_buf[4], hole_buf[4];
CV_CALL( mat = cvGetMat( mat, &stub, &coi ));
if( line_type == CV_AA && CV_MAT_DEPTH(mat->type) != CV_8U )
line_type = 8;
if( !contour )
EXIT;
if( coi != 0 )
CV_ERROR( CV_BadCOI, cvUnsupportedFormat );
if( thickness < -1 || thickness > 255 )
CV_ERROR( CV_StsOutOfRange, "" );
CV_CALL( cvScalarToRawData( &externalColor, ext_buf, mat->type, 0 ));
CV_CALL( cvScalarToRawData( &holeColor, hole_buf, mat->type, 0 ));
if( maxLevel < 0 )
{
h_next = contour->h_next;
contour->h_next = 0;
maxLevel = -maxLevel+1;
}
if( thickness < 0 )
{
if( contour->storage )
st = cvCreateChildMemStorage( contour->storage );
else
st = cvCreateMemStorage( CV_DRAWING_STORAGE_BLOCK );
tseq = cvCreateSeq( 0, sizeof(CvContour), sizeof(CvPoint), st );
edges = (CvContour*)cvCreateSeq( 0, sizeof(CvContour), sizeof(CvPolyEdge), st );
}
memset( &writer, 0, sizeof(writer));
cvInitTreeNodeIterator( &iterator, contour, maxLevel );
while( (contour = (CvSeq*)cvNextTreeNode( &iterator )) != 0 )
{
CvSeqReader reader;
int i, count = contour->total;
int elem_type = CV_MAT_TYPE(contour->flags);
void* clr = (contour->flags & CV_SEQ_FLAG_HOLE) == 0 ? ext_buf : hole_buf;
cvStartReadSeq( contour, &reader, 0 );
if( CV_IS_SEQ_CHAIN_CONTOUR( contour ))
{
CvPoint pt = ((CvChain*)contour)->origin;
CvPoint prev_pt = pt;
char prev_code = reader.ptr ? reader.ptr[0] : '\0';
if( thickness < 0 )
{
cvClearSeq( tseq );
cvStartAppendToSeq( tseq, &writer );
CV_WRITE_SEQ_ELEM( pt, writer );
}
prev_pt.x += offset.x;
prev_pt.y += offset.y;
for( i = 0; i < count; i++ )
{
char code;
CV_READ_SEQ_ELEM( code, reader );
assert( (code & ~7) == 0 );
if( code != prev_code )
{
prev_code = code;
if( thickness >= 0 )
{
icvThickLine( mat, prev_pt, pt, clr, thickness, line_type, 2, 0 );
}
else
{
CV_WRITE_SEQ_ELEM( pt, writer );
}
prev_pt = pt;
}
pt.x += icvCodeDeltas[(int)code].x;
pt.y += icvCodeDeltas[(int)code].y;
}
if( thickness >= 0 )
{
icvThickLine( mat, prev_pt, ((CvChain*)contour)->origin,
clr, thickness, line_type, 2, 0 );
}
else
{
CV_WRITE_SEQ_ELEM( pt, writer );
cvEndWriteSeq( &writer );
CV_CALL( icvCollectPolyEdges( mat, tseq, edges, ext_buf, line_type, 0 ));
}
}
else if( CV_IS_SEQ_POLYLINE( contour ))
{
if( thickness >= 0 )
{
CvPoint pt1, pt2;
int shift = 0;
count -= !CV_IS_SEQ_CLOSED(contour);
CV_READ_SEQ_ELEM( pt1, reader );
if( elem_type == CV_32SC2 )
{
pt1.x += offset.x;
pt1.y += offset.y;
}
else
{
pt1.x = cvRound( ((float&)pt1.x + offset.x) * XY_ONE );
pt1.y = cvRound( ((float&)pt1.y + offset.y) * XY_ONE );
shift = XY_SHIFT;
}
for( i = 0; i < count; i++ )
{
CV_READ_SEQ_ELEM( pt2, reader );
if( elem_type == CV_32SC2 )
{
pt2.x += offset.x;
pt2.y += offset.y;
}
else
{
pt2.x = cvRound( (float&)pt2.x * XY_ONE );
pt2.y = cvRound( (float&)pt2.y * XY_ONE );
}
icvThickLine( mat, pt1, pt2, clr, thickness, line_type, 2, shift );
pt1 = pt2;
}
}
else
{
CV_CALL( icvCollectPolyEdges( mat, contour, edges, ext_buf, line_type, 0, offset ));
}
}
}
if( thickness < 0 )
{
CV_CALL( icvFillEdgeCollection( mat, edges, ext_buf ));
}
__END__;
if( h_next && contour0 )
contour0->h_next = h_next;
cvReleaseMemStorage( &st );
}
/* End of file. */
| [
"[email protected]"
]
| [
[
[
1,
2588
]
]
]
|
6af822182b27cf158fad15c30a5ce18d2f38a685 | 49f5a108a2ac593b9861f9747bd82eb597b01e24 | /src/JSON/FastDelegate.h | a0208a98a281eb0c2daebf3459ef30ab0975b7d7 | []
| no_license | gpascale/iSynth | 5801b9a1b988303ad77872fad98d4bf76d86e8fe | e45e24590fabb252a5ffd10895b2cddcc988b83d | refs/heads/master | 2021-03-19T06:01:57.451784 | 2010-08-02T02:22:54 | 2010-08-02T02:22:54 | 811,695 | 0 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 96,639 | h | #ifndef FASTDELEGATE_H
#define FASTDELEGATE_H
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#include <memory.h> // to allow <,> comparisons
////////////////////////////////////////////////////////////////////////////////
// Configuration options
//
////////////////////////////////////////////////////////////////////////////////
// Uncomment the next line to allow function declarator syntax.
// It is automatically enabled for those compilers where it is known to work.
//#define FASTDELEGATE_ALLOW_FUNCTION_TYPE_SYNTAX
////////////////////////////////////////////////////////////////////////////////
// Compiler identification for workarounds
//
////////////////////////////////////////////////////////////////////////////////
// Compiler identification. It's not easy to identify Visual C++ because
// many vendors fraudulently define Microsoft's identifiers.
#if defined(_MSC_VER) && !defined(__MWERKS__) && !defined(__VECTOR_C) && !defined(__ICL) && !defined(__BORLANDC__)
#define FASTDLGT_ISMSVC
#if (_MSC_VER <1300) // Many workarounds are required for VC6.
#define FASTDLGT_VC6
#pragma warning(disable:4786) // disable this ridiculous warning
#endif
#endif
// Does the compiler uses Microsoft's member function pointer structure?
// If so, it needs special treatment.
// Metrowerks CodeWarrior, Intel, and CodePlay fraudulently define Microsoft's
// identifier, _MSC_VER. We need to filter Metrowerks out.
#if defined(_MSC_VER) && !defined(__MWERKS__)
#define FASTDLGT_MICROSOFT_MFP
#if !defined(__VECTOR_C)
// CodePlay doesn't have the __single/multi/virtual_inheritance keywords
#define FASTDLGT_HASINHERITANCE_KEYWORDS
#endif
#endif
// Does it allow function declarator syntax? The following compilers are known to work:
#if defined(FASTDLGT_ISMSVC) && (_MSC_VER >=1310) // VC 7.1
#define FASTDELEGATE_ALLOW_FUNCTION_TYPE_SYNTAX
#endif
// Gcc(2.95+), and versions of Digital Mars, Intel and Comeau in common use.
#if defined (__DMC__) || defined(__GNUC__) || defined(__ICL) || defined(__COMO__)
#define FASTDELEGATE_ALLOW_FUNCTION_TYPE_SYNTAX
#endif
// It works on Metrowerks MWCC 3.2.2. From boost.Config it should work on earlier ones too.
#if defined (__MWERKS__)
#define FASTDELEGATE_ALLOW_FUNCTION_TYPE_SYNTAX
#endif
#ifdef __GNUC__ // Workaround GCC bug #8271
// At present, GCC doesn't recognize constness of MFPs in templates
#define FASTDELEGATE_GCC_BUG_8271
#endif
////////////////////////////////////////////////////////////////////////////////
// General tricks used in this code
//
// (a) Error messages are generated by typdefing an array of negative size to
// generate compile-time errors.
// (b) Warning messages on MSVC are generated by declaring unused variables, and
// enabling the "variable XXX is never used" warning.
// (c) Unions are used in a few compiler-specific cases to perform illegal casts.
// (d) For Microsoft and Intel, when adjusting the 'this' pointer, it's cast to
// (char *) first to ensure that the correct number of *bytes* are added.
//
////////////////////////////////////////////////////////////////////////////////
// Helper templates
//
////////////////////////////////////////////////////////////////////////////////
namespace fastdelegate {
namespace detail { // we'll hide the implementation details in a nested namespace.
// implicit_cast< >
// I believe this was originally going to be in the C++ standard but
// was left out by accident. It's even milder than static_cast.
// I use it instead of static_cast<> to emphasize that I'm not doing
// anything nasty.
// Usage is identical to static_cast<>
template <class OutputClass, class InputClass>
inline OutputClass implicit_cast(InputClass input){
return input;
}
// horrible_cast< >
// This is truly evil. It completely subverts C++'s type system, allowing you
// to cast from any class to any other class. Technically, using a union
// to perform the cast is undefined behaviour (even in C). But we can see if
// it is OK by checking that the union is the same size as each of its members.
// horrible_cast<> should only be used for compiler-specific workarounds.
// Usage is identical to reinterpret_cast<>.
// This union is declared outside the horrible_cast because BCC 5.5.1
// can't inline a function with a nested class, and gives a warning.
template <class OutputClass, class InputClass>
union horrible_union{
OutputClass out;
InputClass in;
};
template <class OutputClass, class InputClass>
inline OutputClass horrible_cast(const InputClass input){
horrible_union<OutputClass, InputClass> u;
// Cause a compile-time error if in, out and u are not the same size.
// If the compile fails here, it means the compiler has peculiar
// unions which would prevent the cast from working.
typedef int ERROR_CantUseHorrible_cast[sizeof(InputClass)==sizeof(u)
&& sizeof(InputClass)==sizeof(OutputClass) ? 1 : -1];
u.in = input;
return u.out;
}
////////////////////////////////////////////////////////////////////////////////
// Workarounds
//
////////////////////////////////////////////////////////////////////////////////
// Backwards compatibility: This macro used to be necessary in the virtual inheritance
// case for Intel and Microsoft. Now it just forward-declares the class.
#define FASTDELEGATEDECLARE(CLASSNAME) class CLASSNAME;
// Prevent use of the static function hack with the DOS medium model.
#ifdef __MEDIUM__
#undef FASTDELEGATE_USESTATICFUNCTIONHACK
#endif
// DefaultVoid - a workaround for 'void' templates in VC6.
//
// (1) VC6 and earlier do not allow 'void' as a default template argument.
// (2) They also doesn't allow you to return 'void' from a function.
//
// Workaround for (1): Declare a dummy type 'DefaultVoid' which we use
// when we'd like to use 'void'. We convert it into 'void' and back
// using the templates DefaultVoidToVoid<> and VoidToDefaultVoid<>.
// Workaround for (2): On VC6, the code for calling a void function is
// identical to the code for calling a non-void function in which the
// return value is never used, provided the return value is returned
// in the EAX register, rather than on the stack.
// This is true for most fundamental types such as int, enum, void *.
// Const void * is the safest option since it doesn't participate
// in any automatic conversions. But on a 16-bit compiler it might
// cause extra code to be generated, so we disable it for all compilers
// except for VC6 (and VC5).
#ifdef FASTDLGT_VC6
// VC6 workaround
typedef const void * DefaultVoid;
#else
// On any other compiler, just use a normal void.
typedef void DefaultVoid;
#endif
// Translate from 'DefaultVoid' to 'void'.
// Everything else is unchanged
template <class T>
struct DefaultVoidToVoid { typedef T type; };
template <>
struct DefaultVoidToVoid<DefaultVoid> { typedef void type; };
// Translate from 'void' into 'DefaultVoid'
// Everything else is unchanged
template <class T>
struct VoidToDefaultVoid { typedef T type; };
template <>
struct VoidToDefaultVoid<void> { typedef DefaultVoid type; };
////////////////////////////////////////////////////////////////////////////////
// Fast Delegates, part 1:
//
// Conversion of member function pointer to a standard form
//
////////////////////////////////////////////////////////////////////////////////
// GenericClass is a fake class, ONLY used to provide a type.
// It is vitally important that it is never defined, so that the compiler doesn't
// think it can optimize the invocation. For example, Borland generates simpler
// code if it knows the class only uses single inheritance.
// Compilers using Microsoft's structure need to be treated as a special case.
#ifdef FASTDLGT_MICROSOFT_MFP
#ifdef FASTDLGT_HASINHERITANCE_KEYWORDS
// For Microsoft and Intel, we want to ensure that it's the most efficient type of MFP
// (4 bytes), even when the /vmg option is used. Declaring an empty class
// would give 16 byte pointers in this case....
class __single_inheritance GenericClass;
#endif
// ...but for Codeplay, an empty class *always* gives 4 byte pointers.
// If compiled with the /clr option ("managed C++"), the JIT compiler thinks
// it needs to load GenericClass before it can call any of its functions,
// (compiles OK but crashes at runtime!), so we need to declare an
// empty class to make it happy.
// Codeplay and VC4 can't cope with the unknown_inheritance case either.
class GenericClass {};
#else
class GenericClass;
#endif
// The size of a single inheritance member function pointer.
const int SINGLE_MEMFUNCPTR_SIZE = sizeof(void (GenericClass::*)());
// SimplifyMemFunc< >::Convert()
//
// A template function that converts an arbitrary member function pointer into the
// simplest possible form of member function pointer, using a supplied 'this' pointer.
// According to the standard, this can be done legally with reinterpret_cast<>.
// For (non-standard) compilers which use member function pointers which vary in size
// depending on the class, we need to use knowledge of the internal structure of a
// member function pointer, as used by the compiler. Template specialization is used
// to distinguish between the sizes. Because some compilers don't support partial
// template specialisation, I use full specialisation of a wrapper struct.
// general case -- don't know how to convert it. Force a compile failure
template <int N>
struct SimplifyMemFunc {
template <class X, class XFuncType, class GenericMemFuncType>
inline static GenericClass *Convert(X *pthis, XFuncType function_to_bind,
GenericMemFuncType &bound_func) {
// Unsupported member function type -- force a compile failure.
// (it's illegal to have a array with negative size).
typedef char ERROR_Unsupported_member_function_pointer_on_this_compiler[N-100];
return 0;
}
};
// For compilers where all member func ptrs are the same size, everything goes here.
// For non-standard compilers, only single_inheritance classes go here.
template <>
struct SimplifyMemFunc<SINGLE_MEMFUNCPTR_SIZE> {
template <class X, class XFuncType, class GenericMemFuncType>
inline static GenericClass *Convert(X *pthis, XFuncType function_to_bind,
GenericMemFuncType &bound_func) {
#if defined __DMC__
// Digital Mars doesn't allow you to cast between abitrary PMF's,
// even though the standard says you can. The 32-bit compiler lets you
// static_cast through an int, but the DOS compiler doesn't.
bound_func = horrible_cast<GenericMemFuncType>(function_to_bind);
#else
bound_func = reinterpret_cast<GenericMemFuncType>(function_to_bind);
#endif
return reinterpret_cast<GenericClass *>(pthis);
}
};
////////////////////////////////////////////////////////////////////////////////
// Fast Delegates, part 1b:
//
// Workarounds for Microsoft and Intel
//
////////////////////////////////////////////////////////////////////////////////
// Compilers with member function pointers which violate the standard (MSVC, Intel, Codeplay),
// need to be treated as a special case.
#ifdef FASTDLGT_MICROSOFT_MFP
// We use unions to perform horrible_casts. I would like to use #pragma pack(push, 1)
// at the start of each function for extra safety, but VC6 seems to ICE
// intermittently if you do this inside a template.
// __multiple_inheritance classes go here
// Nasty hack for Microsoft and Intel (IA32 and Itanium)
template<>
struct SimplifyMemFunc< SINGLE_MEMFUNCPTR_SIZE + sizeof(int) > {
template <class X, class XFuncType, class GenericMemFuncType>
inline static GenericClass *Convert(X *pthis, XFuncType function_to_bind,
GenericMemFuncType &bound_func) {
// We need to use a horrible_cast to do this conversion.
// In MSVC, a multiple inheritance member pointer is internally defined as:
union {
XFuncType func;
struct {
GenericMemFuncType funcaddress; // points to the actual member function
int delta; // #BYTES to be added to the 'this' pointer
}s;
} u;
// Check that the horrible_cast will work
typedef int ERROR_CantUsehorrible_cast[sizeof(function_to_bind)==sizeof(u.s)? 1 : -1];
u.func = function_to_bind;
bound_func = u.s.funcaddress;
return reinterpret_cast<GenericClass *>(reinterpret_cast<char *>(pthis) + u.s.delta);
}
};
// virtual inheritance is a real nuisance. It's inefficient and complicated.
// On MSVC and Intel, there isn't enough information in the pointer itself to
// enable conversion to a closure pointer. Earlier versions of this code didn't
// work for all cases, and generated a compile-time error instead.
// But a very clever hack invented by John M. Dlugosz solves this problem.
// My code is somewhat different to his: I have no asm code, and I make no
// assumptions about the calling convention that is used.
// In VC++ and ICL, a virtual_inheritance member pointer
// is internally defined as:
struct MicrosoftVirtualMFP {
void (GenericClass::*codeptr)(); // points to the actual member function
int delta; // #bytes to be added to the 'this' pointer
int vtable_index; // or 0 if no virtual inheritance
};
// The CRUCIAL feature of Microsoft/Intel MFPs which we exploit is that the
// m_codeptr member is *always* called, regardless of the values of the other
// members. (This is *not* true for other compilers, eg GCC, which obtain the
// function address from the vtable if a virtual function is being called).
// Dlugosz's trick is to make the codeptr point to a probe function which
// returns the 'this' pointer that was used.
// Define a generic class that uses virtual inheritance.
// It has a trival member function that returns the value of the 'this' pointer.
struct GenericVirtualClass : virtual public GenericClass
{
typedef GenericVirtualClass * (GenericVirtualClass::*ProbePtrType)();
GenericVirtualClass * GetThis() { return this; }
};
// __virtual_inheritance classes go here
template <>
struct SimplifyMemFunc<SINGLE_MEMFUNCPTR_SIZE + 2*sizeof(int) >
{
template <class X, class XFuncType, class GenericMemFuncType>
inline static GenericClass *Convert(X *pthis, XFuncType function_to_bind,
GenericMemFuncType &bound_func) {
union {
XFuncType func;
GenericClass* (X::*ProbeFunc)();
MicrosoftVirtualMFP s;
} u;
u.func = function_to_bind;
bound_func = reinterpret_cast<GenericMemFuncType>(u.s.codeptr);
union {
GenericVirtualClass::ProbePtrType virtfunc;
MicrosoftVirtualMFP s;
} u2;
// Check that the horrible_cast<>s will work
typedef int ERROR_CantUsehorrible_cast[sizeof(function_to_bind)==sizeof(u.s)
&& sizeof(function_to_bind)==sizeof(u.ProbeFunc)
&& sizeof(u2.virtfunc)==sizeof(u2.s) ? 1 : -1];
// Unfortunately, taking the address of a MF prevents it from being inlined, so
// this next line can't be completely optimised away by the compiler.
u2.virtfunc = &GenericVirtualClass::GetThis;
u.s.codeptr = u2.s.codeptr;
return (pthis->*u.ProbeFunc)();
}
};
#if (_MSC_VER <1300)
// Nasty hack for Microsoft Visual C++ 6.0
// unknown_inheritance classes go here
// There is a compiler bug in MSVC6 which generates incorrect code in this case!!
template <>
struct SimplifyMemFunc<SINGLE_MEMFUNCPTR_SIZE + 3*sizeof(int) >
{
template <class X, class XFuncType, class GenericMemFuncType>
inline static GenericClass *Convert(X *pthis, XFuncType function_to_bind,
GenericMemFuncType &bound_func) {
// There is an apalling but obscure compiler bug in MSVC6 and earlier:
// vtable_index and 'vtordisp' are always set to 0 in the
// unknown_inheritance case!
// This means that an incorrect function could be called!!!
// Compiling with the /vmg option leads to potentially incorrect code.
// This is probably the reason that the IDE has a user interface for specifying
// the /vmg option, but it is disabled - you can only specify /vmg on
// the command line. In VC1.5 and earlier, the compiler would ICE if it ever
// encountered this situation.
// It is OK to use the /vmg option if /vmm or /vms is specified.
// Fortunately, the wrong function is only called in very obscure cases.
// It only occurs when a derived class overrides a virtual function declared
// in a virtual base class, and the member function
// points to the *Derived* version of that function. The problem can be
// completely averted in 100% of cases by using the *Base class* for the
// member fpointer. Ie, if you use the base class as an interface, you'll
// stay out of trouble.
// Occasionally, you might want to point directly to a derived class function
// that isn't an override of a base class. In this case, both vtable_index
// and 'vtordisp' are zero, but a virtual_inheritance pointer will be generated.
// We can generate correct code in this case. To prevent an incorrect call from
// ever being made, on MSVC6 we generate a warning, and call a function to
// make the program crash instantly.
#error "VC6 compiler bug."
return 0;
}
};
#else
// Nasty hack for Microsoft and Intel (IA32 and Itanium)
// unknown_inheritance classes go here
// This is probably the ugliest bit of code I've ever written. Look at the casts!
// There is a compiler bug in MSVC6 which prevents it from using this code.
template <>
struct SimplifyMemFunc<SINGLE_MEMFUNCPTR_SIZE + 3*sizeof(int) >
{
template <class X, class XFuncType, class GenericMemFuncType>
inline static GenericClass *Convert(X *pthis, XFuncType function_to_bind,
GenericMemFuncType &bound_func) {
// The member function pointer is 16 bytes long. We can't use a normal cast, but
// we can use a union to do the conversion.
union {
XFuncType func;
// In VC++ and ICL, an unknown_inheritance member pointer
// is internally defined as:
struct {
GenericMemFuncType m_funcaddress; // points to the actual member function
int delta; // #bytes to be added to the 'this' pointer
int vtordisp; // #bytes to add to 'this' to find the vtable
int vtable_index; // or 0 if no virtual inheritance
} s;
} u;
// Check that the horrible_cast will work
typedef int ERROR_CantUsehorrible_cast[sizeof(XFuncType)==sizeof(u.s)? 1 : -1];
u.func = function_to_bind;
bound_func = u.s.funcaddress;
int virtual_delta = 0;
if (u.s.vtable_index) { // Virtual inheritance is used
// First, get to the vtable.
// It is 'vtordisp' bytes from the start of the class.
const int * vtable = *reinterpret_cast<const int *const*>(
reinterpret_cast<const char *>(pthis) + u.s.vtordisp );
// 'vtable_index' tells us where in the table we should be looking.
virtual_delta = u.s.vtordisp + *reinterpret_cast<const int *>(
reinterpret_cast<const char *>(vtable) + u.s.vtable_index);
}
// The int at 'virtual_delta' gives us the amount to add to 'this'.
// Finally we can add the three components together. Phew!
return reinterpret_cast<GenericClass *>(
reinterpret_cast<char *>(pthis) + u.s.delta + virtual_delta);
};
};
#endif // MSVC 7 and greater
#endif // MS/Intel hacks
} // namespace detail
////////////////////////////////////////////////////////////////////////////////
// Fast Delegates, part 2:
//
// Define the delegate storage, and cope with static functions
//
////////////////////////////////////////////////////////////////////////////////
// DelegateMemento -- an opaque structure which can hold an arbitary delegate.
// It knows nothing about the calling convention or number of arguments used by
// the function pointed to.
// It supplies comparison operators so that it can be stored in STL collections.
// It cannot be set to anything other than null, nor invoked directly:
// it must be converted to a specific delegate.
// Implementation:
// There are two possible implementations: the Safe method and the Evil method.
// DelegateMemento - Safe version
//
// This implementation is standard-compliant, but a bit tricky.
// A static function pointer is stored inside the class.
// Here are the valid values:
// +-- Static pointer --+--pThis --+-- pMemFunc-+-- Meaning------+
// | 0 | 0 | 0 | Empty |
// | !=0 |(dontcare)| Invoker | Static function|
// | 0 | !=0 | !=0* | Method call |
// +--------------------+----------+------------+----------------+
// * For Metrowerks, this can be 0. (first virtual function in a
// single_inheritance class).
// When stored stored inside a specific delegate, the 'dontcare' entries are replaced
// with a reference to the delegate itself. This complicates the = and == operators
// for the delegate class.
// DelegateMemento - Evil version
//
// For compilers where data pointers are at least as big as code pointers, it is
// possible to store the function pointer in the this pointer, using another
// horrible_cast. In this case the DelegateMemento implementation is simple:
// +--pThis --+-- pMemFunc-+-- Meaning---------------------+
// | 0 | 0 | Empty |
// | !=0 | !=0* | Static function or method call|
// +----------+------------+-------------------------------+
// * For Metrowerks, this can be 0. (first virtual function in a
// single_inheritance class).
// Note that the Sun C++ and MSVC documentation explicitly state that they
// support static_cast between void * and function pointers.
class DelegateMemento {
protected:
// the data is protected, not private, because many
// compilers have problems with template friends.
typedef void (detail::GenericClass::*GenericMemFuncType)(); // arbitrary MFP.
detail::GenericClass *m_pthis;
GenericMemFuncType m_pFunction;
public:
DelegateMemento() : m_pthis(0), m_pFunction(0) {};
void clear() { m_pthis=0; m_pFunction=0; }
public:
// Evil method:
inline bool IsEqual (const DelegateMemento &x) const{
return m_pthis==x.m_pthis && m_pFunction==x.m_pFunction;
}
// Provide a strict weak ordering for DelegateMementos.
inline bool IsLess(const DelegateMemento &right) const {
// deal with static function pointers first
if (m_pthis !=right.m_pthis) return m_pthis < right.m_pthis;
// There are no ordering operators for member function pointers,
// but we can fake one by comparing each byte. The resulting ordering is
// arbitrary (and compiler-dependent), but it permits storage in ordered STL containers.
return memcmp(&m_pFunction, &right.m_pFunction, sizeof(m_pFunction)) < 0;
}
// BUGFIX (Mar 2005):
// We can't just compare m_pFunction because on Metrowerks,
// m_pFunction can be zero even if the delegate is not empty!
inline bool operator ! () const // Is it bound to anything?
{ return m_pthis==0 && m_pFunction==0; }
inline bool empty() const // Is it bound to anything?
{ return m_pthis==0 && m_pFunction==0; }
public:
DelegateMemento & operator = (const DelegateMemento &right) {
SetMementoFrom(right);
return *this;
}
inline bool operator <(const DelegateMemento &right) {
return IsLess(right);
}
inline bool operator >(const DelegateMemento &right) {
return right.IsLess(*this);
}
DelegateMemento (const DelegateMemento &right) :
m_pFunction(right.m_pFunction), m_pthis(right.m_pthis)
{}
protected:
void SetMementoFrom(const DelegateMemento &right) {
m_pFunction = right.m_pFunction;
m_pthis = right.m_pthis;
}
};
// ClosurePtr<>
//
// A private wrapper class that adds function signatures to DelegateMemento.
// It's the class that does most of the actual work.
// The signatures are specified by:
// GenericMemFunc: must be a type of GenericClass member function pointer.
// StaticFuncPtr: must be a type of function pointer with the same signature
// as GenericMemFunc.
// UnvoidStaticFuncPtr: is the same as StaticFuncPtr, except on VC6
// where it never returns void (returns DefaultVoid instead).
// An outer class, FastDelegateN<>, handles the invoking and creates the
// necessary typedefs.
// This class does everything else.
namespace detail {
template < class GenericMemFunc, class StaticFuncPtr, class UnvoidStaticFuncPtr>
class ClosurePtr : public DelegateMemento {
public:
// These functions are for setting the delegate to a member function.
// Here's the clever bit: we convert an arbitrary member function into a
// standard form. XMemFunc should be a member function of class X, but I can't
// enforce that here. It needs to be enforced by the wrapper class.
template < class X, class XMemFunc >
inline void bindmemfunc(X *pthis, XMemFunc function_to_bind ) {
m_pthis = SimplifyMemFunc< sizeof(function_to_bind) >
::Convert(pthis, function_to_bind, m_pFunction);
}
// For const member functions, we only need a const class pointer.
// Since we know that the member function is const, it's safe to
// remove the const qualifier from the 'this' pointer with a const_cast.
// VC6 has problems if we just overload 'bindmemfunc', so we give it a different name.
template < class X, class XMemFunc>
inline void bindconstmemfunc(const X *pthis, XMemFunc function_to_bind) {
m_pthis= SimplifyMemFunc< sizeof(function_to_bind) >
::Convert(const_cast<X*>(pthis), function_to_bind, m_pFunction);
}
#ifdef FASTDELEGATE_GCC_BUG_8271 // At present, GCC doesn't recognize constness of MFPs in templates
template < class X, class XMemFunc>
inline void bindmemfunc(const X *pthis, XMemFunc function_to_bind) {
bindconstmemfunc(pthis, function_to_bind);
}
#endif
// These functions are required for invoking the stored function
inline GenericClass *GetClosureThis() const { return m_pthis; }
inline GenericMemFunc GetClosureMemPtr() const { return reinterpret_cast<GenericMemFunc>(m_pFunction); }
// There are a few ways of dealing with static function pointers.
// There's a standard-compliant, but tricky method.
// There's also a straightforward hack, that won't work on DOS compilers using the
// medium memory model. It's so evil that I can't recommend it, but I've
// implemented it anyway because it produces very nice asm code.
// ClosurePtr<> - Evil version
//
// For compilers where data pointers are at least as big as code pointers, it is
// possible to store the function pointer in the this pointer, using another
// horrible_cast. Invocation isn't any faster, but it saves 4 bytes, and
// speeds up comparison and assignment. If C++ provided direct language support
// for delegates, they would produce asm code that was almost identical to this.
// Note that the Sun C++ and MSVC documentation explicitly state that they
// support static_cast between void * and function pointers.
template< class DerivedClass >
inline void CopyFrom (DerivedClass *pParent, const DelegateMemento &right) {
SetMementoFrom(right);
}
// For static functions, the 'static_function_invoker' class in the parent
// will be called. The parent then needs to call GetStaticFunction() to find out
// the actual function to invoke.
// ******** EVIL, EVIL CODE! *******
template < class DerivedClass, class ParentInvokerSig>
inline void bindstaticfunc(DerivedClass *pParent, ParentInvokerSig static_function_invoker,
StaticFuncPtr function_to_bind) {
if (function_to_bind==0) { // cope with assignment to 0
m_pFunction=0;
} else {
// We'll be ignoring the 'this' pointer, but we need to make sure we pass
// a valid value to bindmemfunc().
bindmemfunc(pParent, static_function_invoker);
}
// WARNING! Evil hack. We store the function in the 'this' pointer!
// Ensure that there's a compilation failure if function pointers
// and data pointers have different sizes.
typedef int ERROR_CantUseEvilMethod[sizeof(GenericClass *)==sizeof(function_to_bind) ? 1 : -1];
m_pthis = horrible_cast<GenericClass *>(function_to_bind);
// MSVC, SunC++ and DMC accept the following (non-standard) code:
// m_pthis = static_cast<GenericClass *>(static_cast<void *>(function_to_bind));
// BCC32, Comeau and DMC accept this method. MSVC7.1 needs __int64 instead of long
// m_pthis = reinterpret_cast<GenericClass *>(reinterpret_cast<long>(function_to_bind));
}
// ******** EVIL, EVIL CODE! *******
// This function will be called with an invalid 'this' pointer!!
// We're just returning the 'this' pointer, converted into
// a function pointer!
inline UnvoidStaticFuncPtr GetStaticFunction() const {
// Ensure that there's a compilation failure if function pointers
// and data pointers have different sizes.
typedef int ERROR_CantUseEvilMethod[sizeof(UnvoidStaticFuncPtr)==sizeof(this) ? 1 : -1];
return horrible_cast<UnvoidStaticFuncPtr>(this);
}
// Does the closure contain this static function?
inline bool IsEqualToStaticFuncPtr(StaticFuncPtr funcptr){
if (funcptr==0) return empty();
// For the Evil method, if it doesn't actually contain a static function, this will return an arbitrary
// value that is not equal to any valid function pointer.
else return funcptr==reinterpret_cast<StaticFuncPtr>(GetStaticFunction());
}
};
} // namespace detail
////////////////////////////////////////////////////////////////////////////////
// Fast Delegates, part 3:
//
// Wrapper classes to ensure type safety
//
////////////////////////////////////////////////////////////////////////////////
// Once we have the member function conversion templates, it's easy to make the
// wrapper classes. So that they will work with as many compilers as possible,
// the classes are of the form
// FastDelegate3<int, char *, double>
// They can cope with any combination of parameters. The max number of parameters
// allowed is 8, but it is trivial to increase this limit.
// Note that we need to treat const member functions seperately.
// All this class does is to enforce type safety, and invoke the delegate with
// the correct list of parameters.
// Because of the weird rule about the class of derived member function pointers,
// you sometimes need to apply a downcast to the 'this' pointer.
// This is the reason for the use of "implicit_cast<X*>(pthis)" in the code below.
// If CDerivedClass is derived from CBaseClass, but doesn't override SimpleVirtualFunction,
// without this trick you'd need to write:
// MyDelegate(static_cast<CBaseClass *>(&d), &CDerivedClass::SimpleVirtualFunction);
// but with the trick you can write
// MyDelegate(&d, &CDerivedClass::SimpleVirtualFunction);
// RetType is the type the compiler uses in compiling the template. For VC6,
// it cannot be void. DesiredRetType is the real type which is returned from
// all of the functions. It can be void.
// Implicit conversion to "bool" is achieved using the safe_bool idiom,
// using member data pointers (MDP). This allows "if (dg)..." syntax
// Because some compilers (eg codeplay) don't have a unique value for a zero
// MDP, an extra padding member is added to the SafeBool struct.
// Some compilers (eg VC6) won't implicitly convert from 0 to an MDP, so
// in that case the static function constructor is not made explicit; this
// allows "if (dg==0) ..." to compile.
//N=0
template<class RetType=detail::DefaultVoid>
class FastDelegate0 {
private:
typedef typename detail::DefaultVoidToVoid<RetType>::type DesiredRetType;
typedef DesiredRetType (*StaticFunctionPtr)();
typedef RetType (*UnvoidStaticFunctionPtr)();
typedef RetType (detail::GenericClass::*GenericMemFn)();
typedef detail::ClosurePtr<GenericMemFn, StaticFunctionPtr, UnvoidStaticFunctionPtr> ClosureType;
ClosureType m_Closure;
public:
// Typedefs to aid generic programming
typedef FastDelegate0 type;
// Construction and comparison functions
FastDelegate0() { clear(); }
FastDelegate0(const FastDelegate0 &x) {
m_Closure.CopyFrom(this, x.m_Closure); }
void operator = (const FastDelegate0 &x) {
m_Closure.CopyFrom(this, x.m_Closure); }
bool operator ==(const FastDelegate0 &x) const {
return m_Closure.IsEqual(x.m_Closure); }
bool operator !=(const FastDelegate0 &x) const {
return !m_Closure.IsEqual(x.m_Closure); }
bool operator <(const FastDelegate0 &x) const {
return m_Closure.IsLess(x.m_Closure); }
bool operator >(const FastDelegate0 &x) const {
return x.m_Closure.IsLess(m_Closure); }
// Binding to non-const member functions
template < class X, class Y >
FastDelegate0(Y *pthis, DesiredRetType (X::* function_to_bind)() ) {
m_Closure.bindmemfunc(detail::implicit_cast<X*>(pthis), function_to_bind); }
template < class X, class Y >
inline void bind(Y *pthis, DesiredRetType (X::* function_to_bind)()) {
m_Closure.bindmemfunc(detail::implicit_cast<X*>(pthis), function_to_bind); }
// Binding to const member functions.
template < class X, class Y >
FastDelegate0(const Y *pthis, DesiredRetType (X::* function_to_bind)() const) {
m_Closure.bindconstmemfunc(detail::implicit_cast<const X*>(pthis), function_to_bind); }
template < class X, class Y >
inline void bind(const Y *pthis, DesiredRetType (X::* function_to_bind)() const) {
m_Closure.bindconstmemfunc(detail::implicit_cast<const X *>(pthis), function_to_bind); }
// Static functions. We convert them into a member function call.
// This constructor also provides implicit conversion
FastDelegate0(DesiredRetType (*function_to_bind)() ) {
bind(function_to_bind); }
// for efficiency, prevent creation of a temporary
void operator = (DesiredRetType (*function_to_bind)() ) {
bind(function_to_bind); }
inline void bind(DesiredRetType (*function_to_bind)()) {
m_Closure.bindstaticfunc(this, &FastDelegate0::InvokeStaticFunction,
function_to_bind); }
// Invoke the delegate
RetType operator() () const {
return (m_Closure.GetClosureThis()->*(m_Closure.GetClosureMemPtr()))(); }
// Implicit conversion to "bool" using the safe_bool idiom
private:
typedef struct SafeBoolStruct {
int a_data_pointer_to_this_is_0_on_buggy_compilers;
StaticFunctionPtr m_nonzero;
} UselessTypedef;
typedef StaticFunctionPtr SafeBoolStruct::*unspecified_bool_type;
public:
operator unspecified_bool_type() const {
return empty()? 0: &SafeBoolStruct::m_nonzero;
}
// necessary to allow ==0 to work despite the safe_bool idiom
inline bool operator==(StaticFunctionPtr funcptr) {
return m_Closure.IsEqualToStaticFuncPtr(funcptr); }
inline bool operator!=(StaticFunctionPtr funcptr) {
return !m_Closure.IsEqualToStaticFuncPtr(funcptr); }
inline bool operator ! () const { // Is it bound to anything?
return !m_Closure; }
inline bool empty() const {
return !m_Closure; }
void clear() { m_Closure.clear();}
// Conversion to and from the DelegateMemento storage class
const DelegateMemento & GetMemento() { return m_Closure; }
void SetMemento(const DelegateMemento &any) { m_Closure.CopyFrom(this, any); }
private: // Invoker for static functions
RetType InvokeStaticFunction() const {
return (*(m_Closure.GetStaticFunction()))(); }
};
//N=1
template<class Param1, class RetType=detail::DefaultVoid>
class FastDelegate1 {
private:
typedef typename detail::DefaultVoidToVoid<RetType>::type DesiredRetType;
typedef DesiredRetType (*StaticFunctionPtr)(Param1 p1);
typedef RetType (*UnvoidStaticFunctionPtr)(Param1 p1);
typedef RetType (detail::GenericClass::*GenericMemFn)(Param1 p1);
typedef detail::ClosurePtr<GenericMemFn, StaticFunctionPtr, UnvoidStaticFunctionPtr> ClosureType;
ClosureType m_Closure;
public:
// Typedefs to aid generic programming
typedef FastDelegate1 type;
// Construction and comparison functions
FastDelegate1() { clear(); }
FastDelegate1(const FastDelegate1 &x) {
m_Closure.CopyFrom(this, x.m_Closure); }
void operator = (const FastDelegate1 &x) {
m_Closure.CopyFrom(this, x.m_Closure); }
bool operator ==(const FastDelegate1 &x) const {
return m_Closure.IsEqual(x.m_Closure); }
bool operator !=(const FastDelegate1 &x) const {
return !m_Closure.IsEqual(x.m_Closure); }
bool operator <(const FastDelegate1 &x) const {
return m_Closure.IsLess(x.m_Closure); }
bool operator >(const FastDelegate1 &x) const {
return x.m_Closure.IsLess(m_Closure); }
// Binding to non-const member functions
template < class X, class Y >
FastDelegate1(Y *pthis, DesiredRetType (X::* function_to_bind)(Param1 p1) ) {
m_Closure.bindmemfunc(detail::implicit_cast<X*>(pthis), function_to_bind); }
template < class X, class Y >
inline void bind(Y *pthis, DesiredRetType (X::* function_to_bind)(Param1 p1)) {
m_Closure.bindmemfunc(detail::implicit_cast<X*>(pthis), function_to_bind); }
// Binding to const member functions.
template < class X, class Y >
FastDelegate1(const Y *pthis, DesiredRetType (X::* function_to_bind)(Param1 p1) const) {
m_Closure.bindconstmemfunc(detail::implicit_cast<const X*>(pthis), function_to_bind); }
template < class X, class Y >
inline void bind(const Y *pthis, DesiredRetType (X::* function_to_bind)(Param1 p1) const) {
m_Closure.bindconstmemfunc(detail::implicit_cast<const X *>(pthis), function_to_bind); }
// Static functions. We convert them into a member function call.
// This constructor also provides implicit conversion
FastDelegate1(DesiredRetType (*function_to_bind)(Param1 p1) ) {
bind(function_to_bind); }
// for efficiency, prevent creation of a temporary
void operator = (DesiredRetType (*function_to_bind)(Param1 p1) ) {
bind(function_to_bind); }
inline void bind(DesiredRetType (*function_to_bind)(Param1 p1)) {
m_Closure.bindstaticfunc(this, &FastDelegate1::InvokeStaticFunction,
function_to_bind); }
// Invoke the delegate
RetType operator() (Param1 p1) const {
return (m_Closure.GetClosureThis()->*(m_Closure.GetClosureMemPtr()))(p1); }
// Implicit conversion to "bool" using the safe_bool idiom
private:
typedef struct SafeBoolStruct {
int a_data_pointer_to_this_is_0_on_buggy_compilers;
StaticFunctionPtr m_nonzero;
} UselessTypedef;
typedef StaticFunctionPtr SafeBoolStruct::*unspecified_bool_type;
public:
operator unspecified_bool_type() const {
return empty()? 0: &SafeBoolStruct::m_nonzero;
}
// necessary to allow ==0 to work despite the safe_bool idiom
inline bool operator==(StaticFunctionPtr funcptr) {
return m_Closure.IsEqualToStaticFuncPtr(funcptr); }
inline bool operator!=(StaticFunctionPtr funcptr) {
return !m_Closure.IsEqualToStaticFuncPtr(funcptr); }
inline bool operator ! () const { // Is it bound to anything?
return !m_Closure; }
inline bool empty() const {
return !m_Closure; }
void clear() { m_Closure.clear();}
// Conversion to and from the DelegateMemento storage class
const DelegateMemento & GetMemento() { return m_Closure; }
void SetMemento(const DelegateMemento &any) { m_Closure.CopyFrom(this, any); }
private: // Invoker for static functions
RetType InvokeStaticFunction(Param1 p1) const {
return (*(m_Closure.GetStaticFunction()))(p1); }
};
//N=2
template<class Param1, class Param2, class RetType=detail::DefaultVoid>
class FastDelegate2 {
private:
typedef typename detail::DefaultVoidToVoid<RetType>::type DesiredRetType;
typedef DesiredRetType (*StaticFunctionPtr)(Param1 p1, Param2 p2);
typedef RetType (*UnvoidStaticFunctionPtr)(Param1 p1, Param2 p2);
typedef RetType (detail::GenericClass::*GenericMemFn)(Param1 p1, Param2 p2);
typedef detail::ClosurePtr<GenericMemFn, StaticFunctionPtr, UnvoidStaticFunctionPtr> ClosureType;
ClosureType m_Closure;
public:
// Typedefs to aid generic programming
typedef FastDelegate2 type;
// Construction and comparison functions
FastDelegate2() { clear(); }
FastDelegate2(const FastDelegate2 &x) {
m_Closure.CopyFrom(this, x.m_Closure); }
void operator = (const FastDelegate2 &x) {
m_Closure.CopyFrom(this, x.m_Closure); }
bool operator ==(const FastDelegate2 &x) const {
return m_Closure.IsEqual(x.m_Closure); }
bool operator !=(const FastDelegate2 &x) const {
return !m_Closure.IsEqual(x.m_Closure); }
bool operator <(const FastDelegate2 &x) const {
return m_Closure.IsLess(x.m_Closure); }
bool operator >(const FastDelegate2 &x) const {
return x.m_Closure.IsLess(m_Closure); }
// Binding to non-const member functions
template < class X, class Y >
FastDelegate2(Y *pthis, DesiredRetType (X::* function_to_bind)(Param1 p1, Param2 p2) ) {
m_Closure.bindmemfunc(detail::implicit_cast<X*>(pthis), function_to_bind); }
template < class X, class Y >
inline void bind(Y *pthis, DesiredRetType (X::* function_to_bind)(Param1 p1, Param2 p2)) {
m_Closure.bindmemfunc(detail::implicit_cast<X*>(pthis), function_to_bind); }
// Binding to const member functions.
template < class X, class Y >
FastDelegate2(const Y *pthis, DesiredRetType (X::* function_to_bind)(Param1 p1, Param2 p2) const) {
m_Closure.bindconstmemfunc(detail::implicit_cast<const X*>(pthis), function_to_bind); }
template < class X, class Y >
inline void bind(const Y *pthis, DesiredRetType (X::* function_to_bind)(Param1 p1, Param2 p2) const) {
m_Closure.bindconstmemfunc(detail::implicit_cast<const X *>(pthis), function_to_bind); }
// Static functions. We convert them into a member function call.
// This constructor also provides implicit conversion
FastDelegate2(DesiredRetType (*function_to_bind)(Param1 p1, Param2 p2) ) {
bind(function_to_bind); }
// for efficiency, prevent creation of a temporary
void operator = (DesiredRetType (*function_to_bind)(Param1 p1, Param2 p2) ) {
bind(function_to_bind); }
inline void bind(DesiredRetType (*function_to_bind)(Param1 p1, Param2 p2)) {
m_Closure.bindstaticfunc(this, &FastDelegate2::InvokeStaticFunction,
function_to_bind); }
// Invoke the delegate
RetType operator() (Param1 p1, Param2 p2) const {
return (m_Closure.GetClosureThis()->*(m_Closure.GetClosureMemPtr()))(p1, p2); }
// Implicit conversion to "bool" using the safe_bool idiom
private:
typedef struct SafeBoolStruct {
int a_data_pointer_to_this_is_0_on_buggy_compilers;
StaticFunctionPtr m_nonzero;
} UselessTypedef;
typedef StaticFunctionPtr SafeBoolStruct::*unspecified_bool_type;
public:
operator unspecified_bool_type() const {
return empty()? 0: &SafeBoolStruct::m_nonzero;
}
// necessary to allow ==0 to work despite the safe_bool idiom
inline bool operator==(StaticFunctionPtr funcptr) {
return m_Closure.IsEqualToStaticFuncPtr(funcptr); }
inline bool operator!=(StaticFunctionPtr funcptr) {
return !m_Closure.IsEqualToStaticFuncPtr(funcptr); }
inline bool operator ! () const { // Is it bound to anything?
return !m_Closure; }
inline bool empty() const {
return !m_Closure; }
void clear() { m_Closure.clear();}
// Conversion to and from the DelegateMemento storage class
const DelegateMemento & GetMemento() { return m_Closure; }
void SetMemento(const DelegateMemento &any) { m_Closure.CopyFrom(this, any); }
private: // Invoker for static functions
RetType InvokeStaticFunction(Param1 p1, Param2 p2) const {
return (*(m_Closure.GetStaticFunction()))(p1, p2); }
};
//N=3
template<class Param1, class Param2, class Param3, class RetType=detail::DefaultVoid>
class FastDelegate3 {
private:
typedef typename detail::DefaultVoidToVoid<RetType>::type DesiredRetType;
typedef DesiredRetType (*StaticFunctionPtr)(Param1 p1, Param2 p2, Param3 p3);
typedef RetType (*UnvoidStaticFunctionPtr)(Param1 p1, Param2 p2, Param3 p3);
typedef RetType (detail::GenericClass::*GenericMemFn)(Param1 p1, Param2 p2, Param3 p3);
typedef detail::ClosurePtr<GenericMemFn, StaticFunctionPtr, UnvoidStaticFunctionPtr> ClosureType;
ClosureType m_Closure;
public:
// Typedefs to aid generic programming
typedef FastDelegate3 type;
// Construction and comparison functions
FastDelegate3() { clear(); }
FastDelegate3(const FastDelegate3 &x) {
m_Closure.CopyFrom(this, x.m_Closure); }
void operator = (const FastDelegate3 &x) {
m_Closure.CopyFrom(this, x.m_Closure); }
bool operator ==(const FastDelegate3 &x) const {
return m_Closure.IsEqual(x.m_Closure); }
bool operator !=(const FastDelegate3 &x) const {
return !m_Closure.IsEqual(x.m_Closure); }
bool operator <(const FastDelegate3 &x) const {
return m_Closure.IsLess(x.m_Closure); }
bool operator >(const FastDelegate3 &x) const {
return x.m_Closure.IsLess(m_Closure); }
// Binding to non-const member functions
template < class X, class Y >
FastDelegate3(Y *pthis, DesiredRetType (X::* function_to_bind)(Param1 p1, Param2 p2, Param3 p3) ) {
m_Closure.bindmemfunc(detail::implicit_cast<X*>(pthis), function_to_bind); }
template < class X, class Y >
inline void bind(Y *pthis, DesiredRetType (X::* function_to_bind)(Param1 p1, Param2 p2, Param3 p3)) {
m_Closure.bindmemfunc(detail::implicit_cast<X*>(pthis), function_to_bind); }
// Binding to const member functions.
template < class X, class Y >
FastDelegate3(const Y *pthis, DesiredRetType (X::* function_to_bind)(Param1 p1, Param2 p2, Param3 p3) const) {
m_Closure.bindconstmemfunc(detail::implicit_cast<const X*>(pthis), function_to_bind); }
template < class X, class Y >
inline void bind(const Y *pthis, DesiredRetType (X::* function_to_bind)(Param1 p1, Param2 p2, Param3 p3) const) {
m_Closure.bindconstmemfunc(detail::implicit_cast<const X *>(pthis), function_to_bind); }
// Static functions. We convert them into a member function call.
// This constructor also provides implicit conversion
FastDelegate3(DesiredRetType (*function_to_bind)(Param1 p1, Param2 p2, Param3 p3) ) {
bind(function_to_bind); }
// for efficiency, prevent creation of a temporary
void operator = (DesiredRetType (*function_to_bind)(Param1 p1, Param2 p2, Param3 p3) ) {
bind(function_to_bind); }
inline void bind(DesiredRetType (*function_to_bind)(Param1 p1, Param2 p2, Param3 p3)) {
m_Closure.bindstaticfunc(this, &FastDelegate3::InvokeStaticFunction,
function_to_bind); }
// Invoke the delegate
RetType operator() (Param1 p1, Param2 p2, Param3 p3) const {
return (m_Closure.GetClosureThis()->*(m_Closure.GetClosureMemPtr()))(p1, p2, p3); }
// Implicit conversion to "bool" using the safe_bool idiom
private:
typedef struct SafeBoolStruct {
int a_data_pointer_to_this_is_0_on_buggy_compilers;
StaticFunctionPtr m_nonzero;
} UselessTypedef;
typedef StaticFunctionPtr SafeBoolStruct::*unspecified_bool_type;
public:
operator unspecified_bool_type() const {
return empty()? 0: &SafeBoolStruct::m_nonzero;
}
// necessary to allow ==0 to work despite the safe_bool idiom
inline bool operator==(StaticFunctionPtr funcptr) {
return m_Closure.IsEqualToStaticFuncPtr(funcptr); }
inline bool operator!=(StaticFunctionPtr funcptr) {
return !m_Closure.IsEqualToStaticFuncPtr(funcptr); }
inline bool operator ! () const { // Is it bound to anything?
return !m_Closure; }
inline bool empty() const {
return !m_Closure; }
void clear() { m_Closure.clear();}
// Conversion to and from the DelegateMemento storage class
const DelegateMemento & GetMemento() { return m_Closure; }
void SetMemento(const DelegateMemento &any) { m_Closure.CopyFrom(this, any); }
private: // Invoker for static functions
RetType InvokeStaticFunction(Param1 p1, Param2 p2, Param3 p3) const {
return (*(m_Closure.GetStaticFunction()))(p1, p2, p3); }
};
//N=4
template<class Param1, class Param2, class Param3, class Param4, class RetType=detail::DefaultVoid>
class FastDelegate4 {
private:
typedef typename detail::DefaultVoidToVoid<RetType>::type DesiredRetType;
typedef DesiredRetType (*StaticFunctionPtr)(Param1 p1, Param2 p2, Param3 p3, Param4 p4);
typedef RetType (*UnvoidStaticFunctionPtr)(Param1 p1, Param2 p2, Param3 p3, Param4 p4);
typedef RetType (detail::GenericClass::*GenericMemFn)(Param1 p1, Param2 p2, Param3 p3, Param4 p4);
typedef detail::ClosurePtr<GenericMemFn, StaticFunctionPtr, UnvoidStaticFunctionPtr> ClosureType;
ClosureType m_Closure;
public:
// Typedefs to aid generic programming
typedef FastDelegate4 type;
// Construction and comparison functions
FastDelegate4() { clear(); }
FastDelegate4(const FastDelegate4 &x) {
m_Closure.CopyFrom(this, x.m_Closure); }
void operator = (const FastDelegate4 &x) {
m_Closure.CopyFrom(this, x.m_Closure); }
bool operator ==(const FastDelegate4 &x) const {
return m_Closure.IsEqual(x.m_Closure); }
bool operator !=(const FastDelegate4 &x) const {
return !m_Closure.IsEqual(x.m_Closure); }
bool operator <(const FastDelegate4 &x) const {
return m_Closure.IsLess(x.m_Closure); }
bool operator >(const FastDelegate4 &x) const {
return x.m_Closure.IsLess(m_Closure); }
// Binding to non-const member functions
template < class X, class Y >
FastDelegate4(Y *pthis, DesiredRetType (X::* function_to_bind)(Param1 p1, Param2 p2, Param3 p3, Param4 p4) ) {
m_Closure.bindmemfunc(detail::implicit_cast<X*>(pthis), function_to_bind); }
template < class X, class Y >
inline void bind(Y *pthis, DesiredRetType (X::* function_to_bind)(Param1 p1, Param2 p2, Param3 p3, Param4 p4)) {
m_Closure.bindmemfunc(detail::implicit_cast<X*>(pthis), function_to_bind); }
// Binding to const member functions.
template < class X, class Y >
FastDelegate4(const Y *pthis, DesiredRetType (X::* function_to_bind)(Param1 p1, Param2 p2, Param3 p3, Param4 p4) const) {
m_Closure.bindconstmemfunc(detail::implicit_cast<const X*>(pthis), function_to_bind); }
template < class X, class Y >
inline void bind(const Y *pthis, DesiredRetType (X::* function_to_bind)(Param1 p1, Param2 p2, Param3 p3, Param4 p4) const) {
m_Closure.bindconstmemfunc(detail::implicit_cast<const X *>(pthis), function_to_bind); }
// Static functions. We convert them into a member function call.
// This constructor also provides implicit conversion
FastDelegate4(DesiredRetType (*function_to_bind)(Param1 p1, Param2 p2, Param3 p3, Param4 p4) ) {
bind(function_to_bind); }
// for efficiency, prevent creation of a temporary
void operator = (DesiredRetType (*function_to_bind)(Param1 p1, Param2 p2, Param3 p3, Param4 p4) ) {
bind(function_to_bind); }
inline void bind(DesiredRetType (*function_to_bind)(Param1 p1, Param2 p2, Param3 p3, Param4 p4)) {
m_Closure.bindstaticfunc(this, &FastDelegate4::InvokeStaticFunction,
function_to_bind); }
// Invoke the delegate
RetType operator() (Param1 p1, Param2 p2, Param3 p3, Param4 p4) const {
return (m_Closure.GetClosureThis()->*(m_Closure.GetClosureMemPtr()))(p1, p2, p3, p4); }
// Implicit conversion to "bool" using the safe_bool idiom
private:
typedef struct SafeBoolStruct {
int a_data_pointer_to_this_is_0_on_buggy_compilers;
StaticFunctionPtr m_nonzero;
} UselessTypedef;
typedef StaticFunctionPtr SafeBoolStruct::*unspecified_bool_type;
public:
operator unspecified_bool_type() const {
return empty()? 0: &SafeBoolStruct::m_nonzero;
}
// necessary to allow ==0 to work despite the safe_bool idiom
inline bool operator==(StaticFunctionPtr funcptr) {
return m_Closure.IsEqualToStaticFuncPtr(funcptr); }
inline bool operator!=(StaticFunctionPtr funcptr) {
return !m_Closure.IsEqualToStaticFuncPtr(funcptr); }
inline bool operator ! () const { // Is it bound to anything?
return !m_Closure; }
inline bool empty() const {
return !m_Closure; }
void clear() { m_Closure.clear();}
// Conversion to and from the DelegateMemento storage class
const DelegateMemento & GetMemento() { return m_Closure; }
void SetMemento(const DelegateMemento &any) { m_Closure.CopyFrom(this, any); }
private: // Invoker for static functions
RetType InvokeStaticFunction(Param1 p1, Param2 p2, Param3 p3, Param4 p4) const {
return (*(m_Closure.GetStaticFunction()))(p1, p2, p3, p4); }
};
//N=5
template<class Param1, class Param2, class Param3, class Param4, class Param5, class RetType=detail::DefaultVoid>
class FastDelegate5 {
private:
typedef typename detail::DefaultVoidToVoid<RetType>::type DesiredRetType;
typedef DesiredRetType (*StaticFunctionPtr)(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5);
typedef RetType (*UnvoidStaticFunctionPtr)(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5);
typedef RetType (detail::GenericClass::*GenericMemFn)(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5);
typedef detail::ClosurePtr<GenericMemFn, StaticFunctionPtr, UnvoidStaticFunctionPtr> ClosureType;
ClosureType m_Closure;
public:
// Typedefs to aid generic programming
typedef FastDelegate5 type;
// Construction and comparison functions
FastDelegate5() { clear(); }
FastDelegate5(const FastDelegate5 &x) {
m_Closure.CopyFrom(this, x.m_Closure); }
void operator = (const FastDelegate5 &x) {
m_Closure.CopyFrom(this, x.m_Closure); }
bool operator ==(const FastDelegate5 &x) const {
return m_Closure.IsEqual(x.m_Closure); }
bool operator !=(const FastDelegate5 &x) const {
return !m_Closure.IsEqual(x.m_Closure); }
bool operator <(const FastDelegate5 &x) const {
return m_Closure.IsLess(x.m_Closure); }
bool operator >(const FastDelegate5 &x) const {
return x.m_Closure.IsLess(m_Closure); }
// Binding to non-const member functions
template < class X, class Y >
FastDelegate5(Y *pthis, DesiredRetType (X::* function_to_bind)(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5) ) {
m_Closure.bindmemfunc(detail::implicit_cast<X*>(pthis), function_to_bind); }
template < class X, class Y >
inline void bind(Y *pthis, DesiredRetType (X::* function_to_bind)(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5)) {
m_Closure.bindmemfunc(detail::implicit_cast<X*>(pthis), function_to_bind); }
// Binding to const member functions.
template < class X, class Y >
FastDelegate5(const Y *pthis, DesiredRetType (X::* function_to_bind)(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5) const) {
m_Closure.bindconstmemfunc(detail::implicit_cast<const X*>(pthis), function_to_bind); }
template < class X, class Y >
inline void bind(const Y *pthis, DesiredRetType (X::* function_to_bind)(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5) const) {
m_Closure.bindconstmemfunc(detail::implicit_cast<const X *>(pthis), function_to_bind); }
// Static functions. We convert them into a member function call.
// This constructor also provides implicit conversion
FastDelegate5(DesiredRetType (*function_to_bind)(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5) ) {
bind(function_to_bind); }
// for efficiency, prevent creation of a temporary
void operator = (DesiredRetType (*function_to_bind)(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5) ) {
bind(function_to_bind); }
inline void bind(DesiredRetType (*function_to_bind)(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5)) {
m_Closure.bindstaticfunc(this, &FastDelegate5::InvokeStaticFunction,
function_to_bind); }
// Invoke the delegate
RetType operator() (Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5) const {
return (m_Closure.GetClosureThis()->*(m_Closure.GetClosureMemPtr()))(p1, p2, p3, p4, p5); }
// Implicit conversion to "bool" using the safe_bool idiom
private:
typedef struct SafeBoolStruct {
int a_data_pointer_to_this_is_0_on_buggy_compilers;
StaticFunctionPtr m_nonzero;
} UselessTypedef;
typedef StaticFunctionPtr SafeBoolStruct::*unspecified_bool_type;
public:
operator unspecified_bool_type() const {
return empty()? 0: &SafeBoolStruct::m_nonzero;
}
// necessary to allow ==0 to work despite the safe_bool idiom
inline bool operator==(StaticFunctionPtr funcptr) {
return m_Closure.IsEqualToStaticFuncPtr(funcptr); }
inline bool operator!=(StaticFunctionPtr funcptr) {
return !m_Closure.IsEqualToStaticFuncPtr(funcptr); }
inline bool operator ! () const { // Is it bound to anything?
return !m_Closure; }
inline bool empty() const {
return !m_Closure; }
void clear() { m_Closure.clear();}
// Conversion to and from the DelegateMemento storage class
const DelegateMemento & GetMemento() { return m_Closure; }
void SetMemento(const DelegateMemento &any) { m_Closure.CopyFrom(this, any); }
private: // Invoker for static functions
RetType InvokeStaticFunction(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5) const {
return (*(m_Closure.GetStaticFunction()))(p1, p2, p3, p4, p5); }
};
//N=6
template<class Param1, class Param2, class Param3, class Param4, class Param5, class Param6, class RetType=detail::DefaultVoid>
class FastDelegate6 {
private:
typedef typename detail::DefaultVoidToVoid<RetType>::type DesiredRetType;
typedef DesiredRetType (*StaticFunctionPtr)(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6);
typedef RetType (*UnvoidStaticFunctionPtr)(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6);
typedef RetType (detail::GenericClass::*GenericMemFn)(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6);
typedef detail::ClosurePtr<GenericMemFn, StaticFunctionPtr, UnvoidStaticFunctionPtr> ClosureType;
ClosureType m_Closure;
public:
// Typedefs to aid generic programming
typedef FastDelegate6 type;
// Construction and comparison functions
FastDelegate6() { clear(); }
FastDelegate6(const FastDelegate6 &x) {
m_Closure.CopyFrom(this, x.m_Closure); }
void operator = (const FastDelegate6 &x) {
m_Closure.CopyFrom(this, x.m_Closure); }
bool operator ==(const FastDelegate6 &x) const {
return m_Closure.IsEqual(x.m_Closure); }
bool operator !=(const FastDelegate6 &x) const {
return !m_Closure.IsEqual(x.m_Closure); }
bool operator <(const FastDelegate6 &x) const {
return m_Closure.IsLess(x.m_Closure); }
bool operator >(const FastDelegate6 &x) const {
return x.m_Closure.IsLess(m_Closure); }
// Binding to non-const member functions
template < class X, class Y >
FastDelegate6(Y *pthis, DesiredRetType (X::* function_to_bind)(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6) ) {
m_Closure.bindmemfunc(detail::implicit_cast<X*>(pthis), function_to_bind); }
template < class X, class Y >
inline void bind(Y *pthis, DesiredRetType (X::* function_to_bind)(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6)) {
m_Closure.bindmemfunc(detail::implicit_cast<X*>(pthis), function_to_bind); }
// Binding to const member functions.
template < class X, class Y >
FastDelegate6(const Y *pthis, DesiredRetType (X::* function_to_bind)(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6) const) {
m_Closure.bindconstmemfunc(detail::implicit_cast<const X*>(pthis), function_to_bind); }
template < class X, class Y >
inline void bind(const Y *pthis, DesiredRetType (X::* function_to_bind)(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6) const) {
m_Closure.bindconstmemfunc(detail::implicit_cast<const X *>(pthis), function_to_bind); }
// Static functions. We convert them into a member function call.
// This constructor also provides implicit conversion
FastDelegate6(DesiredRetType (*function_to_bind)(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6) ) {
bind(function_to_bind); }
// for efficiency, prevent creation of a temporary
void operator = (DesiredRetType (*function_to_bind)(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6) ) {
bind(function_to_bind); }
inline void bind(DesiredRetType (*function_to_bind)(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6)) {
m_Closure.bindstaticfunc(this, &FastDelegate6::InvokeStaticFunction,
function_to_bind); }
// Invoke the delegate
RetType operator() (Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6) const {
return (m_Closure.GetClosureThis()->*(m_Closure.GetClosureMemPtr()))(p1, p2, p3, p4, p5, p6); }
// Implicit conversion to "bool" using the safe_bool idiom
private:
typedef struct SafeBoolStruct {
int a_data_pointer_to_this_is_0_on_buggy_compilers;
StaticFunctionPtr m_nonzero;
} UselessTypedef;
typedef StaticFunctionPtr SafeBoolStruct::*unspecified_bool_type;
public:
operator unspecified_bool_type() const {
return empty()? 0: &SafeBoolStruct::m_nonzero;
}
// necessary to allow ==0 to work despite the safe_bool idiom
inline bool operator==(StaticFunctionPtr funcptr) {
return m_Closure.IsEqualToStaticFuncPtr(funcptr); }
inline bool operator!=(StaticFunctionPtr funcptr) {
return !m_Closure.IsEqualToStaticFuncPtr(funcptr); }
inline bool operator ! () const { // Is it bound to anything?
return !m_Closure; }
inline bool empty() const {
return !m_Closure; }
void clear() { m_Closure.clear();}
// Conversion to and from the DelegateMemento storage class
const DelegateMemento & GetMemento() { return m_Closure; }
void SetMemento(const DelegateMemento &any) { m_Closure.CopyFrom(this, any); }
private: // Invoker for static functions
RetType InvokeStaticFunction(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6) const {
return (*(m_Closure.GetStaticFunction()))(p1, p2, p3, p4, p5, p6); }
};
//N=7
template<class Param1, class Param2, class Param3, class Param4, class Param5, class Param6, class Param7, class RetType=detail::DefaultVoid>
class FastDelegate7 {
private:
typedef typename detail::DefaultVoidToVoid<RetType>::type DesiredRetType;
typedef DesiredRetType (*StaticFunctionPtr)(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6, Param7 p7);
typedef RetType (*UnvoidStaticFunctionPtr)(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6, Param7 p7);
typedef RetType (detail::GenericClass::*GenericMemFn)(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6, Param7 p7);
typedef detail::ClosurePtr<GenericMemFn, StaticFunctionPtr, UnvoidStaticFunctionPtr> ClosureType;
ClosureType m_Closure;
public:
// Typedefs to aid generic programming
typedef FastDelegate7 type;
// Construction and comparison functions
FastDelegate7() { clear(); }
FastDelegate7(const FastDelegate7 &x) {
m_Closure.CopyFrom(this, x.m_Closure); }
void operator = (const FastDelegate7 &x) {
m_Closure.CopyFrom(this, x.m_Closure); }
bool operator ==(const FastDelegate7 &x) const {
return m_Closure.IsEqual(x.m_Closure); }
bool operator !=(const FastDelegate7 &x) const {
return !m_Closure.IsEqual(x.m_Closure); }
bool operator <(const FastDelegate7 &x) const {
return m_Closure.IsLess(x.m_Closure); }
bool operator >(const FastDelegate7 &x) const {
return x.m_Closure.IsLess(m_Closure); }
// Binding to non-const member functions
template < class X, class Y >
FastDelegate7(Y *pthis, DesiredRetType (X::* function_to_bind)(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6, Param7 p7) ) {
m_Closure.bindmemfunc(detail::implicit_cast<X*>(pthis), function_to_bind); }
template < class X, class Y >
inline void bind(Y *pthis, DesiredRetType (X::* function_to_bind)(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6, Param7 p7)) {
m_Closure.bindmemfunc(detail::implicit_cast<X*>(pthis), function_to_bind); }
// Binding to const member functions.
template < class X, class Y >
FastDelegate7(const Y *pthis, DesiredRetType (X::* function_to_bind)(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6, Param7 p7) const) {
m_Closure.bindconstmemfunc(detail::implicit_cast<const X*>(pthis), function_to_bind); }
template < class X, class Y >
inline void bind(const Y *pthis, DesiredRetType (X::* function_to_bind)(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6, Param7 p7) const) {
m_Closure.bindconstmemfunc(detail::implicit_cast<const X *>(pthis), function_to_bind); }
// Static functions. We convert them into a member function call.
// This constructor also provides implicit conversion
FastDelegate7(DesiredRetType (*function_to_bind)(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6, Param7 p7) ) {
bind(function_to_bind); }
// for efficiency, prevent creation of a temporary
void operator = (DesiredRetType (*function_to_bind)(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6, Param7 p7) ) {
bind(function_to_bind); }
inline void bind(DesiredRetType (*function_to_bind)(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6, Param7 p7)) {
m_Closure.bindstaticfunc(this, &FastDelegate7::InvokeStaticFunction,
function_to_bind); }
// Invoke the delegate
RetType operator() (Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6, Param7 p7) const {
return (m_Closure.GetClosureThis()->*(m_Closure.GetClosureMemPtr()))(p1, p2, p3, p4, p5, p6, p7); }
// Implicit conversion to "bool" using the safe_bool idiom
private:
typedef struct SafeBoolStruct {
int a_data_pointer_to_this_is_0_on_buggy_compilers;
StaticFunctionPtr m_nonzero;
} UselessTypedef;
typedef StaticFunctionPtr SafeBoolStruct::*unspecified_bool_type;
public:
operator unspecified_bool_type() const {
return empty()? 0: &SafeBoolStruct::m_nonzero;
}
// necessary to allow ==0 to work despite the safe_bool idiom
inline bool operator==(StaticFunctionPtr funcptr) {
return m_Closure.IsEqualToStaticFuncPtr(funcptr); }
inline bool operator!=(StaticFunctionPtr funcptr) {
return !m_Closure.IsEqualToStaticFuncPtr(funcptr); }
inline bool operator ! () const { // Is it bound to anything?
return !m_Closure; }
inline bool empty() const {
return !m_Closure; }
void clear() { m_Closure.clear();}
// Conversion to and from the DelegateMemento storage class
const DelegateMemento & GetMemento() { return m_Closure; }
void SetMemento(const DelegateMemento &any) { m_Closure.CopyFrom(this, any); }
private: // Invoker for static functions
RetType InvokeStaticFunction(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6, Param7 p7) const {
return (*(m_Closure.GetStaticFunction()))(p1, p2, p3, p4, p5, p6, p7); }
};
//N=8
template<class Param1, class Param2, class Param3, class Param4, class Param5, class Param6, class Param7, class Param8, class RetType=detail::DefaultVoid>
class FastDelegate8 {
private:
typedef typename detail::DefaultVoidToVoid<RetType>::type DesiredRetType;
typedef DesiredRetType (*StaticFunctionPtr)(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6, Param7 p7, Param8 p8);
typedef RetType (*UnvoidStaticFunctionPtr)(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6, Param7 p7, Param8 p8);
typedef RetType (detail::GenericClass::*GenericMemFn)(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6, Param7 p7, Param8 p8);
typedef detail::ClosurePtr<GenericMemFn, StaticFunctionPtr, UnvoidStaticFunctionPtr> ClosureType;
ClosureType m_Closure;
public:
// Typedefs to aid generic programming
typedef FastDelegate8 type;
// Construction and comparison functions
FastDelegate8() { clear(); }
FastDelegate8(const FastDelegate8 &x) {
m_Closure.CopyFrom(this, x.m_Closure); }
void operator = (const FastDelegate8 &x) {
m_Closure.CopyFrom(this, x.m_Closure); }
bool operator ==(const FastDelegate8 &x) const {
return m_Closure.IsEqual(x.m_Closure); }
bool operator !=(const FastDelegate8 &x) const {
return !m_Closure.IsEqual(x.m_Closure); }
bool operator <(const FastDelegate8 &x) const {
return m_Closure.IsLess(x.m_Closure); }
bool operator >(const FastDelegate8 &x) const {
return x.m_Closure.IsLess(m_Closure); }
// Binding to non-const member functions
template < class X, class Y >
FastDelegate8(Y *pthis, DesiredRetType (X::* function_to_bind)(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6, Param7 p7, Param8 p8) ) {
m_Closure.bindmemfunc(detail::implicit_cast<X*>(pthis), function_to_bind); }
template < class X, class Y >
inline void bind(Y *pthis, DesiredRetType (X::* function_to_bind)(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6, Param7 p7, Param8 p8)) {
m_Closure.bindmemfunc(detail::implicit_cast<X*>(pthis), function_to_bind); }
// Binding to const member functions.
template < class X, class Y >
FastDelegate8(const Y *pthis, DesiredRetType (X::* function_to_bind)(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6, Param7 p7, Param8 p8) const) {
m_Closure.bindconstmemfunc(detail::implicit_cast<const X*>(pthis), function_to_bind); }
template < class X, class Y >
inline void bind(const Y *pthis, DesiredRetType (X::* function_to_bind)(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6, Param7 p7, Param8 p8) const) {
m_Closure.bindconstmemfunc(detail::implicit_cast<const X *>(pthis), function_to_bind); }
// Static functions. We convert them into a member function call.
// This constructor also provides implicit conversion
FastDelegate8(DesiredRetType (*function_to_bind)(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6, Param7 p7, Param8 p8) ) {
bind(function_to_bind); }
// for efficiency, prevent creation of a temporary
void operator = (DesiredRetType (*function_to_bind)(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6, Param7 p7, Param8 p8) ) {
bind(function_to_bind); }
inline void bind(DesiredRetType (*function_to_bind)(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6, Param7 p7, Param8 p8)) {
m_Closure.bindstaticfunc(this, &FastDelegate8::InvokeStaticFunction,
function_to_bind); }
// Invoke the delegate
RetType operator() (Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6, Param7 p7, Param8 p8) const {
return (m_Closure.GetClosureThis()->*(m_Closure.GetClosureMemPtr()))(p1, p2, p3, p4, p5, p6, p7, p8); }
// Implicit conversion to "bool" using the safe_bool idiom
private:
typedef struct SafeBoolStruct {
int a_data_pointer_to_this_is_0_on_buggy_compilers;
StaticFunctionPtr m_nonzero;
} UselessTypedef;
typedef StaticFunctionPtr SafeBoolStruct::*unspecified_bool_type;
public:
operator unspecified_bool_type() const {
return empty()? 0: &SafeBoolStruct::m_nonzero;
}
// necessary to allow ==0 to work despite the safe_bool idiom
inline bool operator==(StaticFunctionPtr funcptr) {
return m_Closure.IsEqualToStaticFuncPtr(funcptr); }
inline bool operator!=(StaticFunctionPtr funcptr) {
return !m_Closure.IsEqualToStaticFuncPtr(funcptr); }
inline bool operator ! () const { // Is it bound to anything?
return !m_Closure; }
inline bool empty() const {
return !m_Closure; }
void clear() { m_Closure.clear();}
// Conversion to and from the DelegateMemento storage class
const DelegateMemento & GetMemento() { return m_Closure; }
void SetMemento(const DelegateMemento &any) { m_Closure.CopyFrom(this, any); }
private: // Invoker for static functions
RetType InvokeStaticFunction(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6, Param7 p7, Param8 p8) const {
return (*(m_Closure.GetStaticFunction()))(p1, p2, p3, p4, p5, p6, p7, p8); }
};
////////////////////////////////////////////////////////////////////////////////
// Fast Delegates, part 4:
//
// FastDelegate<> class (Original author: Jody Hagins)
// Allows boost::function style syntax like:
// FastDelegate< double (int, long) >
// instead of:
// FastDelegate2< int, long, double >
//
////////////////////////////////////////////////////////////////////////////////
#ifdef FASTDELEGATE_ALLOW_FUNCTION_TYPE_SYNTAX
// Declare FastDelegate as a class template. It will be specialized
// later for all number of arguments.
template <typename Signature>
class FastDelegate;
//N=0
// Specialization to allow use of
// FastDelegate< R ( ) >
// instead of
// FastDelegate0 < R >
template<typename R>
class FastDelegate< R ( ) >
// Inherit from FastDelegate0 so that it can be treated just like a FastDelegate0
: public FastDelegate0 < R >
{
public:
// Make using the base type a bit easier via typedef.
typedef FastDelegate0 < R > BaseType;
// Allow users access to the specific type of this delegate.
typedef FastDelegate SelfType;
// Mimic the base class constructors.
FastDelegate() : BaseType() { }
template < class X, class Y >
FastDelegate(Y * pthis,
R (X::* function_to_bind)( ))
: BaseType(pthis, function_to_bind) { }
template < class X, class Y >
FastDelegate(const Y *pthis,
R (X::* function_to_bind)( ) const)
: BaseType(pthis, function_to_bind)
{ }
FastDelegate(R (*function_to_bind)( ))
: BaseType(function_to_bind) { }
void operator = (const BaseType &x) {
*static_cast<BaseType*>(this) = x; }
};
//N=1
// Specialization to allow use of
// FastDelegate< R ( Param1 ) >
// instead of
// FastDelegate1 < Param1, R >
template<typename R, class Param1>
class FastDelegate< R ( Param1 ) >
// Inherit from FastDelegate1 so that it can be treated just like a FastDelegate1
: public FastDelegate1 < Param1, R >
{
public:
// Make using the base type a bit easier via typedef.
typedef FastDelegate1 < Param1, R > BaseType;
// Allow users access to the specific type of this delegate.
typedef FastDelegate SelfType;
// Mimic the base class constructors.
FastDelegate() : BaseType() { }
template < class X, class Y >
FastDelegate(Y * pthis,
R (X::* function_to_bind)( Param1 p1 ))
: BaseType(pthis, function_to_bind) { }
template < class X, class Y >
FastDelegate(const Y *pthis,
R (X::* function_to_bind)( Param1 p1 ) const)
: BaseType(pthis, function_to_bind)
{ }
FastDelegate(R (*function_to_bind)( Param1 p1 ))
: BaseType(function_to_bind) { }
void operator = (const BaseType &x) {
*static_cast<BaseType*>(this) = x; }
};
//N=2
// Specialization to allow use of
// FastDelegate< R ( Param1, Param2 ) >
// instead of
// FastDelegate2 < Param1, Param2, R >
template<typename R, class Param1, class Param2>
class FastDelegate< R ( Param1, Param2 ) >
// Inherit from FastDelegate2 so that it can be treated just like a FastDelegate2
: public FastDelegate2 < Param1, Param2, R >
{
public:
// Make using the base type a bit easier via typedef.
typedef FastDelegate2 < Param1, Param2, R > BaseType;
// Allow users access to the specific type of this delegate.
typedef FastDelegate SelfType;
// Mimic the base class constructors.
FastDelegate() : BaseType() { }
template < class X, class Y >
FastDelegate(Y * pthis,
R (X::* function_to_bind)( Param1 p1, Param2 p2 ))
: BaseType(pthis, function_to_bind) { }
template < class X, class Y >
FastDelegate(const Y *pthis,
R (X::* function_to_bind)( Param1 p1, Param2 p2 ) const)
: BaseType(pthis, function_to_bind)
{ }
FastDelegate(R (*function_to_bind)( Param1 p1, Param2 p2 ))
: BaseType(function_to_bind) { }
void operator = (const BaseType &x) {
*static_cast<BaseType*>(this) = x; }
};
//N=3
// Specialization to allow use of
// FastDelegate< R ( Param1, Param2, Param3 ) >
// instead of
// FastDelegate3 < Param1, Param2, Param3, R >
template<typename R, class Param1, class Param2, class Param3>
class FastDelegate< R ( Param1, Param2, Param3 ) >
// Inherit from FastDelegate3 so that it can be treated just like a FastDelegate3
: public FastDelegate3 < Param1, Param2, Param3, R >
{
public:
// Make using the base type a bit easier via typedef.
typedef FastDelegate3 < Param1, Param2, Param3, R > BaseType;
// Allow users access to the specific type of this delegate.
typedef FastDelegate SelfType;
// Mimic the base class constructors.
FastDelegate() : BaseType() { }
template < class X, class Y >
FastDelegate(Y * pthis,
R (X::* function_to_bind)( Param1 p1, Param2 p2, Param3 p3 ))
: BaseType(pthis, function_to_bind) { }
template < class X, class Y >
FastDelegate(const Y *pthis,
R (X::* function_to_bind)( Param1 p1, Param2 p2, Param3 p3 ) const)
: BaseType(pthis, function_to_bind)
{ }
FastDelegate(R (*function_to_bind)( Param1 p1, Param2 p2, Param3 p3 ))
: BaseType(function_to_bind) { }
void operator = (const BaseType &x) {
*static_cast<BaseType*>(this) = x; }
};
//N=4
// Specialization to allow use of
// FastDelegate< R ( Param1, Param2, Param3, Param4 ) >
// instead of
// FastDelegate4 < Param1, Param2, Param3, Param4, R >
template<typename R, class Param1, class Param2, class Param3, class Param4>
class FastDelegate< R ( Param1, Param2, Param3, Param4 ) >
// Inherit from FastDelegate4 so that it can be treated just like a FastDelegate4
: public FastDelegate4 < Param1, Param2, Param3, Param4, R >
{
public:
// Make using the base type a bit easier via typedef.
typedef FastDelegate4 < Param1, Param2, Param3, Param4, R > BaseType;
// Allow users access to the specific type of this delegate.
typedef FastDelegate SelfType;
// Mimic the base class constructors.
FastDelegate() : BaseType() { }
template < class X, class Y >
FastDelegate(Y * pthis,
R (X::* function_to_bind)( Param1 p1, Param2 p2, Param3 p3, Param4 p4 ))
: BaseType(pthis, function_to_bind) { }
template < class X, class Y >
FastDelegate(const Y *pthis,
R (X::* function_to_bind)( Param1 p1, Param2 p2, Param3 p3, Param4 p4 ) const)
: BaseType(pthis, function_to_bind)
{ }
FastDelegate(R (*function_to_bind)( Param1 p1, Param2 p2, Param3 p3, Param4 p4 ))
: BaseType(function_to_bind) { }
void operator = (const BaseType &x) {
*static_cast<BaseType*>(this) = x; }
};
//N=5
// Specialization to allow use of
// FastDelegate< R ( Param1, Param2, Param3, Param4, Param5 ) >
// instead of
// FastDelegate5 < Param1, Param2, Param3, Param4, Param5, R >
template<typename R, class Param1, class Param2, class Param3, class Param4, class Param5>
class FastDelegate< R ( Param1, Param2, Param3, Param4, Param5 ) >
// Inherit from FastDelegate5 so that it can be treated just like a FastDelegate5
: public FastDelegate5 < Param1, Param2, Param3, Param4, Param5, R >
{
public:
// Make using the base type a bit easier via typedef.
typedef FastDelegate5 < Param1, Param2, Param3, Param4, Param5, R > BaseType;
// Allow users access to the specific type of this delegate.
typedef FastDelegate SelfType;
// Mimic the base class constructors.
FastDelegate() : BaseType() { }
template < class X, class Y >
FastDelegate(Y * pthis,
R (X::* function_to_bind)( Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5 ))
: BaseType(pthis, function_to_bind) { }
template < class X, class Y >
FastDelegate(const Y *pthis,
R (X::* function_to_bind)( Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5 ) const)
: BaseType(pthis, function_to_bind)
{ }
FastDelegate(R (*function_to_bind)( Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5 ))
: BaseType(function_to_bind) { }
void operator = (const BaseType &x) {
*static_cast<BaseType*>(this) = x; }
};
//N=6
// Specialization to allow use of
// FastDelegate< R ( Param1, Param2, Param3, Param4, Param5, Param6 ) >
// instead of
// FastDelegate6 < Param1, Param2, Param3, Param4, Param5, Param6, R >
template<typename R, class Param1, class Param2, class Param3, class Param4, class Param5, class Param6>
class FastDelegate< R ( Param1, Param2, Param3, Param4, Param5, Param6 ) >
// Inherit from FastDelegate6 so that it can be treated just like a FastDelegate6
: public FastDelegate6 < Param1, Param2, Param3, Param4, Param5, Param6, R >
{
public:
// Make using the base type a bit easier via typedef.
typedef FastDelegate6 < Param1, Param2, Param3, Param4, Param5, Param6, R > BaseType;
// Allow users access to the specific type of this delegate.
typedef FastDelegate SelfType;
// Mimic the base class constructors.
FastDelegate() : BaseType() { }
template < class X, class Y >
FastDelegate(Y * pthis,
R (X::* function_to_bind)( Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6 ))
: BaseType(pthis, function_to_bind) { }
template < class X, class Y >
FastDelegate(const Y *pthis,
R (X::* function_to_bind)( Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6 ) const)
: BaseType(pthis, function_to_bind)
{ }
FastDelegate(R (*function_to_bind)( Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6 ))
: BaseType(function_to_bind) { }
void operator = (const BaseType &x) {
*static_cast<BaseType*>(this) = x; }
};
//N=7
// Specialization to allow use of
// FastDelegate< R ( Param1, Param2, Param3, Param4, Param5, Param6, Param7 ) >
// instead of
// FastDelegate7 < Param1, Param2, Param3, Param4, Param5, Param6, Param7, R >
template<typename R, class Param1, class Param2, class Param3, class Param4, class Param5, class Param6, class Param7>
class FastDelegate< R ( Param1, Param2, Param3, Param4, Param5, Param6, Param7 ) >
// Inherit from FastDelegate7 so that it can be treated just like a FastDelegate7
: public FastDelegate7 < Param1, Param2, Param3, Param4, Param5, Param6, Param7, R >
{
public:
// Make using the base type a bit easier via typedef.
typedef FastDelegate7 < Param1, Param2, Param3, Param4, Param5, Param6, Param7, R > BaseType;
// Allow users access to the specific type of this delegate.
typedef FastDelegate SelfType;
// Mimic the base class constructors.
FastDelegate() : BaseType() { }
template < class X, class Y >
FastDelegate(Y * pthis,
R (X::* function_to_bind)( Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6, Param7 p7 ))
: BaseType(pthis, function_to_bind) { }
template < class X, class Y >
FastDelegate(const Y *pthis,
R (X::* function_to_bind)( Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6, Param7 p7 ) const)
: BaseType(pthis, function_to_bind)
{ }
FastDelegate(R (*function_to_bind)( Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6, Param7 p7 ))
: BaseType(function_to_bind) { }
void operator = (const BaseType &x) {
*static_cast<BaseType*>(this) = x; }
};
//N=8
// Specialization to allow use of
// FastDelegate< R ( Param1, Param2, Param3, Param4, Param5, Param6, Param7, Param8 ) >
// instead of
// FastDelegate8 < Param1, Param2, Param3, Param4, Param5, Param6, Param7, Param8, R >
template<typename R, class Param1, class Param2, class Param3, class Param4, class Param5, class Param6, class Param7, class Param8>
class FastDelegate< R ( Param1, Param2, Param3, Param4, Param5, Param6, Param7, Param8 ) >
// Inherit from FastDelegate8 so that it can be treated just like a FastDelegate8
: public FastDelegate8 < Param1, Param2, Param3, Param4, Param5, Param6, Param7, Param8, R >
{
public:
// Make using the base type a bit easier via typedef.
typedef FastDelegate8 < Param1, Param2, Param3, Param4, Param5, Param6, Param7, Param8, R > BaseType;
// Allow users access to the specific type of this delegate.
typedef FastDelegate SelfType;
// Mimic the base class constructors.
FastDelegate() : BaseType() { }
template < class X, class Y >
FastDelegate(Y * pthis,
R (X::* function_to_bind)( Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6, Param7 p7, Param8 p8 ))
: BaseType(pthis, function_to_bind) { }
template < class X, class Y >
FastDelegate(const Y *pthis,
R (X::* function_to_bind)( Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6, Param7 p7, Param8 p8 ) const)
: BaseType(pthis, function_to_bind)
{ }
FastDelegate(R (*function_to_bind)( Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6, Param7 p7, Param8 p8 ))
: BaseType(function_to_bind) { }
void operator = (const BaseType &x) {
*static_cast<BaseType*>(this) = x; }
};
#endif //FASTDELEGATE_ALLOW_FUNCTION_TYPE_SYNTAX
////////////////////////////////////////////////////////////////////////////////
// Fast Delegates, part 5:
//
// MakeDelegate() helper function
//
// MakeDelegate(&x, &X::func) returns a fastdelegate of the type
// necessary for calling x.func() with the correct number of arguments.
// This makes it possible to eliminate many typedefs from user code.
//
////////////////////////////////////////////////////////////////////////////////
// Also declare overloads of a MakeDelegate() global function to
// reduce the need for typedefs.
// We need seperate overloads for const and non-const member functions.
// Also, because of the weird rule about the class of derived member function pointers,
// implicit downcasts may need to be applied later to the 'this' pointer.
// That's why two classes (X and Y) appear in the definitions. Y must be implicitly
// castable to X.
// Workaround for VC6. VC6 needs void return types converted into DefaultVoid.
// GCC 3.2 and later won't compile this unless it's preceded by 'typename',
// but VC6 doesn't allow 'typename' in this context.
// So, I have to use a macro.
#ifdef FASTDLGT_VC6
#define FASTDLGT_RETTYPE detail::VoidToDefaultVoid<RetType>::type
#else
#define FASTDLGT_RETTYPE RetType
#endif
//N=0
template <class X, class Y, class RetType>
FastDelegate0<FASTDLGT_RETTYPE> MakeDelegate(Y* x, RetType (X::*func)()) {
return FastDelegate0<FASTDLGT_RETTYPE>(x, func);
}
template <class X, class Y, class RetType>
FastDelegate0<FASTDLGT_RETTYPE> MakeDelegate(Y* x, RetType (X::*func)() const) {
return FastDelegate0<FASTDLGT_RETTYPE>(x, func);
}
//N=1
template <class X, class Y, class Param1, class RetType>
FastDelegate1<Param1, FASTDLGT_RETTYPE> MakeDelegate(Y* x, RetType (X::*func)(Param1 p1)) {
return FastDelegate1<Param1, FASTDLGT_RETTYPE>(x, func);
}
template <class X, class Y, class Param1, class RetType>
FastDelegate1<Param1, FASTDLGT_RETTYPE> MakeDelegate(Y* x, RetType (X::*func)(Param1 p1) const) {
return FastDelegate1<Param1, FASTDLGT_RETTYPE>(x, func);
}
//N=2
template <class X, class Y, class Param1, class Param2, class RetType>
FastDelegate2<Param1, Param2, FASTDLGT_RETTYPE> MakeDelegate(Y* x, RetType (X::*func)(Param1 p1, Param2 p2)) {
return FastDelegate2<Param1, Param2, FASTDLGT_RETTYPE>(x, func);
}
template <class X, class Y, class Param1, class Param2, class RetType>
FastDelegate2<Param1, Param2, FASTDLGT_RETTYPE> MakeDelegate(Y* x, RetType (X::*func)(Param1 p1, Param2 p2) const) {
return FastDelegate2<Param1, Param2, FASTDLGT_RETTYPE>(x, func);
}
//N=3
template <class X, class Y, class Param1, class Param2, class Param3, class RetType>
FastDelegate3<Param1, Param2, Param3, FASTDLGT_RETTYPE> MakeDelegate(Y* x, RetType (X::*func)(Param1 p1, Param2 p2, Param3 p3)) {
return FastDelegate3<Param1, Param2, Param3, FASTDLGT_RETTYPE>(x, func);
}
template <class X, class Y, class Param1, class Param2, class Param3, class RetType>
FastDelegate3<Param1, Param2, Param3, FASTDLGT_RETTYPE> MakeDelegate(Y* x, RetType (X::*func)(Param1 p1, Param2 p2, Param3 p3) const) {
return FastDelegate3<Param1, Param2, Param3, FASTDLGT_RETTYPE>(x, func);
}
//N=4
template <class X, class Y, class Param1, class Param2, class Param3, class Param4, class RetType>
FastDelegate4<Param1, Param2, Param3, Param4, FASTDLGT_RETTYPE> MakeDelegate(Y* x, RetType (X::*func)(Param1 p1, Param2 p2, Param3 p3, Param4 p4)) {
return FastDelegate4<Param1, Param2, Param3, Param4, FASTDLGT_RETTYPE>(x, func);
}
template <class X, class Y, class Param1, class Param2, class Param3, class Param4, class RetType>
FastDelegate4<Param1, Param2, Param3, Param4, FASTDLGT_RETTYPE> MakeDelegate(Y* x, RetType (X::*func)(Param1 p1, Param2 p2, Param3 p3, Param4 p4) const) {
return FastDelegate4<Param1, Param2, Param3, Param4, FASTDLGT_RETTYPE>(x, func);
}
//N=5
template <class X, class Y, class Param1, class Param2, class Param3, class Param4, class Param5, class RetType>
FastDelegate5<Param1, Param2, Param3, Param4, Param5, FASTDLGT_RETTYPE> MakeDelegate(Y* x, RetType (X::*func)(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5)) {
return FastDelegate5<Param1, Param2, Param3, Param4, Param5, FASTDLGT_RETTYPE>(x, func);
}
template <class X, class Y, class Param1, class Param2, class Param3, class Param4, class Param5, class RetType>
FastDelegate5<Param1, Param2, Param3, Param4, Param5, FASTDLGT_RETTYPE> MakeDelegate(Y* x, RetType (X::*func)(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5) const) {
return FastDelegate5<Param1, Param2, Param3, Param4, Param5, FASTDLGT_RETTYPE>(x, func);
}
//N=6
template <class X, class Y, class Param1, class Param2, class Param3, class Param4, class Param5, class Param6, class RetType>
FastDelegate6<Param1, Param2, Param3, Param4, Param5, Param6, FASTDLGT_RETTYPE> MakeDelegate(Y* x, RetType (X::*func)(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6)) {
return FastDelegate6<Param1, Param2, Param3, Param4, Param5, Param6, FASTDLGT_RETTYPE>(x, func);
}
template <class X, class Y, class Param1, class Param2, class Param3, class Param4, class Param5, class Param6, class RetType>
FastDelegate6<Param1, Param2, Param3, Param4, Param5, Param6, FASTDLGT_RETTYPE> MakeDelegate(Y* x, RetType (X::*func)(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6) const) {
return FastDelegate6<Param1, Param2, Param3, Param4, Param5, Param6, FASTDLGT_RETTYPE>(x, func);
}
//N=7
template <class X, class Y, class Param1, class Param2, class Param3, class Param4, class Param5, class Param6, class Param7, class RetType>
FastDelegate7<Param1, Param2, Param3, Param4, Param5, Param6, Param7, FASTDLGT_RETTYPE> MakeDelegate(Y* x, RetType (X::*func)(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6, Param7 p7)) {
return FastDelegate7<Param1, Param2, Param3, Param4, Param5, Param6, Param7, FASTDLGT_RETTYPE>(x, func);
}
template <class X, class Y, class Param1, class Param2, class Param3, class Param4, class Param5, class Param6, class Param7, class RetType>
FastDelegate7<Param1, Param2, Param3, Param4, Param5, Param6, Param7, FASTDLGT_RETTYPE> MakeDelegate(Y* x, RetType (X::*func)(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6, Param7 p7) const) {
return FastDelegate7<Param1, Param2, Param3, Param4, Param5, Param6, Param7, FASTDLGT_RETTYPE>(x, func);
}
//N=8
template <class X, class Y, class Param1, class Param2, class Param3, class Param4, class Param5, class Param6, class Param7, class Param8, class RetType>
FastDelegate8<Param1, Param2, Param3, Param4, Param5, Param6, Param7, Param8, FASTDLGT_RETTYPE> MakeDelegate(Y* x, RetType (X::*func)(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6, Param7 p7, Param8 p8)) {
return FastDelegate8<Param1, Param2, Param3, Param4, Param5, Param6, Param7, Param8, FASTDLGT_RETTYPE>(x, func);
}
template <class X, class Y, class Param1, class Param2, class Param3, class Param4, class Param5, class Param6, class Param7, class Param8, class RetType>
FastDelegate8<Param1, Param2, Param3, Param4, Param5, Param6, Param7, Param8, FASTDLGT_RETTYPE> MakeDelegate(Y* x, RetType (X::*func)(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6, Param7 p7, Param8 p8) const) {
return FastDelegate8<Param1, Param2, Param3, Param4, Param5, Param6, Param7, Param8, FASTDLGT_RETTYPE>(x, func);
}
// clean up after ourselves...
#undef FASTDLGT_RETTYPE
} // namespace fastdelegate
#endif // !defined(FASTDELEGATE_H)
| [
"[email protected]"
]
| [
[
[
1,
1970
]
]
]
|
6d855633e5bde4183f1340d5d6d72e75cfd71ae1 | e618b452106f251f3ac7cf929da9c79256c3aace | /src/lib/cpp/URLResolverImpl.h | c5ac37941cfed64fab942fa30cb4da0afb9ebbbf | []
| no_license | dlinsin/yfrog | 714957669da86deff3a093a7714e7d800c9260d8 | 513e0d64a0ff749e902e797524ad4a521ead37f8 | refs/heads/master | 2020-12-25T15:40:54.751312 | 2010-04-13T16:31:15 | 2010-04-13T16:31:15 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,022 | h | #pragma once
#include "uploader/URLResolver.h"
#include "ImageShackAPI.h"
#include "http/ServerResolver.h"
namespace ImageShack {
using namespace API::ImageShack;
using namespace UPLOAD;
/**
* ImageShack URL Resolver implementation.
*
* @author Alexander Kozlov
*/
class URLResolver : public IUniversalUploaderURLResolver<UploadInfo>
{
private:
CServerResolver m_image_resolver;
CServerResolver m_video_resolver;
public:
URLResolver();
~URLResolver();
public:
static SmartReleasePtr<UPLOAD::IUniversalUploaderURLResolver<API::ImageShack::UploadInfo> > NewInstance()
{
return SmartReleasePtr<UPLOAD::IUniversalUploaderURLResolver<API::ImageShack::UploadInfo> >(new URLResolver());
}
public:
/**
* Must return URL for POST data request
*/
virtual CStringW GetURL(const UploadInfo &item);
/**
* Called to destroy
*/
virtual void Release()
{
delete this;
}
};
}//namespace ImageShack
| [
"[email protected]"
]
| [
[
[
1,
48
]
]
]
|
b80167d801f9165e3a9d5b7e09dda0380cc52d98 | 11039c144f5d93bb34c0d1124f4df1c013a887cb | /qtsingleapplication.cpp | 53216edf50c61381cb31a2d1d2ff908437be624e | []
| no_license | pent9304/mysms-app | 0c7280a20bdebe5f23bdebb795857895e9fd2949 | 28f7cbe950b2eb22c087b5349674139b9bbf6b43 | refs/heads/master | 2021-01-10T05:28:02.757427 | 2011-10-25T08:43:49 | 2011-10-25T08:43:49 | 52,361,860 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 12,100 | cpp | /****************************************************************************
**
** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation ([email protected])
**
** This file is part of a Qt Solutions component.
**
** Commercial Usage
** Licensees holding valid Qt Commercial licenses may use this file in
** accordance with the Qt Solutions Commercial License Agreement provided
** with the Software or, alternatively, in accordance with the terms
** contained in a written agreement between you and Nokia.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Nokia gives you certain
** additional rights. These rights are described in the Nokia Qt LGPL
** Exception version 1.1, included in the file LGPL_EXCEPTION.txt in this
** package.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3.0 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU General Public License version 3.0 requirements will be
** met: http://www.gnu.org/copyleft/gpl.html.
**
** Please note Third Party Software included with Qt Solutions may impose
** additional restrictions and it is the user's responsibility to ensure
** that they have met the licensing requirements of the GPL, LGPL, or Qt
** Solutions Commercial license and the relevant license of the Third
** Party Software they are using.
**
** If you are unsure which license is appropriate for your use, please
** contact Nokia at [email protected].
**
****************************************************************************/
#include "qtsingleapplication.h"
#include "qtlocalpeer.h"
#include <QtGui/QWidget>
#include <QtGui/QMessageBox>
/*!
\class QtSingleApplication qtsingleapplication.h
\brief The QtSingleApplication class provides an API to detect and
communicate with running instances of an application.
This class allows you to create applications where only one
instance should be running at a time. I.e., if the user tries to
launch another instance, the already running instance will be
activated instead. Another usecase is a client-server system,
where the first started instance will assume the role of server,
and the later instances will act as clients of that server.
By default, the full path of the executable file is used to
determine whether two processes are instances of the same
application. You can also provide an explicit identifier string
that will be compared instead.
The application should create the QtSingleApplication object early
in the startup phase, and call isRunning() or sendMessage() to
find out if another instance of this application is already
running. Startup parameters (e.g. the name of the file the user
wanted this new instance to open) can be passed to the running
instance in the sendMessage() function.
If isRunning() or sendMessage() returns false, it means that no
other instance is running, and this instance has assumed the role
as the running instance. The application should continue with the
initialization of the application user interface before entering
the event loop with exec(), as normal. The messageReceived()
signal will be emitted when the application receives messages from
another instance of the same application.
If isRunning() or sendMessage() returns true, another instance is
already running, and the application should terminate or enter
client mode.
If a message is received it might be helpful to the user to raise
the application so that it becomes visible. To facilitate this,
QtSingleApplication provides the setActivationWindow() function
and the activateWindow() slot.
Here's an example that shows how to convert an existing
application to use QtSingleApplication. It is very simple and does
not make use of all QtSingleApplication's functionality (see the
examples for that).
\code
// Original
int main(int argc, char **argv)
{
QApplication app(argc, argv);
MyMainWidget mmw;
mmw.show();
return app.exec();
}
// Single instance
int main(int argc, char **argv)
{
QtSingleApplication app(argc, argv);
if (app.isRunning())
return 0;
MyMainWidget mmw;
app.setActivationWindow(&mmw);
mmw.show();
return app.exec();
}
\endcode
Once this QtSingleApplication instance is destroyed(for example,
when the user quits), when the user next attempts to run the
application this instance will not, of course, be encountered. The
next instance to call isRunning() or sendMessage() will assume the
role as the new running instance.
For console (non-GUI) applications, QtSingleCoreApplication may be
used instead of this class, to avoid the dependency on the QtGui
library.
\sa QtSingleCoreApplication
*/
void QtSingleApplication::sysInit(const QString &appId)
{
actWin = 0;
peer = new QtLocalPeer(this, appId);
connect(peer, SIGNAL(messageReceived(const QString&)), SIGNAL(messageReceived(const QString&)));
}
/*!
Creates a QtSingleApplication object. The application identifier
will be QCoreApplication::applicationFilePath(). \a argc, \a
argv, and \a GUIenabled are passed on to the QAppliation constructor.
If you are creating a console application (i.e. setting \a
GUIenabled to false), you may consider using
QtSingleCoreApplication instead.
*/
QtSingleApplication::QtSingleApplication(int &argc, char **argv, bool GUIenabled)
: QApplication(argc, argv, GUIenabled)
{
sysInit();
}
/*!
Creates a QtSingleApplication object with the application
identifier \a appId. \a argc and \a argv are passed on to the
QAppliation constructor.
*/
QtSingleApplication::QtSingleApplication(const QString &appId, int &argc, char **argv)
: QApplication(argc, argv)
{
sysInit(appId);
}
/*!
Creates a QtSingleApplication object. The application identifier
will be QCoreApplication::applicationFilePath(). \a argc, \a
argv, and \a type are passed on to the QAppliation constructor.
*/
QtSingleApplication::QtSingleApplication(int &argc, char **argv, Type type)
: QApplication(argc, argv, type)
{
sysInit();
}
#if defined(Q_WS_X11)
/*!
Special constructor for X11, ref. the documentation of
QApplication's corresponding constructor. The application identifier
will be QCoreApplication::applicationFilePath(). \a dpy, \a visual,
and \a cmap are passed on to the QApplication constructor.
*/
QtSingleApplication::QtSingleApplication(Display* dpy, Qt::HANDLE visual, Qt::HANDLE cmap)
: QApplication(dpy, visual, cmap)
{
sysInit();
}
/*!
Special constructor for X11, ref. the documentation of
QApplication's corresponding constructor. The application identifier
will be QCoreApplication::applicationFilePath(). \a dpy, \a argc, \a
argv, \a visual, and \a cmap are passed on to the QApplication
constructor.
*/
QtSingleApplication::QtSingleApplication(Display *dpy, int &argc, char **argv, Qt::HANDLE visual, Qt::HANDLE cmap)
: QApplication(dpy, argc, argv, visual, cmap)
{
sysInit();
}
/*!
Special constructor for X11, ref. the documentation of
QApplication's corresponding constructor. The application identifier
will be \a appId. \a dpy, \a argc, \a
argv, \a visual, and \a cmap are passed on to the QApplication
constructor.
*/
QtSingleApplication::QtSingleApplication(Display* dpy, const QString &appId, int argc, char **argv, Qt::HANDLE visual, Qt::HANDLE cmap)
: QApplication(dpy, argc, argv, visual, cmap)
{
sysInit(appId);
}
#endif
/*!
Returns true if another instance of this application is running;
otherwise false.
This function does not find instances of this application that are
being run by a different user (on Windows: that are running in
another session).
\sa sendMessage()
*/
bool QtSingleApplication::isRunning()
{
return peer->isClient();
}
/*!
Tries to send the text \a message to the currently running
instance. The QtSingleApplication object in the running instance
will emit the messageReceived() signal when it receives the
message.
This function returns true if the message has been sent to, and
processed by, the current instance. If there is no instance
currently running, or if the running instance fails to process the
message within \a timeout milliseconds, this function return false.
\sa isRunning(), messageReceived()
*/
bool QtSingleApplication::sendMessage(const QString &message, int timeout)
{
return peer->sendMessage(message, timeout);
}
/*!
Returns the application identifier. Two processes with the same
identifier will be regarded as instances of the same application.
*/
QString QtSingleApplication::id() const
{
return peer->applicationId();
}
/*!
Sets the activation window of this application to \a aw. The
activation window is the widget that will be activated by
activateWindow(). This is typically the application's main window.
If \a activateOnMessage is true (the default), the window will be
activated automatically every time a message is received, just prior
to the messageReceived() signal being emitted.
\sa activateWindow(), messageReceived()
*/
void QtSingleApplication::setActivationWindow(QWidget* aw, bool activateOnMessage)
{
actWin = aw;
if (activateOnMessage)
connect(peer, SIGNAL(messageReceived(const QString&)), this, SLOT(activateWindow()));
else
disconnect(peer, SIGNAL(messageReceived(const QString&)), this, SLOT(activateWindow()));
}
/*!
Returns the applications activation window if one has been set by
calling setActivationWindow(), otherwise returns 0.
\sa setActivationWindow()
*/
QWidget* QtSingleApplication::activationWindow() const
{
return actWin;
}
/*!
De-minimizes, raises, and activates this application's activation window.
This function does nothing if no activation window has been set.
This is a convenience function to show the user that this
application instance has been activated when he has tried to start
another instance.
This function should typically be called in response to the
messageReceived() signal. By default, that will happen
automatically, if an activation window has been set.
\sa setActivationWindow(), messageReceived(), initialize()
*/
void QtSingleApplication::activateWindow()
{
if (actWin) {
actWin->setWindowState(actWin->windowState() & ~Qt::WindowMinimized);
actWin->raise();
actWin->activateWindow();
}
}
/*!
\fn void QtSingleApplication::messageReceived(const QString& message)
This signal is emitted when the current instance receives a \a
message from another instance of this application.
\sa sendMessage(), setActivationWindow(), activateWindow()
*/
/*!
\fn void QtSingleApplication::initialize(bool dummy = true)
\obsolete
*/
| [
"[email protected]"
]
| [
[
[
1,
352
]
]
]
|
9edcaa6ed9802a12df32ec31a79240210a40f90c | 119ba245bea18df8d27b84ee06e152b35c707da1 | /unreal/branches/robots/qrgui/interpreters/robots/details/robotImplementations/sensorImplementations/unrealSensorImplementation.h | f05ec70f0838d9f2e1dd5d916abb40366d1535e3 | []
| 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 | 823 | h | #pragma once
#include "abstractSensorImplementation.h"
#include "../../../robotCommunicationInterface.h"
#include "../../robotCommandConstants.h"
#include "../../d2RobotModel/d2RobotModel.h"
namespace qReal {
namespace interpreters {
namespace robots {
namespace details {
namespace robotImplementations {
namespace sensorImplementations {
class UnrealSensorImplementation : public AbstractSensorImplementation
{
Q_OBJECT
public:
UnrealSensorImplementation(inputPort::InputPortEnum const &port, d2Model::D2RobotModel *d2Model);
virtual ~UnrealSensorImplementation() {};
virtual void read();
protected:
d2Model::D2RobotModel *mD2Model;
lowLevelSensorType::SensorTypeEnum mSensorType;
sensorMode::SensorModeEnum mSensorMode;
bool mIsConfigured;
bool mResetDone;
};
}
}
}
}
}
}
| [
"[email protected]"
]
| [
[
[
1,
35
]
]
]
|
b26209e0f752141c691c8bc6f5a8b4957b5156f2 | b1936b91f941b5ed7c4ef6263fbe68aab7bf3c08 | /smartkid.h | 1cfbcfedada7d072a6c4e69af6a84bfc8abf8613 | []
| no_license | philsong/smartkid | dd0f920f505fbf7db3d60de9a2cbc08b33885878 | 1eb26544e206cb1f1ca97b72d4a85ad461827f05 | refs/heads/master | 2021-01-18T17:17:33.679817 | 2006-12-29T14:37:53 | 2006-12-29T14:37:53 | 32,116,947 | 1 | 0 | null | null | null | null | GB18030 | C++ | false | false | 491 | h | // smartkid.h : PROJECT_NAME 应用程序的主头文件
//
#pragma once
#ifndef __AFXWIN_H__
#error 在包含用于 PCH 的此文件之前包含“stdafx.h”
#endif
#include "resource.h" // 主符号
// CsmartkidApp:
// 有关此类的实现,请参阅 smartkid.cpp
//
class CsmartkidApp : public CWinApp
{
public:
CsmartkidApp();
// 重写
public:
virtual BOOL InitInstance();
// 实现
DECLARE_MESSAGE_MAP()
};
extern CsmartkidApp theApp;
| [
"songbohr@99f8ccfc-bd25-0410-92d8-6ff52df36cf9"
]
| [
[
[
1,
31
]
]
]
|
bebfcc0be01fb1a21dc2a9f1c8ffa5539f418b16 | 854ee643a4e4d0b7a202fce237ee76b6930315ec | /arcemu_svn/src/sun/src/GossipScripts/Gossip_Guard.cpp | 7dcc33fc7aa46e88ea98ec0035d44472b4547481 | []
| no_license | miklasiak/projekt | df37fa82cf2d4a91c2073f41609bec8b2f23cf66 | 064402da950555bf88609e98b7256d4dc0af248a | refs/heads/master | 2021-01-01T19:29:49.778109 | 2008-11-10T17:14:14 | 2008-11-10T17:14:14 | 34,016,391 | 2 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 137,810 | cpp | /*
* Moon++ Scripts for Ascent MMORPG Server
* Copyright (C) 2005-2007 Ascent Team <http://www.ascentemu.com/>
* Copyright (C) 2007-2008 Moon++ Team <http://www.moonplusplus.info/>
*
* 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 3 of the License, or
* 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, see <http://www.gnu.org/licenses/>.
*/
#include "StdAfx.h"
#include "Setup.h"
#ifdef WIN32
#pragma warning(disable:4305) // warning C4305: 'argument' : truncation from 'double' to 'float'
#endif
/************************************************************************/
/* GENERAL GUARD SCRIPT */
/************************************************************************/
// Covers *all* guard types, scripting their texts to guide players around.
// Enable this define to make all gossip texts have a "back" / "I was looking
// for somethinge else" button added.
#define BACK_BUTTON
#ifdef BACK_BUTTON
// Make code neater with this define.
#define SendQuickMenu(textid) objmgr.CreateGossipMenuForPlayer(&Menu, pObject->GetGUID(), textid, Plr); \
Menu->SendTo(Plr);
#else
// Make code neater with this define.
#define SendQuickMenu(textid) objmgr.CreateGossipMenuForPlayer(&Menu, pObject->GetGUID(), textid, Plr); \
Menu->AddItem(0, "I was looking for something else.", 0); \
Menu->SendTo(Plr);
#endif
/************************************************************************/
/* Stormwind CITY Guards */
/************************************************************************/
class StormwindGuard : public GossipScript
{
public:
void Destroy()
{
delete this;
}
void GossipHello(Object* pObject, Player * Plr, bool AutoSend)
{
GossipMenu *Menu;
objmgr.CreateGossipMenuForPlayer(&Menu, pObject->GetGUID(), 933, Plr);
Menu->AddItem(0, "Auction House" , 1);
Menu->AddItem(0, "Bank of Stormwind" , 2);
if(Plr->GetSession()->GetClientBuild() > 8606) // Greater than 2.4.3
Menu->AddItem(0, "Stormwind Harbor" , 3);
Menu->AddItem(0, "Deeprun Tram" , 4);
Menu->AddItem(0, "The Inn" , 5);
Menu->AddItem(0, "Gryphon Master" , 6);
Menu->AddItem(0, "Guild Master" , 7);
Menu->AddItem(0, "Mailbox" , 8);
Menu->AddItem(0, "Stable Master" , 9);
Menu->AddItem(0, "Weapons Trainer" , 10);
Menu->AddItem(0, "Officers' Lounge" , 11);
Menu->AddItem(0, "Battlemaster" , 12);
if(Plr->GetSession()->GetClientBuild() > 8606) // Greater than 2.4.3
Menu->AddItem(0, "Barber" , 13);
Menu->AddItem(0, "Class Trainer" , 14);
Menu->AddItem(0, "Profession Trainer" , 15);
if(AutoSend)
Menu->SendTo(Plr);
}
void GossipSelectOption(Object* pObject, Player* Plr, uint32 Id, uint32 IntId, const char * Code)
{
GossipMenu * Menu;
switch(IntId)
{
case 0: // Return to start
GossipHello(pObject, Plr, true);
break;
//////////////////////
// Main menu handlers
/////
case 1: // Auction House
SendQuickMenu(3834);
Plr->Gossip_SendPOI(-8811.46, 667.46, 6, 6, 0, "Stormwind Auction House");
break;
case 2: // Bank of Stormwind
SendQuickMenu(764);
Plr->Gossip_SendPOI(-8916.87, 622.87, 6, 6, 0, "Stormwind Bank");
break;
case 3: // Stormwind Harbor
SendQuickMenu(13439);
Plr->Gossip_SendPOI(-8634.77, 949.64, 6, 6, 0, "Stormwind Harbor");
break;
case 4: // Deeprun Tram
SendQuickMenu(3813);
Plr->Gossip_SendPOI(-8378.88, 554.23, 6, 6, 0, "The Deeprun Tram");
break;
case 5: // The Inn
SendQuickMenu(3860);
Plr->Gossip_SendPOI(-8869.0, 675.4, 6, 6, 0, "The Gilded Rose");
break;
case 6: // Gryphon Master
SendQuickMenu(879);
Plr->Gossip_SendPOI(-8837.0, 493.5, 6, 6, 0, "Stormwind Gryphon Master");
break;
case 7: // Guild Master
SendQuickMenu(882);
Plr->Gossip_SendPOI(-8894.0, 611.2, 6, 6, 0, "Stormwind Vistor`s Center");
break;
case 8: // Mailbox
SendQuickMenu(3861);
Plr->Gossip_SendPOI(-8876.48, 649.18, 6, 6, 0, "Stormwind Mailbox");
break;
case 9: // Stable Master
SendQuickMenu(5984);
Plr->Gossip_SendPOI(-8433.0, 554.7, 6, 6, 0, "Jenova Stoneshield");
break;
case 10: // Weapons Master
SendQuickMenu(4516);
Plr->Gossip_SendPOI(-8797.0, 612.8, 6, 6, 0, "Woo Ping");
break;
case 11: // Officers' Lounge
SendQuickMenu(7047);
Plr->Gossip_SendPOI(-8759.92, 399.69, 6, 6, 0, "Champions` Hall");
break;
case 12: // Battlemaster
{
SendQuickMenu(10218);
Plr->Gossip_SendPOI(-8393.62, 274.21, 6, 6, 0, "Battlemasters Stormwind");
}break;
case 13: // Barber
SendQuickMenu(13882);
Plr->Gossip_SendPOI(-8743.15, 660.36, 6, 6, 0, "Stormwind Barber");
break;
case 14: // Class Trainers
{
objmgr.CreateGossipMenuForPlayer(&Menu, pObject->GetGUID(), 898, Plr);
Menu->AddItem( 0, "Druid" , 16);
Menu->AddItem( 0, "Hunter" , 17);
Menu->AddItem( 0, "Mage" , 18);
Menu->AddItem( 0, "Paladin" , 19);
Menu->AddItem( 0, "Priest" , 20);
Menu->AddItem( 0, "Rogue" , 21);
Menu->AddItem( 0, "Shaman" , 22);
Menu->AddItem( 0, "Warlock" , 23);
Menu->AddItem( 0, "Warrior" , 24);
Menu->SendTo(Plr);
}break;
case 15: // Profession Trainers
{
objmgr.CreateGossipMenuForPlayer(&Menu, pObject->GetGUID(), 918, Plr);
Menu->AddItem( 0, "Alchemy" , 25);
Menu->AddItem( 0, "Blacksmithing" , 26);
Menu->AddItem( 0, "Cooking" , 27);
Menu->AddItem( 0, "Enchanting" , 28);
Menu->AddItem( 0, "Engineering" , 29);
Menu->AddItem( 0, "First Aid" , 30);
Menu->AddItem( 0, "Fishing" , 31);
Menu->AddItem( 0, "Herbalism" , 32);
if(Plr->GetSession()->GetClientBuild() > 8606) // Greater than 2.4.3
Menu->AddItem(0, "Inscription" , 33);
Menu->AddItem( 0, "Leatherworking" , 34);
Menu->AddItem( 0, "Mining" , 35);
Menu->AddItem( 0, "Skinning" , 36);
Menu->AddItem( 0, "Tailoring" , 37);
Menu->SendTo(Plr);
}break;
////////////////
// Class trainer submenu
////////
case 16: //Druid
{
Plr->Gossip_SendPOI(-8751.0, 1124.5, 6, 6, 0, "The Park");
SendQuickMenu(902);
}break;
case 17: //Hunter
{
Plr->Gossip_SendPOI(-8413.0, 541.5, 6, 6, 0, "Hunter Lodge");
SendQuickMenu(905);
}break;
case 18: //Mage
{
Plr->Gossip_SendPOI(-9012.0, 867.6, 6, 6, 0, "Wizard`s Sanctum");
SendQuickMenu(899);
}break;
case 19: //Paladin
{
Plr->Gossip_SendPOI(-8577.0, 881.7, 6, 6, 0, "Cathedral Of Light");
SendQuickMenu(904);
}break;
case 20: //Priest
{
Plr->Gossip_SendPOI(-8512.0, 862.4, 6, 6, 0, "Cathedral Of Light");
SendQuickMenu(903);
}break;
case 21: //Rogue
{
Plr->Gossip_SendPOI(-8753.0, 367.8, 6, 6, 0, "Stormwind - Rogue House");
SendQuickMenu(900);
}break;
case 22: //Shaman
{
Plr->Gossip_SendPOI(-9031.54, 549.87, 6, 6, 0, "Farseer Umbrua");
SendQuickMenu(10106);
}break;
case 23: //Warlock
{
Plr->Gossip_SendPOI(-8948.91, 998.35, 6, 6, 0, "The Slaughtered Lamb");
SendQuickMenu(906);
}break;
case 24: //Warrior
{
Plr->Gossip_SendPOI(-8714.14, 334.96, 6, 6, 0, "Stormwind Barracks");
SendQuickMenu(901);
}break;
case 25: //Alchemy
{
Plr->Gossip_SendPOI(-8988.0, 759.60, 6, 6, 0, "Alchemy Needs");
SendQuickMenu(919);
}break;
case 26: //Blacksmithing
{
Plr->Gossip_SendPOI(-8424.0, 616.9, 6, 6, 0, "Therum Deepforge");
SendQuickMenu(920);
}break;
case 27: //Cooking
{
Plr->Gossip_SendPOI(-8611.0, 364.6, 6, 6, 0, "Pig and Whistle Tavern");
SendQuickMenu(921);
}break;
case 28: //Enchanting
{
Plr->Gossip_SendPOI(-8858.0, 803.7, 6, 6, 0, "Lucan Cordell");
SendQuickMenu(941);
}break;
case 29: //Engineering
{
Plr->Gossip_SendPOI(-8347.0, 644.1, 6, 6, 0, "Lilliam Sparkspindle");
SendQuickMenu(922);
}break;
case 30: //First Aid
{
Plr->Gossip_SendPOI(-8513.0, 801.8, 6, 6, 0, "Shaina Fuller");
SendQuickMenu(923);
}break;
case 31: //Fishing
{
Plr->Gossip_SendPOI(-8803.0, 767.5, 6, 6, 0, "Arnold Leland");
SendQuickMenu(940);
}break;
case 32: //Herbalism
{
Plr->Gossip_SendPOI(-8967.0, 779.5, 6, 6, 0, "Alchemy Needs");
SendQuickMenu(924);
}break;
case 33: //Inscription
{
Plr->Gossip_SendPOI(-8853.33, 857.66, 6, 6, 0, "Stormwind Inscription");
SendQuickMenu(13881);
}break;
case 34: //Leatherworking
{
Plr->Gossip_SendPOI(-8726.0, 477.4, 6, 6, 0, "The Protective Hide");
SendQuickMenu(925);
}break;
case 35: //Mining
{
Plr->Gossip_SendPOI(-8434.0, 692.8, 6, 6, 0, "Gelman Stonehand");
SendQuickMenu(927);
}break;
case 36: //Skinning
{
Plr->Gossip_SendPOI(-8716.0, 469.4, 6, 6, 0, "The Protective Hide");
SendQuickMenu(928);
}break;
case 37: //Tailoring
{
Plr->Gossip_SendPOI(-8938.0, 800.7, 6, 6, 0, "Duncan`s Textiles");
SendQuickMenu(929);
}break;
}
}
};
class DarnassusGuard : public GossipScript
{
public:
void Destroy()
{
delete this;
}
void GossipHello(Object* pObject, Player * Plr, bool AutoSend)
{
GossipMenu *Menu;
objmgr.CreateGossipMenuForPlayer(&Menu, pObject->GetGUID(), 3016, Plr);
Menu->AddItem( 0, "Auction House" , 1);
Menu->AddItem( 0, "The Bank" , 2);
Menu->AddItem( 0, "Hippogryph Master" , 3);
Menu->AddItem( 0, "Guild Master" , 4);
Menu->AddItem( 0, "The Inn" , 5);
Menu->AddItem( 0, "Mailbox" , 6);
Menu->AddItem( 0, "Stable Master" , 7);
Menu->AddItem( 0, "Weapons Trainer" , 8);
Menu->AddItem( 0, "Battlemaster" , 9);
Menu->AddItem( 0, "Class Trainer" , 10);
Menu->AddItem( 0, "Profession Trainer" , 11);
if(Plr->GetSession()->GetClientBuild() > 8606) // Greater than 2.4.3
Menu->AddItem( 0, "Lexicon of Power" , 27);
if(AutoSend)
Menu->SendTo(Plr);
}
void GossipSelectOption(Object* pObject, Player* Plr, uint32 Id, uint32 IntId, const char * Code)
{
GossipMenu * Menu;
switch(IntId)
{
case 0: // Return to start
GossipHello(pObject, Plr, true);
break;
//////////////////////
// Main menu handlers (Most/All 'borrowed' from scriptdev)
/////
case 1: // Auction House
SendQuickMenu(3833);
Plr->Gossip_SendPOI(9861.23, 2334.55, 6, 6, 0, "Darnassus Auction House");
break;
case 2: // The Bank
SendQuickMenu(3017);
Plr->Gossip_SendPOI(9938.45, 2512.35, 6, 6, 0, "Darnassus Bank");
break;
case 3: // Hippogryph Master
SendQuickMenu(3018);
Plr->Gossip_SendPOI(9945.65, 2618.94, 6, 6, 0, "Rut'theran Village");
break;
case 4: // Guild Master
SendQuickMenu(3019);
Plr->Gossip_SendPOI(10076.40, 2199.59, 6, 6, 0, "Darnassus Guild Master");
break;
case 5: // The Inn
SendQuickMenu(3020);
Plr->Gossip_SendPOI(10133.29, 2222.52, 6, 6, 0, "Darnassus Inn");
break;
case 6: // Mailbox
SendQuickMenu(3021);
Plr->Gossip_SendPOI(9942.17, 2495.48, 6, 6, 0, "Darnassus Mailbox");
break;
case 7: // Stable Master
SendQuickMenu(5980);
Plr->Gossip_SendPOI(10167.20, 2522.66, 6, 6, 0, "Alassin");
break;
case 8: // Weapons Trainer
SendQuickMenu(4517);
Plr->Gossip_SendPOI(9907.11, 2329.70, 6, 6, 0, "Ilyenia Moonfire");
break;
case 9: // Battlemaster
{
SendQuickMenu(7519);
Plr->Gossip_SendPOI(9981.9, 2325.9, 6, 6, 0, "Battlemasters Darnassus");
}break;
case 10: // Class Trainer
{
objmgr.CreateGossipMenuForPlayer(&Menu, pObject->GetGUID(), 4264, Plr);
Menu->AddItem( 0, "Druid" , 12);
Menu->AddItem( 0, "Hunter" , 13);
Menu->AddItem( 0, "Priest" , 14);
Menu->AddItem( 0, "Rogue" , 15);
Menu->AddItem( 0, "Warrior" , 16);
Menu->SendTo(Plr);
}break;
case 11: // Profession Trainer
{
objmgr.CreateGossipMenuForPlayer(&Menu, pObject->GetGUID(), 4273, Plr);
Menu->AddItem( 0, "Alchemy" , 17);
Menu->AddItem( 0, "Cooking" , 18);
Menu->AddItem( 0, "Enchanting" , 19);
Menu->AddItem( 0, "First Aid" , 20);
Menu->AddItem( 0, "Fishing" , 21);
Menu->AddItem( 0, "Herbalism" , 22);
if(Plr->GetSession()->GetClientBuild() > 8606) // Greater than 2.4.3
Menu->AddItem( 0, "Inscription" , 23);
Menu->AddItem( 0, "Leatherworking" , 24);
Menu->AddItem( 0, "Skinning" , 25);
Menu->AddItem( 0, "Tailoring" , 26);
Menu->SendTo(Plr);
}break;
case 12: // Druid
{
Plr->Gossip_SendPOI(10186, 2570.46, 6, 6, 0, "Darnassus Druid Trainer");
SendQuickMenu(3024);
}break;
case 13: // Hunter
{
Plr->Gossip_SendPOI(10177.29, 2511.10, 6, 6, 0, "Darnassus Hunter Trainer");
SendQuickMenu(3023);
}break;
case 14: // Priest
{
Plr->Gossip_SendPOI(9659.12, 2524.88, 6, 6, 0, "Temple of the Moon");
SendQuickMenu(3025);
}break;
case 15: // Rogue
{
Plr->Gossip_SendPOI(10122, 2599.12, 6, 6, 0, "Darnassus Rogue Trainer");
SendQuickMenu(3026);
}break;
case 16: // Warrior
{
Plr->Gossip_SendPOI(9951.91, 2280.38, 6, 6, 0, "Warrior's Terrace");
SendQuickMenu(3033);
}break;
case 17: //Alchemy
{
Plr->Gossip_SendPOI(10075.90, 2356.76, 6, 6, 0, "Darnassus Alchemy Trainer");
SendQuickMenu(3035);
}break;
case 18: //Cooking
{
Plr->Gossip_SendPOI(10088.59, 2419.21, 6, 6, 0, "Darnassus Cooking Trainer");
SendQuickMenu(3036);
}break;
case 19: //Enchanting
{
Plr->Gossip_SendPOI(10146.09, 2313.42, 6, 6, 0, "Darnassus Enchanting Trainer");
SendQuickMenu(3337);
}break;
case 20: //First Aid
{
Plr->Gossip_SendPOI(10150.09, 2390.43, 6, 6, 0, "Darnassus First Aid Trainer");
SendQuickMenu(3037);
}break;
case 21: //Fishing
{
Plr->Gossip_SendPOI(9836.20, 2432.17, 6, 6, 0, "Darnassus Fishing Trainer");
SendQuickMenu(3038);
}break;
case 22: //Herbalism
{
Plr->Gossip_SendPOI(9757.17, 2430.16, 6, 6, 0, "Darnassus Herbalism Trainer");
SendQuickMenu(3039);
}break;
case 23: //Inscription
{
Plr->Gossip_SendPOI(10146.09, 2313.42, 6, 6, 0, "Darnassus Inscription Trainer");
SendQuickMenu(13886);
}break;
case 24: //Leatherworking
{
Plr->Gossip_SendPOI(10086.59, 2255.77, 6, 6, 0, "Darnassus Leatherworking Trainer");
SendQuickMenu(3040);
}break;
case 25: //Skinning
{
Plr->Gossip_SendPOI(10081.40, 2257.18, 6, 6, 0, "Darnassus Skinning Trainer");
SendQuickMenu(3042);
}break;
case 26: //Tailoring
{
Plr->Gossip_SendPOI(10079.70, 2268.19, 6, 6, 0, "Darnassus Tailor");
SendQuickMenu(3044);
}break;
case 27: //Lexicon of Power
{
Plr->Gossip_SendPOI(10146.09, 2313.42, 6, 6, 0, "Darnassus Inscription Trainer");
SendQuickMenu(14174);
}break;
}
}
void GossipEnd(Object* pObject, Player* Plr)
{
}
};
class GoldshireGuard : public GossipScript
{
public:
void Destroy()
{
delete this;
}
void GossipHello(Object* pObject, Player * Plr, bool AutoSend)
{
GossipMenu *Menu;
objmgr.CreateGossipMenuForPlayer(&Menu, pObject->GetGUID(), 4259, Plr);
Menu->AddItem( 0, "Bank" , 1);
Menu->AddItem( 0, "Gryphon Master" , 2);
Menu->AddItem( 0, "Guild Master" , 3);
Menu->AddItem( 0, "Inn" , 4);
Menu->AddItem( 0, "Stable Master" , 5);
Menu->AddItem( 0, "Class Trainer" , 6);
Menu->AddItem( 0, "Profession Trainer" , 7);
if(AutoSend)
Menu->SendTo(Plr);
}
void GossipSelectOption(Object* pObject, Player* Plr, uint32 Id, uint32 IntId, const char * Code)
{
GossipMenu * Menu;
switch(IntId)
{
case 0: // Return to start
GossipHello(pObject, Plr, true);
break;
//////////////////////
// Main menu handlers
/////
case 1: //Bank
SendQuickMenu(4260);
break;
case 2: //Gryphon Master
SendQuickMenu(4261);
break;
case 3: //Guild Master
SendQuickMenu(4262);
break;
case 4: //Inn
SendQuickMenu(4263);
Plr->Gossip_SendPOI(-9459.34, 42.08, 99, 6, 0, "Lion's Pride Inn");
break;
case 5: //Stable Master
SendQuickMenu(5983);
Plr->Gossip_SendPOI(-9466.62, 45.87, 99, 6, 0, "Erma");
break;
case 6: //Class Trainer
{
objmgr.CreateGossipMenuForPlayer(&Menu, pObject->GetGUID(), 4264, Plr);
Menu->AddItem( 0, "Druid", 8);
Menu->AddItem( 0, "Hunter", 9);
Menu->AddItem( 0, "Mage", 10);
Menu->AddItem( 0, "Paladin", 11);
Menu->AddItem( 0, "Priest", 12);
Menu->AddItem( 0, "Rogue", 13);
Menu->AddItem( 0, "Shaman", 14);
Menu->AddItem( 0, "Warlock", 15);
Menu->AddItem( 0, "Warrior", 16);
Menu->SendTo(Plr);
}break;
case 7: //Profession Trainer
{
objmgr.CreateGossipMenuForPlayer(&Menu, pObject->GetGUID(), 4273, Plr);
Menu->AddItem( 0, "Alchemy" ,17);
Menu->AddItem( 0, "Blacksmithing" ,18);
Menu->AddItem( 0, "Cooking" ,19);
Menu->AddItem( 0, "Enchanting" ,20);
Menu->AddItem( 0, "Engineering" ,21);
Menu->AddItem( 0, "First Aid" ,22);
Menu->AddItem( 0, "Fishing" ,23);
Menu->AddItem( 0, "Herbalism" ,24);
if(Plr->GetSession()->GetClientBuild() > 8606) // Greater than 2.4.3
Menu->AddItem( 0, "Inscription" , 25);
Menu->AddItem( 0, "Leatherworking" ,26);
Menu->AddItem( 0, "Mining" ,27);
Menu->AddItem( 0, "Skinning" ,28);
Menu->AddItem( 0, "Tailoring" ,29);
Menu->SendTo(Plr);
}break;
case 8: //Druid
{
SendQuickMenu(4265);
}break;
case 9: //Hunter
{
SendQuickMenu(4266);
}break;
case 10: //Mage
{
Plr->Gossip_SendPOI(-9471.12, 33.44, 6, 6, 0, "Zaldimar Wefhellt");
SendQuickMenu(4268);
}break;
case 11: //Paladin
{
Plr->Gossip_SendPOI(-9469, 108.05, 6, 6, 0, "Brother Wilhelm");
SendQuickMenu(4269);
}break;
case 12: //Priest
{
Plr->Gossip_SendPOI(-9461.07, 32.6, 6, 6, 0, "Priestess Josetta");
SendQuickMenu(4267);
}break;
case 13: //Rogue
{
Plr->Gossip_SendPOI(-9465.13, 13.29, 6, 6, 0, "Keryn Sylvius");
SendQuickMenu(4270);
}break;
case 14: //Shaman
{
SendQuickMenu(10101);
}break;
case 15: //Warlock
{
Plr->Gossip_SendPOI(-9473.21, -4.08, 6, 6, 0, "Maximillian Crowe");
SendQuickMenu(4272);
}break;
case 16: //Warrior
{
Plr->Gossip_SendPOI(-9461.82, 109.50, 6, 6, 0, "Lyria Du Lac");
SendQuickMenu(4271);
}break;
case 17: //Alchemy
{
Plr->Gossip_SendPOI(-9057.04, 153.63, 6, 6, 0, "Alchemist Mallory");
SendQuickMenu(4274);
}break;
case 18: //Blacksmithing
{
Plr->Gossip_SendPOI(-9456.58, 87.90, 6, 6, 0, "Smith Argus");
SendQuickMenu(4275);
}break;
case 19: //Cooking
{
Plr->Gossip_SendPOI(-9467.54, -3.16, 6, 6, 0, "Tomas");
SendQuickMenu(4276);
}break;
case 20: //Enchanting
{
SendQuickMenu(4277);
}break;
case 21: //Engineering
{
SendQuickMenu(4278);
}break;
case 22: //First Aid
{
Plr->Gossip_SendPOI(-9456.82, 30.49, 6, 6, 0, "Michelle Belle");
SendQuickMenu(4279);
}break;
case 23: //Fishing
{
Plr->Gossip_SendPOI(-9386.54, -118.73, 6, 6, 0, "Lee Brown");
SendQuickMenu(4280);
}break;
case 24: //Herbalism
{
Plr->Gossip_SendPOI(-9060.70, 149.23, 6, 6, 0, "Herbalist Pomeroy");
SendQuickMenu(4281);
}break;
case 25: //Inscription
{
Plr->Gossip_SendPOI(-8853.33, 857.66, 6, 6, 0, "Stormwind Inscription");
SendQuickMenu(13881);
}break;
case 26: //Leatherworking
{
Plr->Gossip_SendPOI(-9376.12, -75.23, 6, 6, 0, "Adele Fielder");
SendQuickMenu(4282);
}break;
case 27: //Mining
{
SendQuickMenu(4283);
}break;
case 28: //Skinning
{
Plr->Gossip_SendPOI(-9536.91, -1212.76, 6, 6, 0, "Helene Peltskinner");
SendQuickMenu(4284);
}break;
case 29: //Tailoring
{
Plr->Gossip_SendPOI(-9376.12, -75.23, 6, 6, 0, "Eldrin");
SendQuickMenu(4285);
}break;
}
}
};
class UndercityGuard : public GossipScript
{
public:
void Destroy()
{
delete this;
}
void GossipHello(Object* pObject, Player * Plr, bool AutoSend)
{
GossipMenu *Menu;
objmgr.CreateGossipMenuForPlayer(&Menu, pObject->GetGUID(), 3543, Plr);
Menu->AddItem(0, "The bank", 1);
Menu->AddItem(0, "The bat handler", 2);
Menu->AddItem(0, "The guild master", 3);
Menu->AddItem(0, "The inn", 4);
Menu->AddItem(0, "The mailbox", 5);
Menu->AddItem(0, "The auction house", 6);
Menu->AddItem(0, "The zeppelin master", 7);
Menu->AddItem(0, "The weapon master", 8);
Menu->AddItem(0, "The stable master", 9);
Menu->AddItem(0, "The battlemaster", 10);
Menu->AddItem(0, "A class trainer", 11);
Menu->AddItem(0, "A profession trainer", 12);
if(AutoSend)
Menu->SendTo(Plr);
}
void GossipSelectOption(Object* pObject, Player* Plr, uint32 Id, uint32 IntId, const char * Code)
{
GossipMenu * Menu;
switch(IntId)
{
case 0: // Return to start
GossipHello(pObject, Plr, true);
break;
//////////////////////
// Main menu handlers
/////
case 1: // The bank
SendQuickMenu(3514);
Plr->Gossip_SendPOI(1595.64, 232.45, 6, 6, 0, "Undercity Bank");
break;
case 2: // The bat handler
SendQuickMenu(3515);
Plr->Gossip_SendPOI(1565.9, 271.43, 6, 6, 0, "Undercity Bat Handler");
break;
case 3: // The guild master
SendQuickMenu(3516);
Plr->Gossip_SendPOI(1594.17, 205.57, 6, 6, 0, "Undercity Guild Master");
break;
case 4: // The inn
SendQuickMenu(3517);
Plr->Gossip_SendPOI(1639.43, 220.99, 6, 6, 0, "Undercity Inn");
break;
case 5: // The mailbox
SendQuickMenu(3518);
Plr->Gossip_SendPOI(1632.68, 219.4, 6, 6, 0, "Undercity Mailbox");
break;
case 6: // The auction house
SendQuickMenu(3520);
Plr->Gossip_SendPOI(1647.9, 258.49, 6, 6, 0, "Undercity Auction House");
break;
case 7: // The zeppelin master
SendQuickMenu(3519);
Plr->Gossip_SendPOI(2059, 274.86, 6, 6, 0, "Undercity Zeppelin");
break;
case 8: // The weapon master
SendQuickMenu(4521);
Plr->Gossip_SendPOI(1670.31, 324.66, 6, 6, 0, "Archibald");
break;
case 9: // The stable master
SendQuickMenu(5979);
Plr->Gossip_SendPOI(1634.18, 226.76, 6, 6, 0, "Anya Maulray");
break;
case 10: // The battlemaster
{
SendQuickMenu(7527);
Plr->Gossip_SendPOI(1300.33, 350.92, 6, 6, 0, "Battlemasters Undercity");
}break;
case 11: // A class trainer
{
objmgr.CreateGossipMenuForPlayer(&Menu, pObject->GetGUID(), 3542, Plr);
Menu->AddItem( 0, "Mage" , 13);
Menu->AddItem( 0, "Paladin" , 14);
Menu->AddItem( 0, "Priest" , 15);
Menu->AddItem( 0, "Rogue" , 16);
Menu->AddItem( 0, "Warlock" , 17);
Menu->AddItem( 0, "Warrior" , 18);
Menu->SendTo(Plr);
}break;
case 12: // A profession trainer
{
objmgr.CreateGossipMenuForPlayer(&Menu, pObject->GetGUID(), 3541, Plr);
Menu->AddItem( 0, "Alchemy" , 19);
Menu->AddItem( 0, "Blacksmithing" , 20);
Menu->AddItem( 0, "Cooking" , 21);
Menu->AddItem( 0, "Enchanting" , 22);
Menu->AddItem( 0, "Engineering" , 23);
Menu->AddItem( 0, "First Aid" , 24);
Menu->AddItem( 0, "Fishing" , 25);
Menu->AddItem( 0, "Herbalism" , 26);
Menu->AddItem( 0, "Leatherworking" , 27);
Menu->AddItem( 0, "Mining" , 28);
Menu->AddItem( 0, "Skinning" , 29);
Menu->AddItem( 0, "Tailoring" , 30);
Menu->SendTo(Plr);
}break;
////////////////
// Class trainer submenu
////////
case 13: //Mage
{
Plr->Gossip_SendPOI(1781, 53, 6, 6, 0, "Undercity Mage Trainers");
SendQuickMenu(3513);
}break;
case 14: //Paladin
{
Plr->Gossip_SendPOI(1298.98, 316.51, 6, 6, 0, "Champion Cyssa Downrose");
SendQuickMenu(3521);
}break;
case 15: //Priest
{
Plr->Gossip_SendPOI(1758.33, 401.5, 6, 6, 0, "Undercity Priest Trainers");
SendQuickMenu(3521);
}break;
case 16: //Rogue
{
Plr->Gossip_SendPOI(1418.56, 65, 6, 6, 0, "Undercity Rogue Trainers");
SendQuickMenu(3526);
}break;
case 17: //Warlock
{
Plr->Gossip_SendPOI(1780.92, 53.16, 6, 6, 0, "Undercity Warlock Trainers");
SendQuickMenu(3526);
}break;
case 18: //Warrior
{
Plr->Gossip_SendPOI(1775.59, 418.19, 6, 6, 0, "Undercity Warrior Trainers");
SendQuickMenu(3527);
}break;
case 19: //Alchemy
{
Plr->Gossip_SendPOI(1419.82, 417.19, 6, 6, 0, "The Apothecarium");
SendQuickMenu(3528);
}break;
case 20: //Blacksmithing
{
Plr->Gossip_SendPOI(1696, 285, 6, 6, 0, "Undercity Blacksmithing Trainer");
SendQuickMenu(3529);
}break;
case 21: //Cooking
{
Plr->Gossip_SendPOI(1596.34, 274.68, 6, 6, 0, "Undercity Cooking Trainer");
SendQuickMenu(3530);
}break;
case 22: //Enchanting
{
Plr->Gossip_SendPOI(1488.54, 280.19, 6, 6, 0, "Undercity Enchanting Trainer");
SendQuickMenu(3531);
}break;
case 23: //Engineering
{
Plr->Gossip_SendPOI(1408.58, 143.43, 6, 6, 0, "Undercity Engineering Trainer");
SendQuickMenu(3532);
}break;
case 24: //First Aid
{
Plr->Gossip_SendPOI(1519.65, 167.19, 6, 6, 0, "Undercity First Aid Trainer");
SendQuickMenu(3533);
}break;
case 25: //Fishing
{
Plr->Gossip_SendPOI(1679.9, 89, 6, 6, 0, "Undercity Fishing Trainer");
SendQuickMenu(3534);
}break;
case 26: //Herbalism
{
Plr->Gossip_SendPOI(1558, 349.36, 6, 6, 0, "Undercity Herbalism Trainer");
SendQuickMenu(3535);
}break;
case 27: //Leatherworking
{
Plr->Gossip_SendPOI(1498.76, 196.43, 6, 6, 0, "Undercity Leatherworking Trainer");
SendQuickMenu(3536);
}break;
case 28: //Mining
{
Plr->Gossip_SendPOI(1642.88, 335.58, 6, 6, 0, "Undercity Mining Trainer");
SendQuickMenu(3537);
}break;
case 29: //Skinning
{
Plr->Gossip_SendPOI(1498.6, 196.46, 6, 6, 0, "Undercity Skinning Trainer");
SendQuickMenu(3538);
}break;
case 30: //Tailoring
{
Plr->Gossip_SendPOI(1689.55, 193, 6, 6, 0, "Undercity Tailoring Trainer");
SendQuickMenu(3539);
}break;
}
}
};
class TeldrassilGuard : public GossipScript
{
public:
void Destroy()
{
delete this;
}
void GossipHello(Object* pObject, Player * Plr, bool AutoSend)
{
GossipMenu *Menu;
objmgr.CreateGossipMenuForPlayer(&Menu, pObject->GetGUID(), 4316, Plr);
Menu->AddItem(0, "The Bank", 1);
Menu->AddItem(0, "Rut'Theran Ferry", 2);
Menu->AddItem(0, "The Guild Master", 3);
Menu->AddItem(0, "The Inn", 4);
Menu->AddItem(0, "Stable Master", 5);
Menu->AddItem(0, "Class Trainer", 6);
Menu->AddItem(0, "Profession Trainer", 7);
if(AutoSend)
Menu->SendTo(Plr);
}
void GossipSelectOption(Object* pObject, Player* Plr, uint32 Id, uint32 IntId, const char * Code)
{
GossipMenu * Menu;
switch(IntId)
{
case 0: // Return to start
GossipHello(pObject, Plr, true);
break;
//////////////////////
// Main menu handlers
/////
case 1: // The Bank
SendQuickMenu(4317);
break;
case 2: // Rut'theran erry
SendQuickMenu(4318);
break;
case 3: // The Guild Master
SendQuickMenu(4319);
break;
case 4: // The Inn
Plr->Gossip_SendPOI(9821.49, 960.13, 6, 6, 0, "Dolanaar Inn");
SendQuickMenu(4320);
break;
case 5: // Stable Master
Plr->Gossip_SendPOI(9808.37, 931.1, 6, 6, 0, "Seriadne");
SendQuickMenu(5982);
break;
case 6: // Class Trainers
{
objmgr.CreateGossipMenuForPlayer(&Menu, pObject->GetGUID(), 4264, Plr);
Menu->AddItem( 0, "Druid" , 8);
Menu->AddItem( 0, "Hunter" , 9);
Menu->AddItem( 0, "Priest" , 10);
Menu->AddItem( 0, "Rogue" , 11);
Menu->AddItem( 0, "Warrior" , 12);
Menu->SendTo(Plr);
}break;
case 7: // Profession Trainers
{
objmgr.CreateGossipMenuForPlayer(&Menu, pObject->GetGUID(), 4273, Plr);
Menu->AddItem( 0, "Alchemy" , 13);
Menu->AddItem( 0, "Cooking" , 14);
Menu->AddItem( 0, "Enchanting" , 15);
Menu->AddItem( 0, "First Aid" , 16);
Menu->AddItem( 0, "Fishing" , 17);
Menu->AddItem( 0, "Herbalism" , 18);
if(Plr->GetSession()->GetClientBuild() > 8606) // Greater than 2.4.3
Menu->AddItem( 0, "Inscription" , 19);
Menu->AddItem( 0, "Leatherworking" , 20);
Menu->AddItem( 0, "Skinning" , 21);
Menu->AddItem( 0, "Tailoring" , 22);
Menu->SendTo(Plr);
}break;
////////////////
// Class trainer submenu
////////
case 8: //Druid
{
Plr->Gossip_SendPOI(9741.58, 963.7, 6, 6, 0, "Kal");
SendQuickMenu(4323);
}break;
case 9: // Hunter
{
Plr->Gossip_SendPOI(9815.12, 926.28, 6, 6, 0, "Dazalar");
SendQuickMenu(4324);
}break;
case 10: // Priest
{
Plr->Gossip_SendPOI(9906.16, 986.63, 6, 6, 0, "Laurna Morninglight");
SendQuickMenu(4325);
}break;
case 11: // Rogue
{
Plr->Gossip_SendPOI(9789, 942.86, 6, 6, 0, "Jannok Breezesong");
SendQuickMenu(4326);
}break;
case 12: // Warrior
{
Plr->Gossip_SendPOI(9821.96, 950.61, 6, 6, 0, "Kyra Windblade");
SendQuickMenu(4327);
}break;
case 13: // Alchemy
{
Plr->Gossip_SendPOI(9767.59, 878.81, 6, 6, 0, "Cyndra Kindwhisper");
SendQuickMenu(4329);
}break;
case 14: // Cooking
{
Plr->Gossip_SendPOI(9751.19, 906.13, 6, 6, 0, "Zarrin");
SendQuickMenu(4330);
}break;
case 15: // Enchanting
{
Plr->Gossip_SendPOI(10677.59, 1946.56, 6, 6, 0, "Alanna Raveneye");
SendQuickMenu(4331);
}break;
case 16: // First Aid
{
Plr->Gossip_SendPOI(9903.12, 999, 6, 6, 0, "Byancie");
SendQuickMenu(4332);
}break;
case 17: // Fishing
{
SendQuickMenu(4333);
}break;
case 18: // Herbalism
{
Plr->Gossip_SendPOI(9773.78, 875.88, 6, 6, 0, "Malorne Bladeleaf");
SendQuickMenu(4334);
}break;
case 19: // Inscription
{
Plr->Gossip_SendPOI(10146.09, 2313.42, 6, 6, 0, "Darnassus Inscription Trainer");
SendQuickMenu(13886);
}break;
case 20: // Leatherworking
{
Plr->Gossip_SendPOI(10152.59, 1681.46, 6, 6, 0, "Nadyia Maneweaver");
SendQuickMenu(4335);
}break;
case 21: // Skinning
{
Plr->Gossip_SendPOI(10135.59, 1673.18, 6, 6, 0, "Radnaal Maneweaver");
SendQuickMenu(4336);
}break;
case 22: // Tailoring
{
SendQuickMenu(4337);
}break;
}
}
};
class SilvermoonGuard : public GossipScript
{
public:
void Destroy()
{
delete this;
}
void GossipHello(Object* pObject, Player * Plr, bool AutoSend)
{
GossipMenu *Menu;
objmgr.CreateGossipMenuForPlayer(&Menu, pObject->GetGUID(), 9316, Plr);
Menu->AddItem(0, "Auction House" , 1);
Menu->AddItem(0, "The Bank" , 2);
Menu->AddItem(0, "Dragonhawk Master" , 3);
Menu->AddItem(0, "Guild Master" , 4);
Menu->AddItem(0, "The Inn" , 5);
Menu->AddItem(0, "Mailbox" , 6);
Menu->AddItem(0, "Stable Master" , 7);
Menu->AddItem(0, "Weapon Master" , 8);
Menu->AddItem(0, "Battlemaster" , 9);
Menu->AddItem(0, "Class Trainer" , 10);
Menu->AddItem(0, "Profession Trainer" , 11);
Menu->AddItem(0, "Mana Loom" , 12);
if(Plr->GetSession()->GetClientBuild() > 8606) // Greater than 2.4.3
Menu->AddItem(0, "Lexicon of Power" , 40);
if(AutoSend)
Menu->SendTo(Plr);
}
void GossipSelectOption(Object* pObject, Player* Plr, uint32 Id, uint32 IntId, const char * Code)
{
GossipMenu * Menu;
switch(IntId)
{
case 0: // Return to start
GossipHello(pObject, Plr, true);
break;
//////////////////////
// Main menu handlers
/////
case 1: // Auction House
objmgr.CreateGossipMenuForPlayer(&Menu, pObject->GetGUID(), 9317, Plr);
Menu->AddItem(0, "To the west." , 13);
Menu->AddItem(0, "To the east." , 14);
Menu->SendTo(Plr);
break;
case 2: // The Bank
objmgr.CreateGossipMenuForPlayer(&Menu, pObject->GetGUID(), 9320, Plr);
Menu->AddItem(0, "The west." , 15);
Menu->AddItem(0, "The east." , 16);
Menu->SendTo(Plr);
break;
case 3: // Dragonhawk Master
SendQuickMenu(9323);
Plr->Gossip_SendPOI(9378.45, -7163.94, 6, 6, 0, "Silvermoon City, Flight Master");
break;
case 4: // Guild Master
SendQuickMenu(9324);
Plr->Gossip_SendPOI(9480.75, -7345.587, 6, 6, 0, "Silvermoon City, Guild Master");
break;
case 5: // The Inn
objmgr.CreateGossipMenuForPlayer(&Menu, pObject->GetGUID(), 9325, Plr);
Menu->AddItem(0, "The Silvermoon City Inn." , 17);
Menu->AddItem(0, "The Wayfarer's Rest tavern." , 18);
Menu->SendTo(Plr);
break;
case 6: // Mailbox
SendQuickMenu(9326);
Plr->Gossip_SendPOI(9743.078, -7466.4, 6, 6, 0, "Silvermoon City, Mailbox");
break;
case 7: // Stable Master
SendQuickMenu(9327);
Plr->Gossip_SendPOI(9904.95, -7404.31, 6, 6, 0, "Silvermoon City, Stable Master");
break;
case 8: // Weapon Master
SendQuickMenu(9328);
Plr->Gossip_SendPOI(9841.17, -7505.13, 6, 6, 0, "Silvermoon City, Weapon Master");
break;
case 9: // Battlemasters
SendQuickMenu(9329);
Plr->Gossip_SendPOI(9850.74, -7563.84, 6, 6, 0, "Silvermoon City, Battlemasters");
break;
case 10: // Class Trainers
{
objmgr.CreateGossipMenuForPlayer(&Menu, pObject->GetGUID(), 9331, Plr);
Menu->AddItem( 0, "Druid" , 19);
Menu->AddItem( 0, "Hunter" , 20);
Menu->AddItem( 0, "Mage" , 21);
Menu->AddItem( 0, "Paladin" , 22);
Menu->AddItem( 0, "Priest" , 23);
Menu->AddItem( 0, "Rogue" , 24);
Menu->AddItem( 0, "Warlock" , 25);
Menu->SendTo(Plr);
}break;
case 11: // Profession Trainers
{
objmgr.CreateGossipMenuForPlayer(&Menu, pObject->GetGUID(), 9338, Plr);
Menu->AddItem( 0, "Alchemy" , 26);
Menu->AddItem( 0, "Blacksmithing" , 27);
Menu->AddItem( 0, "Cooking" , 28);
Menu->AddItem( 0, "Enchanting" , 29);
Menu->AddItem( 0, "Engineering" , 30);
Menu->AddItem( 0, "First Aid" , 31);
Menu->AddItem( 0, "Fishing" , 32);
Menu->AddItem( 0, "Herbalism" , 33);
if(Plr->GetSession()->GetClientBuild() > 8606) // Greater than 2.4.3
Menu->AddItem( 0, "Inscription" , 34);
Menu->AddItem( 0, "Jewelcrafting" , 35);
Menu->AddItem( 0, "Leatherworking" , 36);
Menu->AddItem( 0, "Mining" , 37);
Menu->AddItem( 0, "Skinning" , 38);
Menu->AddItem( 0, "Tailoring" , 39);
Menu->SendTo(Plr);
}break;
case 12: //Mana Loom
{
Plr->Gossip_SendPOI(9751.013, -7074.85, 6, 6, 0, "Silvermoon City, Mana Loom");
SendQuickMenu(10502);
}break;
case 13: //To the west - Auction House no. 1
{
Plr->Gossip_SendPOI(9649.429, -7134.027, 6, 6, 0, "Silvermoon City, Auction House");
SendQuickMenu(9318);
}break;
case 14: //To the east - Auction House no. 2
{
Plr->Gossip_SendPOI(9682.864, -7515.786, 6, 6, 0, "Silvermoon City, Auction House");
SendQuickMenu(9319);
}break;
case 15: // The bank - The west.
SendQuickMenu(9321);
Plr->Gossip_SendPOI(9522.104, -7208.878, 6, 6, 0, "Silvermoon City, Bank");
break;
case 16: // The bank - The east.
SendQuickMenu(9322);
Plr->Gossip_SendPOI(9791.07, -7488.041, 6, 6, 0, "Silvermoon City, Bank");
break;
case 17: //The Silvermoon City Inn
{
Plr->Gossip_SendPOI(9677.113, -7367.575, 6, 6, 0, "Silvermoon City, Inn");
SendQuickMenu(9325);
}break;
case 18: //The Wayfarer's Rest tavern
{
Plr->Gossip_SendPOI(9562.813, -7218.63, 6, 6, 0, "Silvermoon City, Inn");
SendQuickMenu(9603);
}break;
case 19: //Druid
{
Plr->Gossip_SendPOI(9700.55, -7262.57, 6, 6, 0, "Silvermoon City, Druid Trainer");
SendQuickMenu(9330);
}break;
case 20: //Hunter
{
Plr->Gossip_SendPOI(9930.568, -7412.115, 6, 6, 0, "Silvermoon City, Hunter Trainer");
SendQuickMenu(9332);
}break;
case 21: //Mage
{
Plr->Gossip_SendPOI(9996.914, -7104.803, 6, 6, 0, "Silvermoon City, Mage Trainer");
SendQuickMenu(9333);
}break;
case 22: //Paladin
{
Plr->Gossip_SendPOI(9850.22, -7516.93, 6, 6, 0, "Silvermoon City, Paladin Trainer");
SendQuickMenu(9334);
}break;
case 23: //Priest
{
Plr->Gossip_SendPOI(9935.37, -7131.14, 6, 6, 0, "Silvermoon City, Priest Trainer");
SendQuickMenu(9335);
}break;
case 24: //Rogue
{
Plr->Gossip_SendPOI(9739.88, -7374.33, 6, 6, 0, "Silvermoon City, Rogue Trainer");
SendQuickMenu(9336);
}break;
case 25: //Warlock
{
Plr->Gossip_SendPOI(9803.052, -7316.967, 6, 6, 0, "Silvermoon City, Warlock Trainer");
SendQuickMenu(9337);
}break;
case 26: //Alchemy
{
Plr->Gossip_SendPOI(10000.9, -7216.63, 6, 6, 0, "Silvermoon City, Alchemy");
SendQuickMenu(9339);
}break;
case 27: //Blacksmithing
{
Plr->Gossip_SendPOI(9841.43, -7361.53, 6, 6, 0, "Silvermoon City, Blacksmithing");
SendQuickMenu(9340);
}break;
case 28: //Cooking
{
Plr->Gossip_SendPOI(9577.26, -7243.6, 6, 6, 0, "Silvermoon City, Cooking");
SendQuickMenu(9624);
}break;
case 29: //Enchanting
{
Plr->Gossip_SendPOI(9962.57, -7246.18, 6, 6, 0, "Silvermoon City, Enchanting");
SendQuickMenu(9341);
}break;
case 30: //Engineering
{
Plr->Gossip_SendPOI(9808.85, -7287.31, 6, 6, 0, "Silvermoon City, Engineering");
SendQuickMenu(9342);
}break;
case 31: //First Aid
{
Plr->Gossip_SendPOI(9588.61, -7337.526, 6, 6, 0, "Silvermoon City, First Aid");
SendQuickMenu(9343);
}break;
case 32: //Fishing
{
Plr->Gossip_SendPOI(9601.97, -7332.34, 6, 6, 0, "Silvermoon City, Fishing");
SendQuickMenu(9344);
}break;
case 33: //Herbalism
{
Plr->Gossip_SendPOI(9996.96, -7208.39, 6, 6, 0, "Silvermoon City, Herbalism");
SendQuickMenu(9345);
}break;
case 34: //Inscription
{
Plr->Gossip_SendPOI(9957.12, -7242.85, 6, 6, 0, "Silvermoon City, Inscription");
SendQuickMenu(13893);
}break;
case 35: //Jewelcrafting
{
Plr->Gossip_SendPOI(9552.8, -7502.12, 6, 6, 0, "Silvermoon City, Jewelcrafting");
SendQuickMenu(9346);
}break;
case 36: //Leatherworking
{
Plr->Gossip_SendPOI(9502.486, -7425.51, 6, 6, 0, "Silvermoon City, Leatherworking");
SendQuickMenu(9347);
}break;
case 37: //Mining
{
Plr->Gossip_SendPOI(9813.73, -7360.19, 6, 6, 0, "Silvermoon City, Mining");
SendQuickMenu(9348);
}break;
case 38: //Skinning
{
Plr->Gossip_SendPOI(9513.37, -7429.4, 6, 6, 0, "Silvermoon City, Skinning");
SendQuickMenu(9349);
}break;
case 39: //Tailoring
{
Plr->Gossip_SendPOI(9727.56, -7086.65, 6, 6, 0, "Silvermoon City, Tailoring");
SendQuickMenu(9350);
}break;
case 40: //Lexicon of Power
{
Plr->Gossip_SendPOI(9957.12, -7242.85, 6, 6, 0, "Silvermoon City, Inscription");
SendQuickMenu(14174);
}break;
}
}
};
class ExodarGuard : public GossipScript
{
public:
void Destroy()
{
delete this;
}
void GossipHello(Object* pObject, Player * Plr, bool AutoSend)
{
GossipMenu *Menu;
objmgr.CreateGossipMenuForPlayer(&Menu, pObject->GetGUID(), 9551, Plr);
Menu->AddItem(0, "Auction House" , 1);
Menu->AddItem(0, "The Bank" , 2);
Menu->AddItem(0, "Hippogryph Master" , 3);
Menu->AddItem(0, "Guild Master" , 4);
Menu->AddItem(0, "The Inn" , 5);
Menu->AddItem(0, "Mailbox" , 6);
Menu->AddItem(0, "Stable Master" , 7);
Menu->AddItem(0, "Weapon Master" , 8);
Menu->AddItem(0, "Battlemasters" , 9);
Menu->AddItem(0, "Class Trainer" , 10);
Menu->AddItem(0, "Profession Trainer" , 11);
if(Plr->GetSession()->GetClientBuild() > 8606) // Greater than 2.4.3
Menu->AddItem(0, "Lexicon of Power" , 34);
if(AutoSend)
Menu->SendTo(Plr);
}
void GossipSelectOption(Object* pObject, Player* Plr, uint32 Id, uint32 IntId, const char * Code)
{
GossipMenu * Menu;
switch(IntId)
{
case 0: // Return to start
GossipHello(pObject, Plr, true);
break;
//////////////////////
// Main menu handlers
/////
case 1: // Auction House
SendQuickMenu(9528);
Plr->Gossip_SendPOI(-4013.82, -11729.64, 6, 6, 0, "Exodar, Auctioneer");
break;
case 2: // The Bank
SendQuickMenu(9529);
Plr->Gossip_SendPOI(-3923.89, -11544.5, 6, 6, 0, "Exodar, bank");
break;
case 3: // Hippogryph Master
SendQuickMenu(9530);
Plr->Gossip_SendPOI(-4058.45, -11789.7, 6, 6, 0, "Exodar, Hippogryph Master");
break;
case 4: // Guild Master
SendQuickMenu(9539);
Plr->Gossip_SendPOI(-4093.38, -11630.39, 6, 6, 0, "Exodar, Guild Master");
break;
case 5: // The Inn
SendQuickMenu(9545);
Plr->Gossip_SendPOI(-3765.34, -11695.8, 6, 6, 0, "Exodar, Inn");
break;
case 6: // Mailbox
SendQuickMenu(10254);
Plr->Gossip_SendPOI(-3913.75, -11606.83, 6, 6, 0, "Exodar, Mailbox");
break;
case 7: // Stable Master
SendQuickMenu(9558);
Plr->Gossip_SendPOI(-3787.01, -11702.7, 6, 6, 0, "Exodar, Stable Master");
break;
case 8: // Weapon Master
SendQuickMenu(9565);
Plr->Gossip_SendPOI(-4215.68, -11628.9, 6, 6, 0, "Exodar, Weapon Master");
break;
case 9: // Battlemasters
Plr->Gossip_SendPOI(-3999.82, -11368.33, 6, 6, 0, "Exodar, Battlemasters");
objmgr.CreateGossipMenuForPlayer(&Menu, pObject->GetGUID(), 9531, Plr);
Menu->AddItem(0, "Arena Battlemaster" , 12);
Menu->SendTo(Plr);
break;
case 10: // Class Trainers
{
objmgr.CreateGossipMenuForPlayer(&Menu, pObject->GetGUID(), 9533, Plr);
Menu->AddItem( 0, "Druid" , 13);
Menu->AddItem( 0, "Hunter" , 14);
Menu->AddItem( 0, "Mage" , 15);
Menu->AddItem( 0, "Paladin" , 16);
Menu->AddItem( 0, "Priest" , 17);
Menu->AddItem( 0, "Shaman" , 18);
Menu->AddItem( 0, "Warrior" , 19);
Menu->SendTo(Plr);
}break;
case 11: // Profession Trainers
{
objmgr.CreateGossipMenuForPlayer(&Menu, pObject->GetGUID(), 9555, Plr);
Menu->AddItem( 0, "Alchemy" , 20);
Menu->AddItem( 0, "Blacksmithing" , 21);
Menu->AddItem( 0, "Enchanting" , 22);
Menu->AddItem( 0, "Engineering" , 23);
Menu->AddItem( 0, "First Aid" , 24);
Menu->AddItem( 0, "Fishing" , 25);
Menu->AddItem( 0, "Herbalism" , 26);
if(Plr->GetSession()->GetClientBuild() > 8606) // Greater than 2.4.3
Menu->AddItem( 0, "Inscription" , 27);
Menu->AddItem( 0, "Jewelcrafting" , 28);
Menu->AddItem( 0, "Leatherworking" , 29);
Menu->AddItem( 0, "Mining" , 30);
Menu->AddItem( 0, "Skinning" , 31);
Menu->AddItem( 0, "Tailoring" , 32);
Menu->AddItem( 0, "Cooking" , 33);
Menu->SendTo(Plr);
}break;
//////////////////
// Battlemaster submenu
////////
case 12://Arena Battlemaster Exodar
{
Plr->Gossip_SendPOI(-3725.25, -11688.3, 6, 6, 0, "Arena Battlemaster Exodar");
SendQuickMenu(10223);
}break;
case 13: //Druid
{
Plr->Gossip_SendPOI(-4274.81, -11495.3, 6, 6, 0, "Exodar, Druid Trainer");
SendQuickMenu(9534);
}break;
case 14: //Hunter
{
Plr->Gossip_SendPOI(-4229.36, -11563.36, 6, 6, 0, "Exodar, Hunter Trainers");
SendQuickMenu(9544);
}break;
case 15: //Mage
{
Plr->Gossip_SendPOI(-4048.8, -11559.02, 6, 6, 0, "Exodar, Mage Trainers");
SendQuickMenu(9550);
}break;
case 16: //Paladin
{
Plr->Gossip_SendPOI(-4176.57, -11476.46, 6, 6, 0, "Exodar, Paladin Trainers");
SendQuickMenu(9553);
}break;
case 17: //Priest
{
Plr->Gossip_SendPOI(-3972.38, -11483.2, 6, 6, 0, "Exodar, Priest Trainers");
SendQuickMenu(9554);
}break;
case 18: //Shaman
{
Plr->Gossip_SendPOI(-3843.8, -11390.75, 6, 6, 0, "Exodar, Shaman Trainer");
SendQuickMenu(9556);
}break;
case 19: //Warrior
{
Plr->Gossip_SendPOI(-4191.11, -11650.45, 6, 6, 0, "Exodar, Warrior Trainers");
SendQuickMenu(9562);
}break;
case 20: //Alchemy
{
Plr->Gossip_SendPOI(-4042.37, -11366.3, 6, 6, 0, "Exodar, Alchemist Trainers");
SendQuickMenu(9527);
}break;
case 21: //Blacksmithing
{
Plr->Gossip_SendPOI(-4232.4, -11705.23, 6, 6, 0, "Exodar, Blacksmithing Trainers");
SendQuickMenu(9532);
}break;
case 22: //Enchanting
{
Plr->Gossip_SendPOI(-3889.3, -11495, 6, 6, 0, "Exodar, Enchanters");
SendQuickMenu(9535);
}break;
case 23: //Engineering
{
Plr->Gossip_SendPOI(-4257.93, -11636.53, 6, 6, 0, "Exodar, Engineering");
SendQuickMenu(9536);
}break;
case 24: //First Aid
{
Plr->Gossip_SendPOI(-3766.05, -11481.8, 6, 6, 0, "Exodar, First Aid Trainer");
SendQuickMenu(9537);
}break;
case 25: //Fishing
{
Plr->Gossip_SendPOI(-3726.64, -11384.43, 6, 6, 0, "Exodar, Fishing Trainer");
SendQuickMenu(9538);
}break;
case 26: //Herbalism
{
Plr->Gossip_SendPOI(-4052.5, -11356.6, 6, 6, 0, "Exodar, Herbalism Trainer");
SendQuickMenu(9543);
}break;
case 27: //Inscription
{
Plr->Gossip_SendPOI(-3889.3, -11495, 6, 6, 0, "Exodar, Inscription");
SendQuickMenu(13887);
}break;
case 28: //Jewelcrafting
{
Plr->Gossip_SendPOI(-3786.27, -11541.33, 6, 6, 0, "Exodar, Jewelcrafters");
SendQuickMenu(9547);
}break;
case 29: //Leatherworking
{
Plr->Gossip_SendPOI(-4134.42, -11772.93, 6, 6, 0, "Exodar, Leatherworking");
SendQuickMenu(9549);
}break;
case 30: //Mining
{
Plr->Gossip_SendPOI(-4220.31, -11694.29, 6, 6, 0, "Exodar, Mining Trainers");
SendQuickMenu(9552);
}break;
case 31: //Skinning
{
Plr->Gossip_SendPOI(-4134.97, -11760.5, 6, 6, 0, "Exodar, Skinning Trainer");
SendQuickMenu(9557);
}break;
case 32: //Tailoring
{
Plr->Gossip_SendPOI(-4095.78, -11746.9, 6, 6, 0, "Exodar, Tailors");
SendQuickMenu(9350);
}break;
case 33: //Cooking
{
Plr->Gossip_SendPOI(-3799.69, -11650.51, 6, 6, 0, "Exodar, Cook");
SendQuickMenu(9559);
}break;
case 34: //Lexicon of Power
{
Plr->Gossip_SendPOI(-3889.3, -11495, 6, 6, 0, "Exodar, Inscription");
SendQuickMenu(14174);
}break;
}
}
};
class OrgrimmarGuard : public GossipScript
{
public:
void Destroy()
{
delete this;
}
void GossipHello(Object* pObject, Player * Plr, bool AutoSend)
{
GossipMenu *Menu;
objmgr.CreateGossipMenuForPlayer(&Menu, pObject->GetGUID(), 2593, Plr);
Menu->AddItem(0, "The bank", 1);
Menu->AddItem(0, "The wind rider master", 2);
Menu->AddItem(0, "The guild master", 3);
Menu->AddItem(0, "The inn", 4);
Menu->AddItem(0, "The mailbox", 5);
Menu->AddItem(0, "The auction house", 6);
Menu->AddItem(0, "The zeppelin master", 7);
Menu->AddItem(0, "The weapon master", 8);
Menu->AddItem(0, "The stable master", 9);
Menu->AddItem(0, "The officers' lounge", 10);
Menu->AddItem(0, "The battlemaster", 11);
Menu->AddItem(0, "A class trainer", 12);
Menu->AddItem(0, "A profession trainer", 13);
if(AutoSend)
Menu->SendTo(Plr);
}
void GossipSelectOption(Object* pObject, Player* Plr, uint32 Id, uint32 IntId, const char * Code)
{
GossipMenu * Menu;
switch(IntId)
{
case 0: // Return to start
GossipHello(pObject, Plr, true);
break;
//////////////////////
// Main menu handlers
/////
case 1: // The bank
SendQuickMenu(2554);
Plr->Gossip_SendPOI(1631.51, -4375.33, 6, 6, 0, "Bank of Orgrimmar");
break;
case 2: // The wind rider master
SendQuickMenu(2555);
Plr->Gossip_SendPOI(1676.6, -4332.72, 6, 6, 0, "The Sky Tower");
break;
case 3: // The guild master
SendQuickMenu(2556);
Plr->Gossip_SendPOI(1576.93, -4294.75, 6, 6, 0, "Horde Embassy");
break;
case 4: // The inn
SendQuickMenu(2557);
Plr->Gossip_SendPOI(1644.51, -4447.27, 6, 6, 0, "Orgrimmar Inn");
break;
case 5: // The mailbox
SendQuickMenu(2558);
Plr->Gossip_SendPOI(1622.53, -4388.79, 6, 6, 0, "Orgrimmar Mailbox");
break;
case 6: // The auction house
SendQuickMenu(3075);
Plr->Gossip_SendPOI(1679.21, -4450.1, 6, 6, 0, "Orgrimmar Auction House");
break;
case 7: // The zeppelin master
SendQuickMenu(3173);
Plr->Gossip_SendPOI(1337.36, -4632.7, 6, 6, 0, "Orgrimmar Zeppelin Tower");
break;
case 8: // The weapon master
SendQuickMenu(4519);
Plr->Gossip_SendPOI(2092.56, -4823.95, 6, 6, 0, "Sayoc & Hanashi");
break;
case 9: // The stable master
SendQuickMenu(5974);
Plr->Gossip_SendPOI(2133.12, -4663.93, 6, 6, 0, "Xon'cha");
break;
case 10: // The officers' lounge
SendQuickMenu(7046);
Plr->Gossip_SendPOI(1633.56, -4249.37, 6, 6, 0, "Hall of Legends");
break;
case 11: // The battlemaster
SendQuickMenu(7521);
Plr->Gossip_SendPOI(1990.41, -4794.15, 6, 6, 0, "Battlemasters Orgrimmar");
break;
case 12: // A class trainer
{
objmgr.CreateGossipMenuForPlayer(&Menu, pObject->GetGUID(), 2599, Plr);
Menu->AddItem( 0, "Hunter" , 14);
Menu->AddItem( 0, "Mage" , 15);
Menu->AddItem( 0, "Priest" , 16);
Menu->AddItem( 0, "Shaman" , 17);
Menu->AddItem( 0, "Rogue" , 18);
Menu->AddItem( 0, "Warlock" , 19);
Menu->AddItem( 0, "Warrior" , 20);
Menu->AddItem( 0, "Paladin" , 21);
Menu->SendTo(Plr);
}break;
case 13: // A profession trainer
{
objmgr.CreateGossipMenuForPlayer(&Menu, pObject->GetGUID(), 2594, Plr);
Menu->AddItem( 0, "Alchemy" , 22);
Menu->AddItem( 0, "Blacksmithing" , 23);
Menu->AddItem( 0, "Cooking" , 24);
Menu->AddItem( 0, "Enchanting" , 25);
Menu->AddItem( 0, "Engineering" , 26);
Menu->AddItem( 0, "First Aid" , 27);
Menu->AddItem( 0, "Fishing" , 28);
Menu->AddItem( 0, "Herbalism" , 29);
Menu->AddItem( 0, "Leatherworking" , 30);
Menu->AddItem( 0, "Mining" , 31);
Menu->AddItem( 0, "Skinning" , 32);
Menu->AddItem( 0, "Tailoring" , 33);
Menu->SendTo(Plr);
}break;
////////////////
// Class trainer submenu
////////
case 14: //Hunter
{
Plr->Gossip_SendPOI(2114.84, -4625.31, 6, 6, 0, "Orgrimmar Hunter's Hall");
SendQuickMenu(2559);
}break;
case 15: //Mage
{
Plr->Gossip_SendPOI(1451.26, -4223.33, 6, 6, 0, "Darkbriar Lodge");
SendQuickMenu(2560);
}break;
case 16: //Priest
{
Plr->Gossip_SendPOI(1442.21, -4183.24, 6, 6, 0, "Spirit Lodge");
SendQuickMenu(2561);
}break;
case 17: //Shaman
{
Plr->Gossip_SendPOI(1925.34, -4181.89, 6, 6, 0, "Thrall's Fortress");
SendQuickMenu(2562);
}break;
case 18: //Rogue
{
Plr->Gossip_SendPOI(1773.39, -4278.97, 6, 6, 0, "Shadowswift Brotherhood");
SendQuickMenu(2563);
}break;
case 19: //Warlock
{
Plr->Gossip_SendPOI(1849.57, -4359.68, 6, 6, 0, "Darkfire Enclave");
SendQuickMenu(2564);
}break;
case 20: //Warrior
{
Plr->Gossip_SendPOI(1983.92, -4794.2, 6, 6, 0, "Hall of the Brave");
SendQuickMenu(2565);
}break;
case 21: //Paladin
{
Plr->Gossip_SendPOI(1937.53, -4141.0, 6, 6, 0, "Thrall's Fortress");
SendQuickMenu(2566);
}break;
case 22: //Alchemy
{
Plr->Gossip_SendPOI(1955.17, -4475.79, 6, 6, 0, "Yelmak's Alchemy and Potions");
SendQuickMenu(2497);
}break;
case 23: //Blacksmithing
{
Plr->Gossip_SendPOI(2054.34, -4831.85, 6, 6, 0, "The Burning Anvil");
SendQuickMenu(2499);
}break;
case 24: //Cooking
{
Plr->Gossip_SendPOI(1780.96, -4481.31, 6, 6, 0, "Borstan's Firepit");
SendQuickMenu(2500);
}break;
case 25: //Enchanting
{
Plr->Gossip_SendPOI(1917.5, -4434.95, 6, 6, 0, "Godan's Runeworks");
SendQuickMenu(2501);
}break;
case 26: //Engineering
{
Plr->Gossip_SendPOI(2038.45, -4744.75, 6, 6, 0, "Nogg's Machine Shop");
SendQuickMenu(2653);
}break;
case 27: //First Aid
{
Plr->Gossip_SendPOI(1485.21, -4160.91, 6, 6, 0, "Survival of the Fittest");
SendQuickMenu(2502);
}break;
case 28: //Fishing
{
Plr->Gossip_SendPOI(1994.15, -4655.7, 6, 6, 0, "Lumak's Fishing");
SendQuickMenu(2503);
}break;
case 29: //Herbalism
{
Plr->Gossip_SendPOI(1898.61, -4454.93, 6, 6, 0, "Jandi's Arboretum");
SendQuickMenu(2504);
}break;
case 30: //Leatherworking
{
Plr->Gossip_SendPOI(1852.82, -4562.31, 6, 6, 0, "Kodohide Leatherworkers");
SendQuickMenu(2513);
}break;
case 31: //Mining
{
Plr->Gossip_SendPOI(2029.79, -4704, 6, 6, 0, "Red Canyon Mining");
SendQuickMenu(2515);
}break;
case 32: //Skinning
{
Plr->Gossip_SendPOI(1852.82, -4562.31, 6, 6, 0, "Kodohide Leatherworkers");
SendQuickMenu(2516);
}break;
case 33: //Tailoring
{
Plr->Gossip_SendPOI(1802.66, -4560.66, 6, 6, 0, "Magar's Cloth Goods");
SendQuickMenu(2518);
}break;
}
}
};
class ThunderbluffGuard : public GossipScript
{
public:
void Destroy()
{
delete this;
}
void GossipHello(Object* pObject, Player * Plr, bool AutoSend)
{
GossipMenu *Menu;
objmgr.CreateGossipMenuForPlayer(&Menu, pObject->GetGUID(), 3543, Plr);
Menu->AddItem(0, "The bank", 1);
Menu->AddItem(0, "The wind rider master", 2);
Menu->AddItem(0, "The guild master", 3);
Menu->AddItem(0, "The inn", 4);
Menu->AddItem(0, "The mailbox", 5);
Menu->AddItem(0, "The auction house", 6);
Menu->AddItem(0, "The weapon master", 7);
Menu->AddItem(0, "The stable master", 8);
Menu->AddItem(0, "The battlemaster", 9);
Menu->AddItem(0, "A class trainer", 10);
Menu->AddItem(0, "A profession trainer", 11);
if(AutoSend)
Menu->SendTo(Plr);
}
void GossipSelectOption(Object* pObject, Player* Plr, uint32 Id, uint32 IntId, const char * Code)
{
GossipMenu * Menu;
switch(IntId)
{
case 0: // Return to start
GossipHello(pObject, Plr, true);
break;
//////////////////////
// Main menu handlers
/////
case 1: // The bank
SendQuickMenu(1292);
Plr->Gossip_SendPOI(-1257.8, 24.14, 6, 6, 0, "Thunder Bluff Bank");
break;
case 2: // The wind rider master
SendQuickMenu(1293);
Plr->Gossip_SendPOI(-1196.43, 28.26, 6, 6, 0, "Wind Rider Roost");
break;
case 3: // The guild master
SendQuickMenu(1291);
Plr->Gossip_SendPOI(-1296.5, 127.57, 6, 6, 0, "Thunder Bluff Civic Information");
break;
case 4: // The inn
SendQuickMenu(3153);
Plr->Gossip_SendPOI(-1296, 39.7, 6, 6, 0, "Thunder Bluff Inn");
break;
case 5: // The mailbox
SendQuickMenu(3154);
Plr->Gossip_SendPOI(-1263.59, 44.36, 6, 6, 0, "Thunder Bluff Mailbox");
break;
case 6: // The auction house
SendQuickMenu(3155);
Plr->Gossip_SendPOI(-1205.51, 105.74, 6, 6, 0, "Thunder Bluff Auction house");
break;
case 7: // The weapon master
SendQuickMenu(4520);
Plr->Gossip_SendPOI(-1282.31, 89.56, 6, 6, 0, "Ansekhwa");
break;
case 8: // The stable master
SendQuickMenu(5977);
Plr->Gossip_SendPOI(-1270.19, 48.84, 6, 6, 0, "Bulrug");
break;
case 9: // The battlemaster
SendQuickMenu(7527);
Plr->Gossip_SendPOI(-1391.22, -81.33, 6, 6, 0, "Battlemasters Thunder Bluff");
break;
case 10: // A class trainer
{
objmgr.CreateGossipMenuForPlayer(&Menu, pObject->GetGUID(), 3542, Plr);
Menu->AddItem( 0, "Druid" , 12);
Menu->AddItem( 0, "Hunter" , 13);
Menu->AddItem( 0, "Mage" , 14);
Menu->AddItem( 0, "Priest" , 15);
Menu->AddItem( 0, "Shaman" , 16);
Menu->AddItem( 0, "Warrior" , 17);
Menu->SendTo(Plr);
}break;
case 11: // A profession trainer
{
objmgr.CreateGossipMenuForPlayer(&Menu, pObject->GetGUID(), 3541, Plr);
Menu->AddItem( 0, "Alchemy" , 18);
Menu->AddItem( 0, "Blacksmithing" , 19);
Menu->AddItem( 0, "Cooking" , 20);
Menu->AddItem( 0, "Enchanting" , 21);
Menu->AddItem( 0, "First Aid" , 22);
Menu->AddItem( 0, "Fishing" , 23);
Menu->AddItem( 0, "Herbalism" , 24);
Menu->AddItem( 0, "Leatherworking" , 25);
Menu->AddItem( 0, "Mining" , 26);
Menu->AddItem( 0, "Skinning" , 27);
Menu->AddItem( 0, "Tailoring" , 28);
Menu->SendTo(Plr);
}break;
////////////////
// Class trainer submenu
////////
case 12: //Druid
{
Plr->Gossip_SendPOI(-1054.47, -285, 6, 6, 0, "Hall of Elders");
SendQuickMenu(1294);
}break;
case 13: //Hunter
{
Plr->Gossip_SendPOI(-1416.32, -114.28, 6, 6, 0, "Hunter's Hall");
SendQuickMenu(1295);
}break;
case 14: //Mage
{
Plr->Gossip_SendPOI(-1061.2, 195.5, 6, 6, 0, "Pools of Vision");
SendQuickMenu(1296);
}break;
case 15: //Priest
{
Plr->Gossip_SendPOI(-1061.2, 195.5, 6, 6, 0, "Pools of Vision");
SendQuickMenu(1297);
}break;
case 16: //Shaman
{
Plr->Gossip_SendPOI(-989.54, 278.25, 6, 6, 0, "Hall of Spirits");
SendQuickMenu(1298);
}break;
case 17: //Warrior
{
Plr->Gossip_SendPOI(-1416.32, -114.28, 6, 6, 0, "Hunter's Hall");
SendQuickMenu(1299);
}break;
case 18: //Alchemy
{
Plr->Gossip_SendPOI(-1085.56, 27.29, 6, 6, 0, "Bena's Alchemy");
SendQuickMenu(1332);
}break;
case 19: //Blacksmithing
{
Plr->Gossip_SendPOI(-1239.75, 104.88, 6, 6, 0, "Karn's Smithy");
SendQuickMenu(1333);
}break;
case 20: //Cooking
{
Plr->Gossip_SendPOI(-1214.5, -21.23, 6, 6, 0, "Aska's Kitchen");
SendQuickMenu(1334);
}break;
case 21: //Enchanting
{
Plr->Gossip_SendPOI(-1112.65, 48.26, 6, 6, 0, "Dawnstrider Enchanters");
SendQuickMenu(1335);
}break;
case 22: //First Aid
{
Plr->Gossip_SendPOI(-996.58, 200.5, 6, 6, 0, "Spiritual Healing");
SendQuickMenu(1336);
}break;
case 23: //Fishing
{
Plr->Gossip_SendPOI(-1169.35, -68.87, 6, 6, 0, "Mountaintop Bait & Tackle");
SendQuickMenu(1337);
}break;
case 24: //Herbalism
{
Plr->Gossip_SendPOI(-1137.7, -1.51, 6, 6, 0, "Holistic Herbalism");
SendQuickMenu(1338);
}break;
case 25: //Leatherworking
{
Plr->Gossip_SendPOI(-1156.22, 66.86, 6, 6, 0, "Thunder Bluff Armorers");
SendQuickMenu(1339);
}break;
case 26: //Mining
{
Plr->Gossip_SendPOI(-1249.17, 155, 6, 6, 0, "Stonehoof Geology");
SendQuickMenu(1340);
}break;
case 27: //Skinning
{
Plr->Gossip_SendPOI(-1148.56, 51.18, 6, 6, 0, "Mooranta");
SendQuickMenu(1343);
}break;
case 28: //Tailoring
{
Plr->Gossip_SendPOI(-1156.22, 66.86, 6, 6, 0, "Thunder Bluff Armorers");
SendQuickMenu(1341);
}break;
}
}
};
class BloodhoofGuard : public GossipScript
{
public:
void Destroy()
{
delete this;
}
void GossipHello(Object* pObject, Player * Plr, bool AutoSend)
{
GossipMenu *Menu;
objmgr.CreateGossipMenuForPlayer(&Menu, pObject->GetGUID(), 3543, Plr);
Menu->AddItem(0, "The bank", 1);
Menu->AddItem(0, "The wind rider master", 2);
Menu->AddItem(0, "The inn", 3);
Menu->AddItem(0, "The stable master", 4);
Menu->AddItem(0, "A class trainer", 5);
Menu->AddItem(0, "A profession trainer", 6);
if(AutoSend)
Menu->SendTo(Plr);
}
void GossipSelectOption(Object* pObject, Player* Plr, uint32 Id, uint32 IntId, const char * Code)
{
GossipMenu * Menu;
switch(IntId)
{
case 0: // Return to start
GossipHello(pObject, Plr, true);
break;
//////////////////////
// Main menu handlers
/////
case 1: // The bank
SendQuickMenu(4051);
break;
case 2: // The wind rider master
SendQuickMenu(4052);
break;
case 3: // The inn
SendQuickMenu(4053);
Plr->Gossip_SendPOI(-2361.38, -349.19, 6, 6, 0, "Bloodhoof Village Inn");
break;
case 4: // The stable master
SendQuickMenu(5976);
Plr->Gossip_SendPOI(-2338.86, -357.56, 6, 6, 0, "Seikwa");
break;
case 5: // A class trainer
{
objmgr.CreateGossipMenuForPlayer(&Menu, pObject->GetGUID(), 4069, Plr);
Menu->AddItem( 0, "Druid" , 7);
Menu->AddItem( 0, "Hunter" , 8);
Menu->AddItem( 0, "Shaman" , 9);
Menu->AddItem( 0, "Warrior" , 10);
Menu->SendTo(Plr);
}break;
case 6: // A profession trainer
{
objmgr.CreateGossipMenuForPlayer(&Menu, pObject->GetGUID(), 3541, Plr);
Menu->AddItem( 0, "Alchemy" , 11);
Menu->AddItem( 0, "Blacksmithing" , 12);
Menu->AddItem( 0, "Cooking" , 13);
Menu->AddItem( 0, "Enchanting" , 14);
Menu->AddItem( 0, "First Aid" , 15);
Menu->AddItem( 0, "Fishing" , 16);
Menu->AddItem( 0, "Herbalism" , 17);
Menu->AddItem( 0, "Leatherworking" , 18);
Menu->AddItem( 0, "Mining" , 19);
Menu->AddItem( 0, "Skinning" , 20);
Menu->AddItem( 0, "Tailoring" , 21);
Menu->SendTo(Plr);
}break;
////////////////
// Class trainer submenu
////////
case 7: //Druid
{
Plr->Gossip_SendPOI(-2312.15, -443.69, 6, 6, 0, "Gennia Runetotem");
SendQuickMenu(4054);
}break;
case 8: //Hunter
{
Plr->Gossip_SendPOI(-2178.14, -406.14, 6, 6, 0, "Yaw Sharpmane");
SendQuickMenu(4055);
}break;
case 9: //Shaman
{
Plr->Gossip_SendPOI(-2301.5, -439.87, 6, 6, 0, "Narm Skychaser");
SendQuickMenu(4056);
}break;
case 10: //Warrior
{
Plr->Gossip_SendPOI(-2345.43, -494.11, 6, 6, 0, "Krang Stonehoof");
SendQuickMenu(4057);
}break;
case 11: //Alchemy
{
SendQuickMenu(4058);
}break;
case 12: //Blacksmithing
{
SendQuickMenu(4059);
}break;
case 13: //Cooking
{
Plr->Gossip_SendPOI(-2263.34, -287.91, 6, 6, 0, "Pyall Silentstride");
SendQuickMenu(4060);
}break;
case 14: //Enchanting
{
SendQuickMenu(4061);
}break;
case 15: //First Aid
{
Plr->Gossip_SendPOI(-2353.52, -355.82, 6, 6, 0, "Vira Younghoof");
SendQuickMenu(4062);
}break;
case 16: //Fishing
{
Plr->Gossip_SendPOI(-2349.21, -241.37, 6, 6, 0, "Uthan Stillwater");
SendQuickMenu(4063);
}break;
case 17: //Herbalism
{
SendQuickMenu(4064);
}break;
case 18: //Leatherworking
{
Plr->Gossip_SendPOI(-2257.12, -288.63, 6, 6, 0, "Chaw Stronghide");
SendQuickMenu(4065);
}break;
case 19: //Mining
{
SendQuickMenu(4066);
}break;
case 20: //Skinning
{
Plr->Gossip_SendPOI(-2252.94, -291.32, 6, 6, 0, "Yonn Deepcut");
SendQuickMenu(4067);
}break;
case 21: //Tailoring
{
SendQuickMenu(4068);
}break;
}
}
};
class RazorHillGuard : public GossipScript
{
public:
void Destroy()
{
delete this;
}
void GossipHello(Object* pObject, Player * Plr, bool AutoSend)
{
GossipMenu *Menu;
objmgr.CreateGossipMenuForPlayer(&Menu, pObject->GetGUID(), 4037, Plr);
Menu->AddItem(0, "The bank", 1);
Menu->AddItem(0, "The wind rider master", 2);
Menu->AddItem(0, "The inn", 3);
Menu->AddItem(0, "The stable master", 4);
Menu->AddItem(0, "A class trainer", 5);
Menu->AddItem(0, "A profession trainer", 6);
if(AutoSend)
Menu->SendTo(Plr);
}
void GossipSelectOption(Object* pObject, Player* Plr, uint32 Id, uint32 IntId, const char * Code)
{
GossipMenu * Menu;
switch(IntId)
{
case 0: // Return to start
GossipHello(pObject, Plr, true);
break;
//////////////////////
// Main menu handlers
/////
case 1: // The bank
SendQuickMenu(4032);
break;
case 2: // The wind rider master
SendQuickMenu(4033);
break;
case 3: // The inn
SendQuickMenu(4034);
Plr->Gossip_SendPOI(338.7, -4688.87, 6, 6, 0, "Razor Hill Inn");
break;
case 4: // The stable master
SendQuickMenu(5973);
Plr->Gossip_SendPOI(330.31, -4710.66, 6, 6, 0, "Shoja'my");
break;
case 5: // A class trainer
{
objmgr.CreateGossipMenuForPlayer(&Menu, pObject->GetGUID(), 4035, Plr);
Menu->AddItem( 0, "Hunter" , 7);
Menu->AddItem( 0, "Mage" , 8);
Menu->AddItem( 0, "Priest" , 9);
Menu->AddItem( 0, "Rogue" , 10);
Menu->AddItem( 0, "Shaman" , 11);
Menu->AddItem( 0, "Warlock" , 12);
Menu->AddItem( 0, "Warrior" , 13);
Menu->SendTo(Plr);
}break;
case 6: // A profession trainer
{
objmgr.CreateGossipMenuForPlayer(&Menu, pObject->GetGUID(), 3541, Plr);
Menu->AddItem( 0, "Alchemy" , 14);
Menu->AddItem( 0, "Blacksmithing" , 15);
Menu->AddItem( 0, "Cooking" , 16);
Menu->AddItem( 0, "Enchanting" , 17);
Menu->AddItem( 0, "Engineering" , 18);
Menu->AddItem( 0, "First Aid" , 19);
Menu->AddItem( 0, "Fishing" , 20);
Menu->AddItem( 0, "Herbalism" , 21);
Menu->AddItem( 0, "Leatherworking" , 22);
Menu->AddItem( 0, "Mining" , 23);
Menu->AddItem( 0, "Skinning" , 24);
Menu->AddItem( 0, "Tailoring" , 25);
Menu->SendTo(Plr);
}break;
////////////////
// Class trainer submenu
////////
case 7: //Hunter
{
Plr->Gossip_SendPOI(276, -4706.72, 6, 6, 0, "Thotar");
SendQuickMenu(4013);
}break;
case 8: //Mage
{
Plr->Gossip_SendPOI(-839.33, -4935.6, 6, 6, 0, "Un'Thuwa");
SendQuickMenu(4014);
}break;
case 9: //Priest
{
Plr->Gossip_SendPOI(296.22, -4828.1, 6, 6, 0, "Tai'jin");
SendQuickMenu(4015);
}break;
case 10: //Rogue
{
Plr->Gossip_SendPOI(265.76, -4709, 6, 6, 0, "Kaplak");
SendQuickMenu(4016);
}break;
case 11: //Shaman
{
Plr->Gossip_SendPOI(307.79, -4836.97, 6, 6, 0, "Swart");
SendQuickMenu(4017);
}break;
case 12: //Warlock
{
Plr->Gossip_SendPOI(355.88, -4836.45, 6, 6, 0, "Dhugru Gorelust");
SendQuickMenu(4018);
}break;
case 13: //Warrior
{
Plr->Gossip_SendPOI(312.3, -4824.66, 6, 6, 0, "Tarshaw Jaggedscar");
SendQuickMenu(4019);
}break;
case 14: //Alchemy
{
Plr->Gossip_SendPOI(-800.25, -4894.33, 6, 6, 0, "Miao'zan");
SendQuickMenu(4020);
}break;
case 15: //Blacksmithing
{
Plr->Gossip_SendPOI(373.24, -4716.45, 6, 6, 0, "Dwukk");
SendQuickMenu(4021);
}break;
case 16: //Cooking
{
SendQuickMenu(4022);
}break;
case 17: //Enchanting
{
SendQuickMenu(4023);
}break;
case 18: //Engineering
{
Plr->Gossip_SendPOI(368.95, -4723.95, 6, 6, 0, "Mukdrak");
SendQuickMenu(4024);
}break;
case 19: //First Aid
{
Plr->Gossip_SendPOI(327.17, -4825.62, 6, 6, 0, "Rawrk");
SendQuickMenu(4025);
}break;
case 20: //Fishing
{
Plr->Gossip_SendPOI(-1065.48, -4777.43, 6, 6, 0, "Lau'Tiki");
SendQuickMenu(4026);
}break;
case 21: //Herbalism
{
Plr->Gossip_SendPOI(-836.25, -4896.89, 6, 6, 0, "Mishiki");
SendQuickMenu(4027);
}break;
case 22: //Leatherworking
{
SendQuickMenu(4028);
}break;
case 23: //Mining
{
Plr->Gossip_SendPOI(366.94, -4705, 6, 6, 0, "Krunn");
SendQuickMenu(4029);
}break;
case 24: //Skinning
{
Plr->Gossip_SendPOI(-2252.94, -291.32, 6, 6, 0, "Yonn Deepcut");
SendQuickMenu(4030);
}break;
case 25: //Tailoring
{
SendQuickMenu(4031);
}break;
}
}
};
class BrillGuard : public GossipScript
{
public:
void Destroy()
{
delete this;
}
void GossipHello(Object* pObject, Player * Plr, bool AutoSend)
{
GossipMenu *Menu;
objmgr.CreateGossipMenuForPlayer(&Menu, pObject->GetGUID(), 2593, Plr);
Menu->AddItem(0, "The bank", 1);
Menu->AddItem(0, "The bat handler", 2);
Menu->AddItem(0, "The inn", 3);
Menu->AddItem(0, "The stable master", 4);
Menu->AddItem(0, "A class trainer", 5);
Menu->AddItem(0, "A profession trainer", 6);
if(AutoSend)
Menu->SendTo(Plr);
}
void GossipSelectOption(Object* pObject, Player* Plr, uint32 Id, uint32 IntId, const char * Code)
{
GossipMenu * Menu;
switch(IntId)
{
case 0: // Return to start
GossipHello(pObject, Plr, true);
break;
//////////////////////
// Main menu handlers
/////
case 1: // The bank
SendQuickMenu(4074);
break;
case 2: // The bat handler
SendQuickMenu(4075);
break;
case 3: // The inn
SendQuickMenu(4076);
Plr->Gossip_SendPOI(2246.68, 241.89, 6, 6, 0, "Gallows` End Tavern");
break;
case 4: // The stable master
SendQuickMenu(5978);
Plr->Gossip_SendPOI(2267.66, 319.32, 6, 6, 0, "Morganus");
break;
case 5: // A class trainer
{
objmgr.CreateGossipMenuForPlayer(&Menu, pObject->GetGUID(), 4292, Plr);
Menu->AddItem( 0, "Mage" , 7);
Menu->AddItem( 0, "Paladin" , 8);
Menu->AddItem( 0, "Priest" , 9);
Menu->AddItem( 0, "Rogue" , 10);
Menu->AddItem( 0, "Warlock" , 11);
Menu->AddItem( 0, "Warrior" , 12);
Menu->SendTo(Plr);
}break;
case 6: // A profession trainer
{
objmgr.CreateGossipMenuForPlayer(&Menu, pObject->GetGUID(), 4300, Plr);
Menu->AddItem( 0, "Alchemy" , 13);
Menu->AddItem( 0, "Blacksmithing" , 14);
Menu->AddItem( 0, "Cooking" , 15);
Menu->AddItem( 0, "Enchanting" , 16);
Menu->AddItem( 0, "Engineering" , 17);
Menu->AddItem( 0, "First Aid" , 18);
Menu->AddItem( 0, "Fishing" , 19);
Menu->AddItem( 0, "Herbalism" , 20);
Menu->AddItem( 0, "Leatherworking" , 21);
Menu->AddItem( 0, "Mining" , 22);
Menu->AddItem( 0, "Skinning" , 23);
Menu->AddItem( 0, "Tailoring" , 24);
Menu->SendTo(Plr);
}break;
////////////////
// Class trainer submenu
////////
case 7: //Mage
{
Plr->Gossip_SendPOI(2259.18, 240.93, 6, 6, 0, "Cain Firesong");
SendQuickMenu(4077);
}break;
case 8: //Paladin
{
SendQuickMenu(0); // Need to add correct text
}break;
case 9: //Priest
{
Plr->Gossip_SendPOI(2259.18, 240.93, 6, 6, 0, "Dark Cleric Beryl");
SendQuickMenu(4078);
}break;
case 10: //Rogue
{
Plr->Gossip_SendPOI(2259.18, 240.93, 6, 6, 0, "Marion Call");
SendQuickMenu(4079);
}break;
case 11: //Warlock
{
Plr->Gossip_SendPOI(2259.18, 240.93, 6, 6, 0, "Rupert Boch");
SendQuickMenu(4080);
}break;
case 12: //Warrior
{
Plr->Gossip_SendPOI(2256.48, 240.32, 6, 6, 0, "Austil de Mon");
SendQuickMenu(4081);
}break;
case 13: //Alchemy
{
Plr->Gossip_SendPOI(2263.25, 344.23, 6, 6, 0, "Carolai Anise");
SendQuickMenu(4082);
}break;
case 14: //Blacksmithing
{
SendQuickMenu(4083);
}break;
case 15: //Cooking
{
SendQuickMenu(4084);
}break;
case 16: //Enchanting
{
Plr->Gossip_SendPOI(2250.35, 249.12, 6, 6, 0, "Vance Undergloom");
SendQuickMenu(4085);
}break;
case 17: //Engineering
{
SendQuickMenu(4086);
}break;
case 18: //First Aid
{
Plr->Gossip_SendPOI(2246.68, 241.89, 6, 6, 0, "Nurse Neela");
SendQuickMenu(4087);
}break;
case 19: //Fishing
{
Plr->Gossip_SendPOI(2292.37, -10.72, 6, 6, 0, "Clyde Kellen");
SendQuickMenu(4088);
}break;
case 20: //Herbalism
{
Plr->Gossip_SendPOI(2268.21, 331.69, 6, 6, 0, "Faruza");
SendQuickMenu(4089);
}break;
case 21: //Leatherworking
{
Plr->Gossip_SendPOI(2027, 78.72, 6, 6, 0, "Shelene Rhobart");
SendQuickMenu(4090);
}break;
case 22: //Mining
{
SendQuickMenu(4091);
}break;
case 23: //Skinning
{
Plr->Gossip_SendPOI(2027, 78.72, 6, 6, 0, "Rand Rhobart");
SendQuickMenu(4092);
}break;
case 24: //Tailoring
{
Plr->Gossip_SendPOI(2160.45, 659.93, 6, 6, 0, "Bowen Brisboise");
SendQuickMenu(4093);
}break;
}
}
};
class IronforgeGuard : public GossipScript
{
public:
void Destroy()
{
delete this;
}
void GossipHello(Object* pObject, Player * Plr, bool AutoSend)
{
GossipMenu *Menu;
objmgr.CreateGossipMenuForPlayer(&Menu, pObject->GetGUID(), 2760, Plr);
Menu->AddItem(0, "Auction House" , 1);
Menu->AddItem(0, "Bank of Ironforge" , 2);
Menu->AddItem(0, "Deeprun Tram" , 3);
Menu->AddItem(0, "Gryphon Master" , 4);
Menu->AddItem(0, "Guild Master" , 5);
Menu->AddItem(0, "The Inn" , 6);
Menu->AddItem(0, "Mailbox" , 7);
Menu->AddItem(0, "Stable Master" , 8);
Menu->AddItem(0, "Weapons Trainer" , 9);
Menu->AddItem(0, "Battlemaster" , 10);
if(Plr->GetSession()->GetClientBuild() > 8606) // Greater than 2.4.3
Menu->AddItem(0, "Barber" , 11);
Menu->AddItem(0, "Class Trainer" , 12);
Menu->AddItem(0, "Profession Trainer" , 13);
if(Plr->GetSession()->GetClientBuild() > 8606) // Greater than 2.4.3
Menu->AddItem(0, "Lexicon of Power" , 34);
if(AutoSend)
Menu->SendTo(Plr);
}
void GossipSelectOption(Object* pObject, Player* Plr, uint32 Id, uint32 IntId, const char * Code)
{
GossipMenu * Menu;
switch(IntId)
{
case 0: // Return to start
GossipHello(pObject, Plr, true);
break;
//////////////////////
// Main menu handlers
/////
case 1: // Auction House
SendQuickMenu(3014);
Plr->Gossip_SendPOI(-4957.39, -911.6, 6, 6, 0, "Ironforge Auction House");
break;
case 2: // Bank of Ironforge
SendQuickMenu(2761);
Plr->Gossip_SendPOI(-4891.91, -991.47, 6, 6, 0, "The Vault");
break;
case 3: // Deeprun Tram
SendQuickMenu(3814);
Plr->Gossip_SendPOI(-4835.27, -1294.69, 6, 6, 0, "Deeprun Tram");
break;
case 4: // Gryphon Master
SendQuickMenu(2762);
Plr->Gossip_SendPOI(-4821.52, -1152.3, 6, 6, 0, "Ironforge Gryphon Master");
break;
case 5: // Guild Master
SendQuickMenu(2764);
Plr->Gossip_SendPOI(-5021, -996.45, 6, 6, 0, "Ironforge Visitor's Center");
break;
case 6: // The Inn
SendQuickMenu(2768);
Plr->Gossip_SendPOI(-4850.47, -872.57, 6, 6, 0, "Stonefire Tavern");
break;
case 7: // Mailbox
SendQuickMenu(2769);
Plr->Gossip_SendPOI(-4845.7, -880.55, 6, 6, 0, "Ironforge Mailbox");
break;
case 8: // Stable Master
SendQuickMenu(5986);
Plr->Gossip_SendPOI(-5010.2, -1262, 6, 6, 0, "Ulbrek Firehand");
break;
case 9: // Weapon Trainer
SendQuickMenu(4518);
Plr->Gossip_SendPOI(-5040, -1201.88, 6, 6, 0, "Bixi and Buliwyf");
break;
case 10: // Battlemaster
SendQuickMenu(10216);
Plr->Gossip_SendPOI(-5038.54, -1266.44, 6, 6, 0, "Battlemasters Ironforge");
break;
case 11: // Barber
SendQuickMenu(13885);
Plr->Gossip_SendPOI(-4838.49, -919.18, 6, 6, 0, "Ironforge Barber");
break;
case 12: // A class trainer
{
objmgr.CreateGossipMenuForPlayer(&Menu, pObject->GetGUID(), 2766, Plr);
Menu->AddItem( 0, "Hunter" , 14);
Menu->AddItem( 0, "Mage" , 15);
Menu->AddItem( 0, "Paladin" , 16);
Menu->AddItem( 0, "Priest" , 17);
Menu->AddItem( 0, "Rogue" , 18);
Menu->AddItem( 0, "Warlock" , 19);
Menu->AddItem( 0, "Warrior" , 20);
Menu->AddItem( 0, "Shaman" , 21);
Menu->SendTo(Plr);
}break;
case 13: // A profession trainer
{
objmgr.CreateGossipMenuForPlayer(&Menu, pObject->GetGUID(), 2793, Plr);
Menu->AddItem( 0, "Alchemy" , 22);
Menu->AddItem( 0, "Blacksmithing" , 23);
Menu->AddItem( 0, "Cooking" , 24);
Menu->AddItem( 0, "Enchanting" , 25);
Menu->AddItem( 0, "Engineering" , 26);
Menu->AddItem( 0, "First Aid" , 27);
Menu->AddItem( 0, "Fishing" , 28);
Menu->AddItem( 0, "Herbalism" , 29);
if(Plr->GetSession()->GetClientBuild() > 8606) // Greater than 2.4.3
Menu->AddItem(0, "Inscription" , 30);
Menu->AddItem( 0, "Leatherworking" , 31);
Menu->AddItem( 0, "Mining" , 32);
Menu->AddItem( 0, "Skinning" , 33);
Menu->AddItem( 0, "Tailoring" , 34);
Menu->SendTo(Plr);
}break;
////////////////
// Class trainer submenu
////////
case 14: //Hunter
{
Plr->Gossip_SendPOI(-5023, -1253.68, 6, 6, 0, "Hall of Arms");
SendQuickMenu(2770);
}break;
case 15: //Mage
{
Plr->Gossip_SendPOI(-4627, -926.45, 6, 6, 0, "Hall of Mysteries");
SendQuickMenu(2771);
}break;
case 16: //Paladin
{
Plr->Gossip_SendPOI(-4627.02, -926.45, 6, 6, 0, "Hall of Mysteries");
SendQuickMenu(2773);
}break;
case 17: //Priest
{
Plr->Gossip_SendPOI(-4627, -926.45, 6, 6, 0, "Hall of Mysteries");
SendQuickMenu(2772);
}break;
case 18: //Rogue
{
Plr->Gossip_SendPOI(-4647.83, -1124, 6, 6, 0, "Ironforge Rogue Trainer");
SendQuickMenu(2774);
}break;
case 19: //Warlock
{
Plr->Gossip_SendPOI(-4605, -1110.45, 6, 6, 0, "Ironforge Warlock Trainer");
SendQuickMenu(2775);
}break;
case 20: //Warrior
{
Plr->Gossip_SendPOI(-5023.08, -1253.68, 6, 6, 0, "Hall of Arms");
SendQuickMenu(2776);
}break;
case 21: //Shaman
{
Plr->Gossip_SendPOI(-4722.02, -1150.66, 6, 6, 0, "Ironforge Shaman Trainer");
SendQuickMenu(10842);
}break;
case 22: //Alchemy
{
Plr->Gossip_SendPOI(-4858.5, -1241.83, 6, 6, 0, "Berryfizz's Potions and Mixed Drinks");
SendQuickMenu(2794);
}break;
case 23: //Blacksmithing
{
Plr->Gossip_SendPOI(-4796.97, -1110.17, 6, 6, 0, "The Great Forge");
SendQuickMenu(2795);
}break;
case 24: //Cooking
{
Plr->Gossip_SendPOI(-4767.83, -1184.59, 6, 6, 0, "The Bronze Kettle");
SendQuickMenu(2796);
}break;
case 25: //Enchanting
{
Plr->Gossip_SendPOI(-4803.72, -1196.53, 6, 6, 0, "Thistlefuzz Arcanery");
SendQuickMenu(2797);
}break;
case 26: //Engineering
{
Plr->Gossip_SendPOI(-4799.56, -1250.23, 6, 6, 0, "Springspindle's Gadgets");
SendQuickMenu(2798);
}break;
case 27: //First Aid
{
Plr->Gossip_SendPOI(-4881.6, -1153.13, 6, 6, 0, "Ironforge Physician");
SendQuickMenu(2799);
}break;
case 28: //Fishing
{
Plr->Gossip_SendPOI(-4597.91, -1091.93, 6, 6, 0, "Traveling Fisherman");
SendQuickMenu(2800);
}break;
case 29: //Herbalism
{
Plr->Gossip_SendPOI(-4876.9, -1151.92, 6, 6, 0, "Ironforge Physician");
SendQuickMenu(2801);
}break;
case 30: //Inscription
{
Plr->Gossip_SendPOI(-4801.72, -1189.41, 6, 6, 0, "Ironforge Inscription");
SendQuickMenu(13884);
}break;
case 31: //Leatherworking
{
Plr->Gossip_SendPOI(-4745, -1027.57, 6, 6, 0, "Finespindle's Leather Goods");
SendQuickMenu(2802);
}break;
case 32: //Mining
{
Plr->Gossip_SendPOI(-4705.06, -1116.43, 6, 6, 0, "Deepmountain Mining Guild");
SendQuickMenu(2804);
}break;
case 33: //Skinning
{
Plr->Gossip_SendPOI(-4745, -1027.57, 6, 6, 0, "Finespindle's Leather Goods");
SendQuickMenu(2805);
}break;
case 34: //Tailoring
{
Plr->Gossip_SendPOI(-4719.60, -1056.96, 6, 6, 0, "Stonebrow's Clothier");
SendQuickMenu(2807);
}break;
case 35: //Lexicon of Power
{
Plr->Gossip_SendPOI(-4801.72, -1189.41, 6, 6, 0, "Ironforge Inscription");
SendQuickMenu(14174);
}break;
}
}
};
class KharanosGuard : public GossipScript
{
public:
void Destroy()
{
delete this;
}
void GossipHello(Object* pObject, Player * Plr, bool AutoSend)
{
GossipMenu *Menu;
objmgr.CreateGossipMenuForPlayer(&Menu, pObject->GetGUID(), 4287, Plr);
Menu->AddItem(0, "Bank", 1);
Menu->AddItem(0, "Gryphon Master", 2);
Menu->AddItem(0, "Guild Master", 3);
Menu->AddItem(0, "The Inn", 4);
Menu->AddItem(0, "Stable Master", 5);
Menu->AddItem(0, "Class Trainer", 6);
Menu->AddItem(0, "Profession Trainer", 7);
if(AutoSend)
Menu->SendTo(Plr);
}
void GossipSelectOption(Object* pObject, Player* Plr, uint32 Id, uint32 IntId, const char * Code)
{
GossipMenu * Menu;
switch(IntId)
{
case 0: // Return to start
GossipHello(pObject, Plr, true);
break;
//////////////////////
// Main menu handlers
/////
case 1: //Bank
SendQuickMenu(4288);
break;
case 2: //Gryphon Master
SendQuickMenu(4289);
break;
case 3: //Guild Master
SendQuickMenu(4290);
break;
case 4: //The Inn
SendQuickMenu(4291);
Plr->Gossip_SendPOI(-5582.66, -525.89, 6, 6, 0, "Thunderbrew Distillery");
break;
case 5: //Stable Master
SendQuickMenu(5985);
Plr->Gossip_SendPOI(-5604, -509.58, 6, 6, 0, "Shelby Stoneflint");
break;
case 6: //Class Trainer
{
objmgr.CreateGossipMenuForPlayer(&Menu, pObject->GetGUID(), 4292, Plr);
Menu->AddItem( 0, "Hunter" , 8);
Menu->AddItem( 0, "Mage" , 9);
Menu->AddItem( 0, "Paladin" ,10);
Menu->AddItem( 0, "Priest" , 11);
Menu->AddItem( 0, "Rogue" , 12);
Menu->AddItem( 0, "Warlock" , 13);
Menu->AddItem( 0, "Warrior" , 14);
Menu->SendTo(Plr);
}break;
case 7: // Profession Trainer
{
objmgr.CreateGossipMenuForPlayer(&Menu, pObject->GetGUID(), 4300, Plr);
Menu->AddItem( 0, "Alchemy" , 15);
Menu->AddItem( 0, "Blacksmithing" , 16);
Menu->AddItem( 0, "Cooking" , 17);
Menu->AddItem( 0, "Enchanting" , 18);
Menu->AddItem( 0, "Engineering" , 19);
Menu->AddItem( 0, "First Aid" , 20);
Menu->AddItem( 0, "Fishing" , 21);
Menu->AddItem( 0, "Herbalism" , 22);
if(Plr->GetSession()->GetClientBuild() > 8606) // Greater than 2.4.3
Menu->AddItem( 0, "Inscription" , 23);
Menu->AddItem( 0, "Leatherworking" , 24);
Menu->AddItem( 0, "Mining" , 25);
Menu->AddItem( 0, "Skinning" , 26);
Menu->AddItem( 0, "Tailoring" , 27);
Menu->SendTo(Plr);
}break;
////////////////
// Class trainer submenu
////////
case 8: //Hunter
{
Plr->Gossip_SendPOI(-5618.29, -454.25, 6, 6, 0, "Grif Wildheart");
SendQuickMenu(4293);
}break;
case 9: //Mage
{
Plr->Gossip_SendPOI(-5585.6, -539.99, 6, 6, 0, "Magis Sparkmantle");
SendQuickMenu(4294);
}break;
case 10: //Paladin
{
Plr->Gossip_SendPOI(-5585.6, -539.99, 6, 6, 0, "Azar Stronghammer");
SendQuickMenu(4295);
}break;
case 11: //Priest
{
Plr->Gossip_SendPOI(-5591.74, -525.61, 6, 6, 0, "Maxan Anvol");
SendQuickMenu(4296);
}break;
case 12: //Rogue
{
Plr->Gossip_SendPOI(-5602.75, -542.4, 6, 6, 0, "Hogral Bakkan");
SendQuickMenu(4297);
}break;
case 13: //Warlock
{
Plr->Gossip_SendPOI(-5641.97, -523.76, 6, 6, 0, "Gimrizz Shadowcog");
SendQuickMenu(4298);
}break;
case 14: //Warrior
{
Plr->Gossip_SendPOI(-5604.79, -529.38, 6, 6, 0, "Granis Swiftaxe");
SendQuickMenu(4299);
}break;
case 15: //Alchemy
{
SendQuickMenu(4301);
}break;
case 16: //Blacksmithing
{
Plr->Gossip_SendPOI(-5584.72, -428.41, 6, 6, 0, "Tognus Flintfire");
SendQuickMenu(4302);
}break;
case 17: //Cooking
{
Plr->Gossip_SendPOI(-5596.85, -541.43, 6, 6, 0, "Gremlock Pilsnor");
SendQuickMenu(4303);
}break;
case 18: //Enchanting
{
SendQuickMenu(4304);
}break;
case 19: //Engineering
{
SendQuickMenu(4305);
}break;
case 20: //First Aid
{
Plr->Gossip_SendPOI(-5603.67, -523.57, 6, 6, 0, "Thamner Pol");
SendQuickMenu(4306);
}break;
case 21: //Fishing
{
Plr->Gossip_SendPOI(-5202.39, -51.36, 6, 6, 0, "Paxton Ganter");
SendQuickMenu(4307);
}break;
case 22: //Herbalism
{
SendQuickMenu(4308);
}break;
case 23: //Inscription
{
Plr->Gossip_SendPOI(-4801.72, -1189.41, 6, 6, 0, "Ironforge Inscription");
SendQuickMenu(13884);
}break;
case 24: //Leatherworking
{
SendQuickMenu(4310);
}break;
case 25: //Mining
{
Plr->Gossip_SendPOI(-5531, -666.53, 6, 6, 0, "Yarr Hamerstone");
SendQuickMenu(4311);
}break;
case 26: //Skinning
{
SendQuickMenu(4312);
}break;
case 27: //Tailoring
{
SendQuickMenu(4313);
}break;
}
}
};
class FalconwingGuard : public GossipScript
{
public:
void Destroy()
{
delete this;
}
void GossipHello(Object* pObject, Player * Plr, bool AutoSend)
{
GossipMenu *Menu;
objmgr.CreateGossipMenuForPlayer(&Menu, pObject->GetGUID(), 2593, Plr);
Menu->AddItem(0, "Bat Handler", 1);
Menu->AddItem(0, "Guild Master", 2);
Menu->AddItem(0, "The Inn", 3);
Menu->AddItem(0, "Stable Master", 4);
Menu->AddItem(0, "Class Trainer", 5);
Menu->AddItem(0, "Profession Trainer", 6);
if(AutoSend)
Menu->SendTo(Plr);
}
void GossipSelectOption(Object* pObject, Player* Plr, uint32 Id, uint32 IntId, const char * Code)
{
GossipMenu * Menu;
switch(IntId)
{
case 0: // Return to start
GossipHello(pObject, Plr, true);
break;
//////////////////////
// Main menu handlers
/////
case 1: //Bat Handler
SendQuickMenu(2593);
Plr->Gossip_SendPOI(9376.4, -7164.92, 6, 6, 0, "Silvermoon City, Flight Master");
break;
case 2: //Guild Master
SendQuickMenu(2593);
break;
case 3: //The Inn
SendQuickMenu(2593);
Plr->Gossip_SendPOI(9476.916, -6859.2, 6, 6, 0, "Falconwing Square, Innkeeper");
break;
case 4: //Stable Master
SendQuickMenu(2593);
Plr->Gossip_SendPOI(9487.6, -6830.59, 6, 6, 0, "Falconwing Square, Stable Master");
break;
case 5: //Class Trainer
{
objmgr.CreateGossipMenuForPlayer(&Menu, pObject->GetGUID(), 4292, Plr);
Menu->AddItem( 0, "Druid" , 7);
Menu->AddItem( 0, "Hunter" , 8);
Menu->AddItem( 0, "Mage" , 9);
Menu->AddItem( 0, "Paladin" , 10);
Menu->AddItem( 0, "Priest" , 11);
Menu->AddItem( 0, "Rogue" , 12);
Menu->AddItem( 0, "Warlock" , 13);
Menu->SendTo(Plr);
}break;
case 6: // Profession Trainer
{
objmgr.CreateGossipMenuForPlayer(&Menu, pObject->GetGUID(), 2593, Plr);
Menu->AddItem( 0, "Alchemy" , 14);
Menu->AddItem( 0, "Blacksmithing" , 15);
Menu->AddItem( 0, "Cooking" , 16);
Menu->AddItem( 0, "Enchanting" , 17);
Menu->AddItem( 0, "Engineering" , 18);
Menu->AddItem( 0, "First Aid" , 19);
Menu->AddItem( 0, "Fishing" , 20);
Menu->AddItem( 0, "Herbalism" , 21);
Menu->AddItem( 0, "Jewelcrafting" , 22);
Menu->AddItem( 0, "Leatherworking" , 23);
Menu->AddItem( 0, "Mining" , 24);
Menu->AddItem( 0, "Skinning" , 25);
Menu->AddItem( 0, "Tailoring" , 26);
Menu->SendTo(Plr);
}break;
////////////////
// Class trainer submenu
////////
case 7: //Druid
{
SendQuickMenu(2593);
}break;
case 8: //Hunter
{
Plr->Gossip_SendPOI(9529.2, -6864.58, 6, 6, 0, "Falconwing Square, Hunter Trainer");
SendQuickMenu(2593);
}break;
case 9: //Mage
{
Plr->Gossip_SendPOI(9462.24, -6853.45, 6, 6, 0, "Falconwing Square, Mage Trainer");
SendQuickMenu(2593);
}break;
case 10: //Paladin <-- Needs to change flag to other sign (don't know how to describe it)
{
Plr->Gossip_SendPOI(9516.05, -6870.96, 6, 6, 0, "Falconwing Square, Paladin Trainer");
SendQuickMenu(2593);
}break;
case 11: //Priest
{
Plr->Gossip_SendPOI(9466.62, -6844.23, 6, 6, 0, "Falconwing Square, Priest Trainer");
SendQuickMenu(2593);
}break;
case 12: //Rogue
{
Plr->Gossip_SendPOI(9534.15, -6876.0, 6, 6, 0, "Falconwing Square, Rogue Trainer");
SendQuickMenu(2593);
}break;
case 13: //Warlock
{
Plr->Gossip_SendPOI(9467.63, -6862.82, 6, 6, 0, "Falconwing Square, Warlock Trainer");
SendQuickMenu(2593);
}break;
case 14: //Alchemy
{
Plr->Gossip_SendPOI(8661.36, -6367.0, 6, 6, 0, "Saltheril's Haven, Alchemist");
SendQuickMenu(2593);
}break;
case 15: //Blacksmithing
{
Plr->Gossip_SendPOI(8986.43, -7419.07, 6, 6, 0, "Farstrider Retreat, Blacksmith");
SendQuickMenu(2593);
}break;
case 16: //Cooking
{
Plr->Gossip_SendPOI(9494.86, -6879.45, 6, 6, 0, "Falconwing Square, Cook");
SendQuickMenu(2593);
}break;
case 17: //Enchanting
{
Plr->Gossip_SendPOI(8657.6, -6366.7, 6, 6, 0, "Saltheril's Haven, Enchanter");
SendQuickMenu(2593);
}break;
case 18: //Engineering
{
SendQuickMenu(2593);
}break;
case 19: //First Aid
{
Plr->Gossip_SendPOI(9479.53, -6880.07, 6, 6, 0, "Falconwing Square, First Aid");
SendQuickMenu(2593);
}break;
case 20: //Fishing
{
SendQuickMenu(2593);
}break;
case 21: //Herbalism
{
Plr->Gossip_SendPOI(8678.92, -6329.09, 6, 6, 0, "Saltheril's Haven, Herbalist");
SendQuickMenu(2593);
}break;
case 22: //Jewelcrafting
{
Plr->Gossip_SendPOI(9484.79, -6876.58, 6, 6, 0, "Falconwing Square, Jewelcrafter");
SendQuickMenu(2593);
}break;
case 23: //Leatherworking
{
Plr->Gossip_SendPOI(9363.75, -7130.75, 6, 6, 0, "Eversong Woods, Leatherworker");
SendQuickMenu(2593);
}break;
case 24: //Mining
{
SendQuickMenu(2593);
}break;
case 25: //Skinning
{
Plr->Gossip_SendPOI(9362.89, -7134.58, 6, 6, 0, "Eversong Woods, Skinner");
SendQuickMenu(2593);
}break;
case 26: //Tailoring
{
Plr->Gossip_SendPOI(8680.36, -6327.51, 6, 6, 0, "Saltheril's Haven, Tailor");
SendQuickMenu(2593);
}break;
}
}
};
class AzureWatchGuard : public GossipScript
{
public:
void Destroy()
{
delete this;
}
void GossipHello(Object* pObject, Player * Plr, bool AutoSend)
{
GossipMenu *Menu;
objmgr.CreateGossipMenuForPlayer(&Menu, pObject->GetGUID(), 10066, Plr);
Menu->AddItem(0, "Bank" , 1);
Menu->AddItem(0, "Hippogryph Master" , 2);
Menu->AddItem(0, "Guild Master" , 3);
Menu->AddItem(0, "Inn" , 4);
Menu->AddItem(0, "Stable" , 5);
Menu->AddItem(0, "Class Trainer" , 6);
Menu->AddItem(0, "Profession Trainer" , 7);
if(AutoSend)
Menu->SendTo(Plr);
}
void GossipSelectOption(Object* pObject, Player* Plr, uint32 Id, uint32 IntId, const char * Code)
{
GossipMenu * Menu;
switch(IntId)
{
case 0: // Return to start
GossipHello(pObject, Plr, true);
break;
//////////////////////
// Main menu handlers
/////
case 1: //Bank
SendQuickMenu(10067);
break;
case 2: //Hippogryph Master
SendQuickMenu(10071);
break;
case 3: //Guild Master
SendQuickMenu(10073);
break;
case 4: //Inn
SendQuickMenu(10074);
Plr->Gossip_SendPOI(-4127.81, -12467.7, 6, 6, 0, "Azure Watch, Innkeeper");
break;
case 5: //Stable Master
SendQuickMenu(10075);
Plr->Gossip_SendPOI(-4146.42, -12492.7, 6, 6, 0, "Azure Watch, Stable Master");
break;
case 6: //Class Trainer
{
objmgr.CreateGossipMenuForPlayer(&Menu, pObject->GetGUID(), 10076, Plr);
Menu->AddItem( 0, "Druid" , 8);
Menu->AddItem( 0, "Hunter" , 9);
Menu->AddItem( 0, "Mage" , 10);
Menu->AddItem( 0, "Paladin" , 11);
Menu->AddItem( 0, "Priest" , 12);
Menu->AddItem( 0, "Shaman" , 13);
Menu->AddItem( 0, "Warrior" , 14);
Menu->SendTo(Plr);
}break;
case 7: //Profession Trainer
{
objmgr.CreateGossipMenuForPlayer(&Menu, pObject->GetGUID(), 10087, Plr);
Menu->AddItem( 0, "Alchemy" , 15);
Menu->AddItem( 0, "Blacksmithing" , 16);
Menu->AddItem( 0, "Cooking" , 17);
Menu->AddItem( 0, "Enchanting" , 18);
Menu->AddItem( 0, "Engineering" , 19);
Menu->AddItem( 0, "First Aid" , 20);
Menu->AddItem( 0, "Fishing" , 21);
Menu->AddItem( 0, "Herbalism" , 22);
if(Plr->GetSession()->GetClientBuild() > 8606) // Greater than 2.4.3
Menu->AddItem( 0, "Inscription" , 23);
Menu->AddItem( 0, "Jewelcrafting" , 24);
Menu->AddItem( 0, "Leatherworking" , 25);
Menu->AddItem( 0, "Mining" , 26);
Menu->AddItem( 0, "Skinning" , 27);
Menu->AddItem( 0, "Tailoring" , 28);
Menu->SendTo(Plr);
}break;
////////////////
// Class trainer submenu
////////
case 8: //Druid
{
SendQuickMenu(10077);
}break;
case 9: //Hunter
{
Plr->Gossip_SendPOI(-4203.65, -12467.7, 6, 6, 0, "Azure Watch, Hunter Trainer");
SendQuickMenu(10078);
}break;
case 10: //Mage
{
Plr->Gossip_SendPOI(-4149.62, -12530.1, 6, 6, 0, "Azure Watch, Mage Trainer");
SendQuickMenu(10081);
}break;
case 11: //Paladin
{
Plr->Gossip_SendPOI(-4138.98, -12468.5, 6, 6, 0, "Azure Watch, Paladin Trainer");
SendQuickMenu(10083);
}break;
case 12: //Priest
{
Plr->Gossip_SendPOI(-4131.66, -12478.6, 6, 6, 0, "Azure Watch, Priest Trainer");
SendQuickMenu(10084);
}break;
case 13: //Shaman
{
Plr->Gossip_SendPOI(-4162.33, -12456.1, 6, 6, 0, "Azure Watch, Shaman Trainer");
SendQuickMenu(10085);
}break;
case 14: //Warrior
{
Plr->Gossip_SendPOI(-4165.05, -12536.4, 6, 6, 0, "Azure Watch, Warrior Trainer");
SendQuickMenu(10086);
}break;
case 15: //Alchemy
{
Plr->Gossip_SendPOI(-4191.15, -12470, 6, 6, 0, "Azure Watch, Alchemist");
SendQuickMenu(10088);
}break;
case 16: //Blacksmithing
{
Plr->Gossip_SendPOI(-4726.29, -12387.0, 6, 6, 0, "Odesyus' Landing, Blacksmith");
SendQuickMenu(10089);
}break;
case 17: //Cooking
{
Plr->Gossip_SendPOI(-4708.59, -12400.3, 6, 6, 0, "Odesyus' Landing, Cook");
SendQuickMenu(10090);
}break;
case 18: //Enchanting
{
SendQuickMenu(10091);
}break;
case 19: //Engineering
{
Plr->Gossip_SendPOI(-4157.57, -12470.2, 6, 6, 0, "Azure Watch, Engineering Trainer");
SendQuickMenu(10092);
}break;
case 20: //First Aid
{
Plr->Gossip_SendPOI(-4199.1, -12469.9, 6, 6, 0, "Azure Watch, First Aid Trainer");
SendQuickMenu(10093);
}break;
case 21: //Fishing
{
Plr->Gossip_SendPOI(-4266.34, -12985.4, 6, 6, 0, "Ammen Ford, Fisherwoman");
SendQuickMenu(10094);
}break;
case 22: //Herbalism
{
Plr->Gossip_SendPOI(-4189.43, -12459.4, 6, 6, 0, "Azure Watch, Herbalist");
SendQuickMenu(10095);
}break;
case 23: //Inscription
{
Plr->Gossip_SendPOI(-3889.3, -11495, 6, 6, 0, "Exodar, Inscription");
SendQuickMenu(13887);
}break;
case 24: //Jewelcrafting
{
SendQuickMenu(10100);
}break;
case 25: //Leatherworking
{
Plr->Gossip_SendPOI(-3442.68, -12322.2, 6, 6, 0, "Stillpine Hold, Leatherworker");
SendQuickMenu(10096);
}break;
case 26: //Mining
{
Plr->Gossip_SendPOI(-4179.89, -12493.1, 6, 6, 0, "Azure Watch, Mining Trainer");
SendQuickMenu(10097);
}break;
case 27: //Skinning
{
Plr->Gossip_SendPOI(-3431.17, -12316.5, 6, 6, 0, "Stillpine Hold, Skinner");
SendQuickMenu(10098);
}break;
case 28: //Tailoring
{
Plr->Gossip_SendPOI(-4711.54, -12386.7, 6, 6, 0, "Odesyus' Landing, Tailor");
SendQuickMenu(10099);
}break;
}
}
};
/*****************************************************************************************/
/* Shattrath Guards original structure by AeThIs. Translated, updated and by Pepsi1x1 */
/*****************************************************************************************/
class ShattrathGuard : public GossipScript
{
public:
void Destroy()
{
delete this;
}
void GossipHello(Object* pObject, Player * Plr, bool AutoSend)
{
GossipMenu *Menu;
objmgr.CreateGossipMenuForPlayer(&Menu, pObject->GetGUID(), 10524, Plr);
Menu->AddItem(0, "World's End Tavern", 1);
Menu->AddItem(0, "Bank", 2);
Menu->AddItem(0, "Inn", 3);
Menu->AddItem(0, "Flight Master", 4);
Menu->AddItem(0, "Mailbox", 5);
Menu->AddItem(0, "Stable Master", 6);
Menu->AddItem(0, "Battlemaster", 7);
Menu->AddItem(0, "Profession Trainer", 8);
Menu->AddItem(0, "Mana Loom", 9);
Menu->AddItem(0, "Alchemy Lab", 10);
Menu->AddItem(0, "Gem Merchant", 11);
if(AutoSend)
Menu->SendTo(Plr);
}
void GossipSelectOption(Object* pObject, Player* Plr, uint32 Id, uint32 IntId, const char * Code)
{
GossipMenu * Menu;
switch(IntId)
{
case 0: // Return to start
GossipHello(pObject, Plr, true);
break;
//////////////////////
// Menus
/////
case 1: // World's End Tavern
SendQuickMenu(10394);
Plr->Gossip_SendPOI(-1760.4, 5166.9, 6, 6, 0, "World's End Tavern");
break;
case 2: // Shattrath Banks
{
objmgr.CreateGossipMenuForPlayer(&Menu, pObject->GetGUID(), 10395, Plr);
Menu->AddItem( 0, "Aldor Bank" , 12);
Menu->AddItem( 0, "Scryers Bank" , 13);
Menu->SendTo(Plr);
}break;
case 3: // Inn's
{
objmgr.CreateGossipMenuForPlayer(&Menu, pObject->GetGUID(), 10398, Plr);
Menu->AddItem( 0, "Aldor inn" , 14);
Menu->AddItem( 0, "Scryers inn" , 15);
Menu->SendTo(Plr);
}break;
case 4: // Gryphon Master
SendQuickMenu(10402);
Plr->Gossip_SendPOI(-1831.9, 5298.2, 6, 6, 0, "Gryphon Master");
break;
case 5: // Mailboxes
{
objmgr.CreateGossipMenuForPlayer(&Menu, pObject->GetGUID(), 10403, Plr);
Menu->AddItem( 0, "Aldor inn" , 16);
Menu->AddItem( 0, "Scryers inn" , 17);
Menu->AddItem( 0, "Aldor Bank" , 18);
Menu->AddItem( 0, "Scryers Bank" , 19);
Menu->SendTo(Plr);
}break;
case 6: // Stable Masters
{
objmgr.CreateGossipMenuForPlayer(&Menu, pObject->GetGUID(), 10404, Plr);
Menu->AddItem( 0, "Aldor Stable" , 20);
Menu->AddItem( 0, "Scryers Stable" , 21);
Menu->SendTo(Plr);
}break;
case 7: // Battlemasters
{
objmgr.CreateGossipMenuForPlayer(&Menu, pObject->GetGUID(), 10405, Plr);
Menu->AddItem( 0, "Alliance Battlemasters" , 22);
Menu->AddItem( 0, "Horde & Arena Battlemasters" , 23);
Menu->SendTo(Plr);
}break;
case 8: // Proffesion Trainers
{
objmgr.CreateGossipMenuForPlayer(&Menu, pObject->GetGUID(), 10391, Plr);
Menu->AddItem( 0, "Alchemy" , 24);
Menu->AddItem( 0, "Blacksmithing" , 25);
Menu->AddItem( 0, "Cooking" , 26);
Menu->AddItem( 0, "Enchanting" , 27);
Menu->AddItem( 0, "First Aid" , 28);
Menu->AddItem( 0, "Jewelcrafting" , 29);
Menu->AddItem( 0, "Leatherworking" , 30);
Menu->AddItem( 0, "Skinning" , 31);
Menu->SendTo(Plr);
}break;
case 9: // Mana Loom
SendQuickMenu(10408);
Plr->Gossip_SendPOI(-2073.9, 5265.7, 6, 6, 0, "Mana Loom");
break;
case 10: // Alchemy Lab
SendQuickMenu(10409);
Plr->Gossip_SendPOI(-1648.1, 5537.3, 6, 6, 0, "Alchemy Lab");
break;
case 11: // Gem Merchants
{
objmgr.CreateGossipMenuForPlayer(&Menu, pObject->GetGUID(), 10410, Plr);
Menu->AddItem( 0, "Aldor Gem Merchant" , 32);
Menu->AddItem( 0, "Scryer Gem Merchant" , 33);
Menu->SendTo(Plr);
}break;
//////////////////////
// Banks
/////
case 12: //Aldor Bank
{
Plr->Gossip_SendPOI(-1730.8, 5496.2, 6, 6, 0, "Aldor Bank");
SendQuickMenu(10396);
}break;
case 13: //Scryers Bank
{
Plr->Gossip_SendPOI(-1999.6, 5362.0, 6, 6, 0, "Scryers Bank");
SendQuickMenu(10397);
}break;
//////////////////////
// Inns
/////
case 14: //Aldor Inn
{
Plr->Gossip_SendPOI(-1897.5, 5767.6, 6, 6, 0, "Aldor inn");
SendQuickMenu(10399);
}break;
case 15: //Scryers Inn
{
Plr->Gossip_SendPOI(-2180.6, 5403.9, 6, 6, 0, "Scryers inn");
SendQuickMenu(10401);
}break;
//////////////////////
// Mailboxes
/////
case 16: //Aldor Inn
{
Plr->Gossip_SendPOI(-1886.9, 5761.5, 6, 6, 0, "Aldor Inn");
SendQuickMenu(10399);
}break;
case 17: //Scryers Bank
{
Plr->Gossip_SendPOI(-2175.0, 5411.7, 6, 6, 0, "Scryers Bank");
SendQuickMenu(10397);
}break;
case 18: //Aldor Bank
{
Plr->Gossip_SendPOI(-1695.5, 5521.8, 6, 6, 0, "Aldor Bank");
SendQuickMenu(10396);
}break;
case 19: //Scryers Inn
{
Plr->Gossip_SendPOI(-2033.0, 5336.1, 6, 6, 0, "Scryers Inn");
SendQuickMenu(10401);
}break;
//////////////////////
// Stable Masters
/////
case 20: //Aldor Stable Master
{
Plr->Gossip_SendPOI(-1889.6, 5761.5, 6, 6, 0, "Aldor Stable");
SendQuickMenu(10399);
}break;
case 21: //Scryers Stable Master
{
Plr->Gossip_SendPOI(-2170.0, 5404.6, 6, 6, 0, "Scryers Stable");
SendQuickMenu(10401);
}break;
//////////////////////
// Battlemasters
/////
case 22: //Alliance Battlemaster
{
Plr->Gossip_SendPOI(-1831.9, 5298.2, 6, 6, 0, "Alliance Battlemasters");
SendQuickMenu(10406);
}break;
case 23: //Horde Battle Master and Arena Battle Master
{
Plr->Gossip_SendPOI(-1968.7, 5262.2, 6, 6, 0, "Horde & Arena Battlemasters");
SendQuickMenu(10407);
}break;
//////////////////////
// Profession Trainers
/////
case 24: //Alchemy
{
Plr->Gossip_SendPOI(-1661.0, 5538, 6, 6, 0, "Alchemy Trainer");
SendQuickMenu(10413);
}break;
case 25: //Blacksmithing
{
Plr->Gossip_SendPOI(-1847.7, 5230.3, 6, 6, 0, "Blacksmithing Trainer");
SendQuickMenu(10400);
}break;
case 26: //Cooking
{
Plr->Gossip_SendPOI(-2067.4, 5316.5, 6, 6, 0, "Cooking Trainer");
SendQuickMenu(10414);
}break;
case 27: //Enchanting
{
Plr->Gossip_SendPOI(-2278.5, 5567.7, 6, 6, 0, "Enchanting Trainer");
SendQuickMenu(10415);
}break;
case 28: //First Aid
{
Plr->Gossip_SendPOI(-1592.0, 5263.7, 6, 6, 0, "First Aid Trainer");
SendQuickMenu(10416);
}break;
case 29: //Jewelcrafting
{
Plr->Gossip_SendPOI(-1653.3, 5665.1, 6, 6, 0, "Jewelcrafting Trainer");
SendQuickMenu(10417);
}break;
case 30: //Leatherworking
{
Plr->Gossip_SendPOI(-2060.9, 5256.6, 6, 6, 0, "Leatherworking Trainer");
SendQuickMenu(10418);
}break;
case 31: //Skinning
{
Plr->Gossip_SendPOI(-2047.9, 5299.6, 6, 6, 0, "Skinning Trainer");
SendQuickMenu(10419);
}break;
//////////////////////
// Gem Merchants
/////
case 32: //Aldor gem merchant
{
Plr->Gossip_SendPOI(-1649.3, 5668.6, 6, 6, 0, "Aldor gem merchant");
SendQuickMenu(10411);
}break;
case 33: //Scryers gem merchant
{
Plr->Gossip_SendPOI(-2193.9, 5422.1, 6, 6, 0, "Scryers gem merchant");
SendQuickMenu(10412);
}break;
}
}
};
void SetupGuardGossip(ScriptMgr * mgr)
{
GossipScript * gold = (GossipScript*) new GoldshireGuard();
GossipScript * sw = (GossipScript*) new StormwindGuard();
GossipScript * darn = (GossipScript*) new DarnassusGuard();
GossipScript * teldra = (GossipScript*) new TeldrassilGuard();
GossipScript * blood = (GossipScript*) new BloodhoofGuard();
GossipScript * razor = (GossipScript*) new RazorHillGuard();
GossipScript * brill = (GossipScript*) new BrillGuard();
GossipScript * irf = (GossipScript*) new IronforgeGuard();
GossipScript * khar = (GossipScript*) new KharanosGuard();
GossipScript * falcon = (GossipScript*) new FalconwingGuard();
GossipScript * azure = (AzureWatchGuard*) new AzureWatchGuard();
GossipScript * under = (GossipScript*) new UndercityGuard();
GossipScript * silver = (SilvermoonGuard*) new SilvermoonGuard();
GossipScript * exodar = (ExodarGuard*) new ExodarGuard();
GossipScript * ogri = (OrgrimmarGuard*) new OrgrimmarGuard();
GossipScript * thun = (ThunderbluffGuard*) new ThunderbluffGuard();
GossipScript * shattr = (ShattrathGuard*) new ShattrathGuard();
/* Guard List */
mgr->register_gossip_script(1423, gold); // Stormwind Guard
mgr->register_gossip_script(68, sw); // Stormwind City Guard
mgr->register_gossip_script(1976, sw); // Stormwind City Patroller
mgr->register_gossip_script(4262, darn); // Darnassus Sentinel
mgr->register_gossip_script(5624, under); // Undercity Guardian
mgr->register_gossip_script(3571, teldra); // Teldrassil Sentinel
mgr->register_gossip_script(16222, silver); // Silvermoon City Guardian
mgr->register_gossip_script(16733, exodar); // Exodar Peacekeeper
mgr->register_gossip_script(20674, exodar); // Shield of Velen
mgr->register_gossip_script(3296, ogri); // Orgrimmar Grunt
mgr->register_gossip_script(3084, thun); // Bluffwatcher
mgr->register_gossip_script(3222, blood); // Brave Wildrunner
mgr->register_gossip_script(3224, blood); // Brave Cloudmane
mgr->register_gossip_script(3220, blood); // Brave Darksky
mgr->register_gossip_script(3219, blood); // Brave Leaping Deer
mgr->register_gossip_script(3217, blood); // Brave Dawneagle
mgr->register_gossip_script(3215, blood); // Brave Strongbash
mgr->register_gossip_script(3218, blood); // Brave Swiftwind
mgr->register_gossip_script(3221, blood); // Brave Rockhorn
mgr->register_gossip_script(3223, blood); // Brave Rainchaser
mgr->register_gossip_script(3212, blood); // Brave Ironhorn
mgr->register_gossip_script(5953, razor); // Razor Hill Grunt
mgr->register_gossip_script(5725, brill); // Deathguard Lundmark
mgr->register_gossip_script(1738, brill); // Deathguard Terrence
mgr->register_gossip_script(1652, brill); // Deathguard Burgess
mgr->register_gossip_script(1746, brill); // Deathguard Cyrus
mgr->register_gossip_script(1745, brill); // Deathguard Morris
mgr->register_gossip_script(1743, brill); // Deathguard Lawrence
mgr->register_gossip_script(1744, brill); // Deathguard Mort
mgr->register_gossip_script(1496, brill); // Deathguard Dillinger
mgr->register_gossip_script(1742, brill); // Deathguard Bartholomew
mgr->register_gossip_script(5595, irf); // Ironforge Guard
mgr->register_gossip_script(727, khar); // Ironforge Mountaineer
mgr->register_gossip_script(16221,falcon); // Silvermoon Guardian
mgr->register_gossip_script(18038,azure); // Azuremyst Peacekeeper
mgr->register_gossip_script(19687,shattr); // Shattrath City Guard -by AeThIs
mgr->register_gossip_script(18568,shattr); // Shattrath City Guard Aruspice -by AeThIs
mgr->register_gossip_script(18549,shattr); // Shattrath City Guard -by AeThIs
}
// To Bloodhoof Guards - I don't know if those are all guards with dialog menu,
// but they were all I could find. Same to Deathguards.
// To do:
// - Add (eventually) missing guards which should use one of those guard menus.
// - Check all scripts + add guard text to DB and connect them with correct scripts.
| [
"[email protected]@3074cc92-8d2b-11dd-8ab4-67102e0efeef",
"[email protected]@3074cc92-8d2b-11dd-8ab4-67102e0efeef"
]
| [
[
[
1,
65
],
[
85,
112
],
[
119,
122
],
[
124,
127
],
[
129,
132
],
[
134,
137
],
[
140,
142
],
[
144,
147
],
[
149,
152
],
[
154,
157
],
[
159,
159
],
[
161,
163
],
[
181,
183
],
[
201,
207
],
[
209,
213
],
[
215,
219
],
[
221,
225
],
[
227,
231
],
[
233,
237
],
[
239,
243
],
[
245,
249
],
[
251,
255
],
[
257,
261
],
[
263,
267
],
[
269,
273
],
[
275,
279
],
[
281,
285
],
[
287,
291
],
[
293,
297
],
[
299,
303
],
[
305,
309
],
[
317,
321
],
[
323,
327
],
[
329,
333
],
[
335,
365
],
[
368,
451
],
[
457,
524
],
[
530,
530
],
[
532,
536
],
[
538,
542
],
[
544,
548
],
[
554,
571
],
[
573,
648
],
[
655,
691
],
[
693,
693
],
[
695,
754
],
[
762,
766
],
[
768,
771
],
[
773,
777
],
[
779,
1023
],
[
1025,
1102
],
[
1108,
1135
],
[
1137,
1179
],
[
1187,
1191
],
[
1193,
1197
],
[
1199,
1217
],
[
1232,
1250
],
[
1252,
1257
],
[
1259,
1263
],
[
1266,
1281
],
[
1283,
1286
],
[
1288,
1291
],
[
1293,
1296
],
[
1298,
1302
],
[
1304,
1324
],
[
1332,
1337
],
[
1339,
1343
],
[
1345,
1349
],
[
1351,
1353
],
[
1355,
1358
],
[
1360,
1365
],
[
1367,
1371
],
[
1373,
1377
],
[
1379,
1383
],
[
1385,
1389
],
[
1391,
1395
],
[
1397,
1401
],
[
1403,
1407
],
[
1409,
1413
],
[
1415,
1419
],
[
1421,
1431
],
[
1433,
1443
],
[
1445,
1449
],
[
1451,
1455
],
[
1457,
1461
],
[
1468,
1469
],
[
1471,
1475
],
[
1477,
1481
],
[
1483,
1487
],
[
1489,
1490
],
[
1492,
1493
],
[
1495,
1498
],
[
1504,
1517
],
[
1532,
1549
],
[
1551,
1554
],
[
1556,
1564
],
[
1566,
1569
],
[
1571,
1574
],
[
1576,
1579
],
[
1581,
1584
],
[
1586,
1590
],
[
1592,
1597
],
[
1599,
1610
],
[
1612,
1618
],
[
1627,
1636
],
[
1638,
1642
],
[
1644,
1648
],
[
1650,
1654
],
[
1656,
1660
],
[
1662,
1666
],
[
1668,
1678
],
[
1680,
1684
],
[
1686,
1690
],
[
1692,
1696
],
[
1698,
1702
],
[
1704,
1708
],
[
1710,
1714
],
[
1716,
1720
],
[
1722,
1723
],
[
1731,
1732
],
[
1734,
1735
],
[
1737,
1738
],
[
1740,
1741
],
[
1743,
1744
],
[
1746,
1747
],
[
1749,
1750
],
[
1752,
1753
],
[
1755,
1759
],
[
1761,
1762
],
[
1770,
2827
],
[
2844,
2906
],
[
2908,
2910
],
[
2917,
2918
],
[
2927,
2929
],
[
2931,
2932
],
[
2947,
2953
],
[
2955,
2959
],
[
2961,
2965
],
[
2967,
2971
],
[
2973,
2977
],
[
2979,
2983
],
[
2985,
2989
],
[
2991,
2995
],
[
2997,
2998
],
[
3000,
3001
],
[
3003,
3007
],
[
3009,
3013
],
[
3015,
3019
],
[
3021,
3025
],
[
3027,
3031
],
[
3033,
3037
],
[
3039,
3043
],
[
3045,
3049
],
[
3057,
3061
],
[
3063,
3067
],
[
3069,
3073
],
[
3075,
3078
],
[
3085,
3098
],
[
3100,
3169
],
[
3176,
3269
],
[
3277,
3280
],
[
3282,
3286
],
[
3288,
3291
],
[
3293,
3519
],
[
3528,
3545
],
[
3547,
3549
],
[
3551,
3553
],
[
3555,
3557
],
[
3559,
3562
],
[
3564,
3568
],
[
3573,
3581
],
[
3583,
3590
],
[
3598,
3607
],
[
3609,
3613
],
[
3615,
3619
],
[
3621,
3625
],
[
3627,
3631
],
[
3633,
3637
],
[
3639,
3643
],
[
3645,
3649
],
[
3651,
3655
],
[
3657,
3661
],
[
3663,
3666
],
[
3668,
3672
],
[
3674,
3678
],
[
3680,
3684
],
[
3686,
3690
],
[
3692,
3693
],
[
3695,
3695
],
[
3698,
3699
],
[
3706,
3707
],
[
3709,
3710
],
[
3712,
3713
],
[
3715,
3716
],
[
3718,
3719
],
[
3721,
3722
],
[
3724,
3725
],
[
3727,
4047
],
[
4049,
4063
],
[
4071,
4073
],
[
4075,
4085
],
[
4096,
4096
],
[
4102,
4109
]
],
[
[
66,
84
],
[
113,
118
],
[
123,
123
],
[
128,
128
],
[
133,
133
],
[
138,
139
],
[
143,
143
],
[
148,
148
],
[
153,
153
],
[
158,
158
],
[
160,
160
],
[
164,
180
],
[
184,
200
],
[
208,
208
],
[
214,
214
],
[
220,
220
],
[
226,
226
],
[
232,
232
],
[
238,
238
],
[
244,
244
],
[
250,
250
],
[
256,
256
],
[
262,
262
],
[
268,
268
],
[
274,
274
],
[
280,
280
],
[
286,
286
],
[
292,
292
],
[
298,
298
],
[
304,
304
],
[
310,
316
],
[
322,
322
],
[
328,
328
],
[
334,
334
],
[
366,
367
],
[
452,
456
],
[
525,
529
],
[
531,
531
],
[
537,
537
],
[
543,
543
],
[
549,
553
],
[
572,
572
],
[
649,
654
],
[
692,
692
],
[
694,
694
],
[
755,
761
],
[
767,
767
],
[
772,
772
],
[
778,
778
],
[
1024,
1024
],
[
1103,
1107
],
[
1136,
1136
],
[
1180,
1186
],
[
1192,
1192
],
[
1198,
1198
],
[
1218,
1231
],
[
1251,
1251
],
[
1258,
1258
],
[
1264,
1265
],
[
1282,
1282
],
[
1287,
1287
],
[
1292,
1292
],
[
1297,
1297
],
[
1303,
1303
],
[
1325,
1331
],
[
1338,
1338
],
[
1344,
1344
],
[
1350,
1350
],
[
1354,
1354
],
[
1359,
1359
],
[
1366,
1366
],
[
1372,
1372
],
[
1378,
1378
],
[
1384,
1384
],
[
1390,
1390
],
[
1396,
1396
],
[
1402,
1402
],
[
1408,
1408
],
[
1414,
1414
],
[
1420,
1420
],
[
1432,
1432
],
[
1444,
1444
],
[
1450,
1450
],
[
1456,
1456
],
[
1462,
1467
],
[
1470,
1470
],
[
1476,
1476
],
[
1482,
1482
],
[
1488,
1488
],
[
1491,
1491
],
[
1494,
1494
],
[
1499,
1503
],
[
1518,
1531
],
[
1550,
1550
],
[
1555,
1555
],
[
1565,
1565
],
[
1570,
1570
],
[
1575,
1575
],
[
1580,
1580
],
[
1585,
1585
],
[
1591,
1591
],
[
1598,
1598
],
[
1611,
1611
],
[
1619,
1626
],
[
1637,
1637
],
[
1643,
1643
],
[
1649,
1649
],
[
1655,
1655
],
[
1661,
1661
],
[
1667,
1667
],
[
1679,
1679
],
[
1685,
1685
],
[
1691,
1691
],
[
1697,
1697
],
[
1703,
1703
],
[
1709,
1709
],
[
1715,
1715
],
[
1721,
1721
],
[
1724,
1730
],
[
1733,
1733
],
[
1736,
1736
],
[
1739,
1739
],
[
1742,
1742
],
[
1745,
1745
],
[
1748,
1748
],
[
1751,
1751
],
[
1754,
1754
],
[
1760,
1760
],
[
1763,
1769
],
[
2828,
2843
],
[
2907,
2907
],
[
2911,
2916
],
[
2919,
2926
],
[
2930,
2930
],
[
2933,
2946
],
[
2954,
2954
],
[
2960,
2960
],
[
2966,
2966
],
[
2972,
2972
],
[
2978,
2978
],
[
2984,
2984
],
[
2990,
2990
],
[
2996,
2996
],
[
2999,
2999
],
[
3002,
3002
],
[
3008,
3008
],
[
3014,
3014
],
[
3020,
3020
],
[
3026,
3026
],
[
3032,
3032
],
[
3038,
3038
],
[
3044,
3044
],
[
3050,
3056
],
[
3062,
3062
],
[
3068,
3068
],
[
3074,
3074
],
[
3079,
3084
],
[
3099,
3099
],
[
3170,
3175
],
[
3270,
3276
],
[
3281,
3281
],
[
3287,
3287
],
[
3292,
3292
],
[
3520,
3527
],
[
3546,
3546
],
[
3550,
3550
],
[
3554,
3554
],
[
3558,
3558
],
[
3563,
3563
],
[
3569,
3572
],
[
3582,
3582
],
[
3591,
3597
],
[
3608,
3608
],
[
3614,
3614
],
[
3620,
3620
],
[
3626,
3626
],
[
3632,
3632
],
[
3638,
3638
],
[
3644,
3644
],
[
3650,
3650
],
[
3656,
3656
],
[
3662,
3662
],
[
3667,
3667
],
[
3673,
3673
],
[
3679,
3679
],
[
3685,
3685
],
[
3691,
3691
],
[
3694,
3694
],
[
3696,
3697
],
[
3700,
3705
],
[
3708,
3708
],
[
3711,
3711
],
[
3714,
3714
],
[
3717,
3717
],
[
3720,
3720
],
[
3723,
3723
],
[
3726,
3726
],
[
4048,
4048
],
[
4064,
4070
],
[
4074,
4074
],
[
4086,
4095
],
[
4097,
4101
]
]
]
|
2f65c9ed99e2c079ed910293d92b0c5092bd2706 | 5ac13fa1746046451f1989b5b8734f40d6445322 | /minimangalore/Nebula2/code/nebula2/src/gfx2/ngfxserver2_cmds.cc | f7379164c3df9ca3eaba7ca4f56b77a9cadfbf4a | []
| no_license | moltenguy1/minimangalore | 9f2edf7901e7392490cc22486a7cf13c1790008d | 4d849672a6f25d8e441245d374b6bde4b59cbd48 | refs/heads/master | 2020-04-23T08:57:16.492734 | 2009-08-01T09:13:33 | 2009-08-01T09:13:33 | 35,933,330 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 13,792 | cc | //------------------------------------------------------------------------------
// ngfxserver2_cmds.cc
// (C) 2002 RadonLabs GmbH
//------------------------------------------------------------------------------
#include "gfx2/ngfxserver2.h"
static void n_setdisplaymode(void* slf, nCmd* cmd);
static void n_getdisplaymode(void* slf, nCmd* cmd);
static void n_opendisplay(void* slf, nCmd* cmd);
static void n_closedisplay(void* slf, nCmd* cmd);
static void n_getfeatureset(void* slf, nCmd* cmd);
static void n_savescreenshot(void* slf, nCmd* cmd);
static void n_setscissorrect(void* slf, nCmd* cmd);
static void n_getscissorrect(void* slf, nCmd* cmd);
static void n_setcursorvisibility(void* slf, nCmd* cmd);
static void n_setmousecursor(void* slf, nCmd* cmd);
static void n_seticon(void* slf, nCmd* cmd);
static void n_setgamma(void* slf, nCmd* cmd);
static void n_getgamma(void* slf, nCmd* cmd);
static void n_setbrightness(void* slf, nCmd* cmd);
static void n_getbrightness(void* slf, nCmd* cmd);
static void n_setcontrast(void* slf, nCmd* cmd);
static void n_getcontrast(void* slf, nCmd* cmd);
static void n_adjustgamma(void* slf, nCmd* cmd);
static void n_restoregamma(void* slf, nCmd* cmd);
static void n_setskipmsgloop(void* slf, nCmd* cmd);
//------------------------------------------------------------------------------
/**
@scriptclass
ngfxserver2
@cppclass
nGfxServer2
@superclass
nroot
@classinfo
Generation 2 gfx server. Completely vertex/pixel shader based.
23-Aug-04 kims added setgamma, setbrightness, setcontrast, adjustgamma
and restoregamma command.
*/
void
n_initcmds(nClass* cl)
{
cl->BeginCmds();
cl->AddCmd("v_setdisplaymode_ssiiiib", 'SDMD', n_setdisplaymode);
cl->AddCmd("ssiiiib_getdisplaymode_v", 'GDMD', n_getdisplaymode);
cl->AddCmd("b_opendisplay_v", 'ODSP', n_opendisplay);
cl->AddCmd("v_closedisplay_v", 'CDSP', n_closedisplay);
cl->AddCmd("s_getfeatureset_v", 'GFTS', n_getfeatureset);
cl->AddCmd("v_savescreenshot_s", 'SSCS', n_savescreenshot);
cl->AddCmd("v_setscissorrect_ffff", 'SSCR', n_setscissorrect);
cl->AddCmd("ffff_getscissorrect_v", 'GSCR', n_getscissorrect);
cl->AddCmd("v_setcursorvisibility_s", 'SCVS', n_setcursorvisibility);
cl->AddCmd("v_setmousecursor_sii", 'SMCS', n_setmousecursor);
cl->AddCmd("v_seticon_s", 'SICO', n_seticon);
cl->AddCmd("v_setgamma_f", 'SETG', n_setgamma);
cl->AddCmd("f_getgamma_v", 'GETG', n_getgamma);
cl->AddCmd("v_setbrightness_f", 'SETB', n_setbrightness);
cl->AddCmd("f_getbrightness_v", 'GETB', n_getbrightness);
cl->AddCmd("v_setcontrast_f", 'SETC', n_setcontrast);
cl->AddCmd("f_getcontrast_v", 'GETC', n_getcontrast);
cl->AddCmd("v_adjustgamma_v", 'ADJG', n_adjustgamma);
cl->AddCmd("v_restoregamma_v", 'RESG', n_restoregamma);
cl->AddCmd("v_setskipmsgloop_b", 'SSML', n_setskipmsgloop);
cl->EndCmds();
}
//------------------------------------------------------------------------------
/**
@cmd
setdisplaymode
@input
s(WindowTitle), s(Type=windowed,fullscreen|alwaysontop), i(XPos), i(YPos), i(Width), i(Height), b(VSync)
@output
v
@info
Set a new display mode. This must happen outside opendisplay/closedisplay.
*/
static void
n_setdisplaymode(void* slf, nCmd* cmd)
{
nGfxServer2* self = (nGfxServer2*) slf;
const char* title = cmd->In()->GetS();
nDisplayMode2::Type type = nDisplayMode2::StringToType(cmd->In()->GetS());
int x = cmd->In()->GetI();
int y = cmd->In()->GetI();
int w = cmd->In()->GetI();
int h = cmd->In()->GetI();
bool vsync = cmd->In()->GetB();
self->SetDisplayMode(nDisplayMode2(title, type, x, y, w, h, vsync, true, "Icon")); // true - dialog box mode
}
//------------------------------------------------------------------------------
/**
@cmd
getdisplaymode
@input
v
@output
s(WindowTitle), s(Type=windowed,fullscreen|alwaysontop), i(XPos), i(YPos), i(Width), i(Height), b(VSync)
@info
Get the current display mode.
*/
static void
n_getdisplaymode(void* slf, nCmd* cmd)
{
nGfxServer2* self = (nGfxServer2*) slf;
const nDisplayMode2& mode = self->GetDisplayMode();
cmd->Out()->SetS(mode.GetWindowTitle().Get());
cmd->Out()->SetS(nDisplayMode2::TypeToString(mode.GetType()));
cmd->Out()->SetI(mode.GetXPos());
cmd->Out()->SetI(mode.GetYPos());
cmd->Out()->SetI(mode.GetWidth());
cmd->Out()->SetI(mode.GetHeight());
cmd->Out()->SetB(mode.GetVerticalSync());
}
//------------------------------------------------------------------------------
/**
@cmd
opendisplay
@input
v
@output
b(Success)
@info
Open the display.
*/
static void
n_opendisplay(void* slf, nCmd* cmd)
{
nGfxServer2* self = (nGfxServer2*) slf;
cmd->Out()->SetB(self->OpenDisplay());
}
//------------------------------------------------------------------------------
/**
@cmd
closedisplay
@input
v
@output
v
@info
Close the display.
*/
static void
n_closedisplay(void* slf, nCmd* /*cmd*/)
{
nGfxServer2* self = (nGfxServer2*) slf;
self->CloseDisplay();
}
//------------------------------------------------------------------------------
/**
@cmd
getfeatureset
@input
v
@output
s(FeatureSet = dx7, dx8, dx8sb, dx9, dx9flt, invalid)
@info
Get the feature set implemented by the graphics card.
*/
static void
n_getfeatureset(void* slf, nCmd* cmd)
{
nGfxServer2* self = (nGfxServer2*) slf;
nGfxServer2::FeatureSet feat = self->GetFeatureSet();
cmd->Out()->SetS(nGfxServer2::FeatureSetToString(feat));
}
//------------------------------------------------------------------------------
/**
@cmd
savescreenshot
@input
s(Filename)
@output
v
@info
Save a screenshot to the provided filename.
A JPG file will be created.
*/
static void
n_savescreenshot(void *slf, nCmd *cmd)
{
nGfxServer2 *self = (nGfxServer2*) slf;
self->SaveScreenshot(cmd->In()->GetS(), nTexture2::JPG);
}
//------------------------------------------------------------------------------
/**
@cmd
setcursorvisibility
@input
s('none', 'system', or 'custom')
@output
v
@info
Set whether no cursor, a standard or a custom mouse
cursor will be displayed.
*/
static void
n_setcursorvisibility(void *slf, nCmd *cmd)
{
nGfxServer2 *self = (nGfxServer2*) slf;
const char *str = cmd->In()->GetS();
nGfxServer2::CursorVisibility visibility;
if (0 == strcmp(str, "none")) visibility = nGfxServer2::None;
else if (0 == strcmp(str, "system")) visibility = nGfxServer2::System;
else if (0 == strcmp(str, "custom")) visibility = nGfxServer2::Custom;
else
{
n_error("setcursorvisibility: invalid string '%s'\n", str);
return;
}
self->SetCursorVisibility(visibility);
}
//------------------------------------------------------------------------------
/**
@cmd
setmousecursor
@input
s (texture resource name), ii (hotspot x, y)
@output
v
@info
Defines a custom mouse cursor.
*/
static void
n_setmousecursor(void *slf, nCmd *cmd)
{
nGfxServer2 *self = (nGfxServer2*) slf;
nMouseCursor cursor;
cursor.SetFilename(cmd->In()->GetS());
cursor.SetHotspotX(cmd->In()->GetI());
cursor.SetHotspotY(cmd->In()->GetI());
self->SetMouseCursor(cursor);
}
//------------------------------------------------------------------------------
/**
@cmd
seticon
@input
v
@output
s(icon resource name)
@info
Sets the window's icon.
This must happen outside opendisplay/closedisplay.
*/
static void
n_seticon(void* slf, nCmd* cmd)
{
nGfxServer2* self = (nGfxServer2*) slf;
nDisplayMode2 mode = self->GetDisplayMode();
mode.SetIcon(cmd->In()->GetS());
self->SetDisplayMode(mode);
}
//------------------------------------------------------------------------------
/**
@cmd
setscissorrect
@input
f(x0), f(y0), f(x1), f(y1)
@output
v
@info
Define the scissor rectangle (topleft is (0.0f, 0.0f), bottomright
is (1.0f, 1.0f)). Note that scissoring must be enabled externally
in a shader!
*/
static void
n_setscissorrect(void* slf, nCmd* cmd)
{
nGfxServer2* self = (nGfxServer2*) slf;
vector2 v0, v1;
v0.x = cmd->In()->GetF();
v0.y = cmd->In()->GetF();
v1.x = cmd->In()->GetF();
v1.y = cmd->In()->GetF();
self->SetScissorRect(rectangle(v0, v1));
}
//------------------------------------------------------------------------------
/**
@cmd
getscissorrect
@input
v
@output
f(x0), f(y0), f(x1), f(y1)
@info
Returns the current scissor rect.
*/
static void
n_getscissorrect(void* slf, nCmd* cmd)
{
nGfxServer2* self = (nGfxServer2*) slf;
const rectangle& r = self->GetScissorRect();
cmd->Out()->SetF(r.v0.x);
cmd->Out()->SetF(r.v0.y);
cmd->Out()->SetF(r.v1.x);
cmd->Out()->SetF(r.v1.y);
}
//------------------------------------------------------------------------------
/**
@cmd
setgamma
@input
f
@output
v
@info
Set gamma value (adjustgamma must be called for the change to take effect)
23-Aug-04 kims created
*/
static
void n_setgamma(void* slf, nCmd* cmd)
{
nGfxServer2* self = (nGfxServer2*) slf;
self->SetGamma(cmd->In()->GetF());
}
//------------------------------------------------------------------------------
/**
@cmd
getgamma
@input
v
@output
f
@info
Get current gamma value (reflects the last call to setgamma, which may not
correspond to the actual screen gamma if adjustgamma has not been called).
8-Sep-04 rafael created
*/
static
void n_getgamma(void* slf, nCmd* cmd)
{
nGfxServer2* self = (nGfxServer2*) slf;
cmd->Out()->SetF(self->GetGamma());
}
//------------------------------------------------------------------------------
/**
@cmd
setbrightness
@input
f
@output
v
@info
Set brightness value (adjustgamma must be called for the change to take effect)
23-Aug-04 kims created
*/
static
void n_setbrightness(void* slf, nCmd* cmd)
{
nGfxServer2* self = (nGfxServer2*) slf;
self->SetBrightness(cmd->In()->GetF());
}
//------------------------------------------------------------------------------
/**
@cmd
getbrightness
@input
v
@output
f
@info
Get current brightness (reflects last call to setbrightness, which may not
correspond to the actual screen brightness if adjustgamma has not been called).
8-Sep-04 rafael created
*/
static
void n_getbrightness(void* slf, nCmd* cmd)
{
nGfxServer2* self = (nGfxServer2*) slf;
cmd->Out()->SetF(self->GetBrightness());
}
//------------------------------------------------------------------------------
/**
@cmd
setcontrast
@input
f
@output
v
@info
Set contrast value (adjustgamma must be called for the change to take effect)
23-Aug-04 kims created
*/
static void
n_setcontrast(void* slf, nCmd* cmd)
{
nGfxServer2* self = (nGfxServer2*) slf;
self->SetContrast(cmd->In()->GetF());
}
//------------------------------------------------------------------------------
/**
@cmd
getcontrast
@input
v
@output
f
@info
Get current contrast (reflects last call to setcontrast, which may not
correspond to the actual screen contrast if adjustgamma has not been called).
8-Sep-04 rafael created
*/
static
void n_getcontrast(void* slf, nCmd* cmd)
{
nGfxServer2* self = (nGfxServer2*) slf;
cmd->Out()->SetF(self->GetContrast());
}
//------------------------------------------------------------------------------
/**
@cmd
adjustgamma
@input
v
@output
v
@info
Commits the last gamma, contrast, and brightness values set,
so that they are actually visible on the screen.
23-Aug-04 kims created
*/
static void
n_adjustgamma(void* slf, nCmd* /*cmd*/)
{
nGfxServer2* self = (nGfxServer2*) slf;
self->AdjustGamma();
}
//------------------------------------------------------------------------------
/**
@cmd
restoregamma
@input
v
@output
v
@info
Resets screen gamma to default values.
23-Aug-04 kims created
*/
static void
n_restoregamma(void* slf, nCmd* /*cmd*/)
{
nGfxServer2* self = (nGfxServer2*) slf;
self->RestoreGamma();
}
//------------------------------------------------------------------------------
/**
@cmd
setskipmsgloop
@input
b(SkipMsgLoop)
@output
v
@info
Set whether or not the window handler should skip its message loop. This
is required when embedding Nebula into an application that provides its
own event loop, such as using wxWidgets.
*/
static void
n_setskipmsgloop(void* slf, nCmd* cmd)
{
nGfxServer2* self = (nGfxServer2*) slf;
bool skipMsgLoop = cmd->In()->GetB();
self->SetSkipMsgLoop(skipMsgLoop);
}
| [
"BawooiT@d1c0eb94-fc07-11dd-a7be-4b3ef3b0700c"
]
| [
[
[
1,
500
]
]
]
|
1506704e03c37dbbb800313d913b8bbf6640abeb | 1e976ee65d326c2d9ed11c3235a9f4e2693557cf | /TrackListPane.cpp | dd5af08ad0c6146c42d93c10ab9aa3ffeda37d7a | []
| 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 | 10,186 | cpp | // /*
// *
// * 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
// *
// */
#include "stdafx.h"
#include "TrackListPane.h"
#include "resource.h"
#include "PrgAPI.h"
#include "SQLManager.h"
#include "ActionManager.h"
#include "StateManager.h"
//#include "StringSerializerHelper.h"
TrackListPane::TrackListPane():
m_bSyncWithPlayer(FALSE),
m_bSyncWithSectionChanger(TRUE),
m_poptionsMenu(NULL)
{
}
TrackListPane::~TrackListPane()
{
delete m_poptionsMenu;
}
BOOL TrackListPane::Init(HWND hwndParent)
{
if (m_enhTrackList.GetSafeHwnd())
return TRUE;
m_hwndParent = hwndParent;
CWnd* pParent = CWnd::FromHandle(m_hwndParent);
//=== Create the EnhTrackList Control & the TrackList
m_enhTrackList.Create(pParent, 7391);
//OnStateChanged(SM_CurrentSectionChanged);
return TRUE;
}
void TrackListPane::UnInit()
{
if (m_enhTrackList.GetSafeHwnd() == 0)
return;
Hide();
PrgAPI* pAPI = PRGAPI();
//pAPI->GetSkinManager()->UnRegisterSkinnable(*this);
//pAPI->GetTranslationManager()->UnRegisterTranslatable(*this);
//pAPI->GetStateManager()->UnRegisterStateChangeListener(*this);
}
BOOL TrackListPane::Show()
{
if (m_enhTrackList.GetSafeHwnd())
{
PRGAPI()->GetStateManager()->RegisterStateChangeListener(*this);
m_enhTrackList.ShowWindow(SW_SHOW);
OnStateChanged(SM_CurrentSectionChanged);
return TRUE;
}
return FALSE;
}
void TrackListPane::Hide()
{
if (m_enhTrackList.GetSafeHwnd())
{
PRGAPI()->GetStateManager()->UnRegisterStateChangeListener(*this);
m_enhTrackList.ShowWindow(SW_HIDE);
}
}
void TrackListPane::MovePane(INT x, INT y, INT cx, INT cy)
{
m_clientRC = CRect(x, y, x + cx, y + cy);
m_enhTrackList.MoveWindow(x, y, cx, cy);
}
LPCTSTR TrackListPane::GetTitle(UINT captionIndex)
{
PrgAPI* pAPI = PRGAPI();
switch (captionIndex % 2)
{
case 0:
return pAPI->GetString(IDS_TRACKLIST);
case 1:
_sntprintf(m_stringBuffer, 500, _T("%s: [F2]"), pAPI->GetString(IDS_FOCUS));
return m_stringBuffer;
}
return NULL;
}
BOOL TrackListPane::GetButtonInfo(PaneButtonInfo& bInfo, UINT idx)
{
bInfo = PaneButtonInfo();
bInfo.iconSize = 16;
PrgAPI* pAPI = PRGAPI();
switch (idx)
{
case CMD_Options:
bInfo.hIcon = pAPI->GetIcon(ICO_Options16);
break;
case CMD_Play:
bInfo.hIcon = pAPI->GetIcon(ICO_Play16);
bInfo.text = pAPI->GetString(IDS_PLAY);
break;
case CMD_Enqueue:
bInfo.hIcon = pAPI->GetIcon(ICO_Add16);
bInfo.text = pAPI->GetString(IDS_ENQUEUE);
break;
default:
return FALSE;
}
return TRUE;
}
BOOL TrackListPane::OnButton(UINT idx)
{
switch (idx)
{
case CMD_Play:
m_enhTrackList.PlayTracks();
break;
case CMD_Enqueue:
m_enhTrackList.EnqueueTracks();
break;
case CMD_ShowInfoIcons:
m_enhTrackList.GetMainTrackList().ShowInfoIcons(!m_enhTrackList.GetMainTrackList().IsShowInfoIconsEnabled());
m_enhTrackList.GetMainTrackList().Invalidate(FALSE);
break;
case CMD_SyncWithSectionChanger:
m_bSyncWithSectionChanger = !m_bSyncWithSectionChanger;
break;
case CMD_SyncWithPlayer:
m_bSyncWithPlayer = !m_bSyncWithPlayer;
break;
default:
ASSERT(0);
return FALSE;
}
return TRUE;
}
//=== From StateChangeListener
BOOL TrackListPane::OnStateChanged(UINT stateMessage)
{
if (m_bSyncWithSectionChanger == FALSE)
{
switch (stateMessage)
{
case SM_DatabaseUpdated:
case SM_CollectionManagerEvent:
case SM_CurrentSectionChanged:
case SM_LocateTrackRequest:
return FALSE;
}
}
if (m_bSyncWithPlayer == FALSE && stateMessage == SM_MediaChanged)
{
return FALSE;
}
return m_enhTrackList.OnStateChanged(stateMessage);
}
ITSMenu* TrackListPane::GetMenu(UINT idx)
{
if (idx == CMD_Options)
{
PrgAPI* pAPI = PRGAPI();
if (m_poptionsMenu == NULL)
m_poptionsMenu = pAPI->CreatePopupMenu();
if (m_poptionsMenu->GetInternalHandler() == NULL)
{
m_poptionsMenu->Create();
m_poptionsMenu->AppendMenu(ITSMenu::MIT_String, CMD_SyncWithPlayer, (LPTSTR)pAPI->GetString(IDS_SYNCWITHPLAYER));
m_poptionsMenu->AppendMenu(ITSMenu::MIT_String, CMD_SyncWithSectionChanger, (LPTSTR)pAPI->GetString(IDS_SYNCWITHSECTIONS));
m_poptionsMenu->AppendMenu(ITSMenu::MIT_Separator, NULL, NULL);
m_poptionsMenu->AppendMenu(ITSMenu::MIT_String, CMD_ShowInfoIcons, (LPTSTR)pAPI->GetString(IDS_SHOWINFOICONS));
};
m_poptionsMenu->CheckMenuItem(CMD_SyncWithPlayer, m_bSyncWithPlayer);
m_poptionsMenu->CheckMenuItem(CMD_SyncWithSectionChanger, m_bSyncWithSectionChanger);
m_poptionsMenu->CheckMenuItem(CMD_ShowInfoIcons, m_enhTrackList.GetMainTrackList().IsShowInfoIconsEnabled());
return m_poptionsMenu;
}
return NULL;
}
const LPCTSTR cTrackListPane_Header = _T("Header");
const LPCTSTR cTrackListPane_ShowInfoIcons = _T("ShowInfoIcons");
const LPCTSTR cTrackListPane_SyncWithPlayer = _T("SyncWithPlayer");
const LPCTSTR cTrackListPane_SyncWithSectionChanger = _T("SyncWithSectionChanger");
const LPCTSTR cTrackListPane_ColumnInfo = _T("ColumnInfo");
const LPCTSTR cTrackListPane_SortingCount = _T("SortingCount");
const LPCTSTR cTrackListPane_Sorting = _T("Sorting");
BOOL TrackListPane::LoadState(IPaneState& paneState)
{
LPCTSTR sValue = paneState.GetLPCTSTRSetting(cTrackListPane_Header);
if (_tcsicmp(sValue, TrackListPaneInfo.Name) != 0)
return FALSE;
CMainListCtrl& list = m_enhTrackList.GetMainTrackList();
INT value = paneState.GetIntSetting(cTrackListPane_ShowInfoIcons);
if (value != -1)
list.ShowInfoIcons(value != 0);
value = paneState.GetIntSetting(cTrackListPane_SyncWithPlayer);
if (value != -1)
m_bSyncWithPlayer = value != 0;
value = paneState.GetIntSetting(cTrackListPane_SyncWithSectionChanger);
if (value != -1)
m_bSyncWithSectionChanger = value != 0;
//=== Read Column Visibility / Width / Position Info
TCHAR bf[500];
CMainListCtrl::SColumnInfo* colInfo = list.GetColumnInfo();
for (INT i = CMainListCtrl::CL_First; i < CMainListCtrl::CL_Last; i++)
{
_sntprintf(bf, 500, _T("%s_%02d_vis"), cTrackListPane_ColumnInfo, i);
colInfo[i].bVisible = paneState.GetIntSetting(bf) > 0;
_sntprintf(bf, 500, _T("%s_%02d_order"), cTrackListPane_ColumnInfo, i);
value = paneState.GetIntSetting(bf);
if (value >= 0 && value < 100)
colInfo[i].iOrder = value;
_sntprintf(bf, 500, _T("%s_%02d_cx"), cTrackListPane_ColumnInfo, i);
value = paneState.GetIntSetting(bf);
if (value >= 0 && value < 10000)
colInfo[i].cx = value;
if (colInfo[i].cx < 1)
colInfo[i].cx = 1;
}
list.UpdateColumns();
//=== Read the sorting information
SortOptionCollection& soc = list.GetSortingInfo();
INT sortCount = paneState.GetIntSetting(cTrackListPane_SortingCount);
for (INT i = 0; i < sortCount; i++)
{
SortOption so(RSO_None, TRUE);
INT sortOption = 0;
_sntprintf(bf, 500, _T("%s_%02d_option"), cTrackListPane_Sorting, i);
value = paneState.GetIntSetting(bf);
if (value >= RSO_None && value < RSO_Last)
so.option = RecordSortOptionsEnum(value);
_sntprintf(bf, 500, _T("%s_%02d_asc"), cTrackListPane_Sorting, i);
so.ascending = paneState.GetIntSetting(bf) != 0;
soc.ApplySortOption(so);
}
if (sortCount > 0)
list.UpdateSorting();
return TRUE;
}
BOOL TrackListPane::SaveState(IPaneState& paneState)
{
paneState.SetLPCTSTRSetting(cTrackListPane_Header, TrackListPaneInfo.Name);
CMainListCtrl& list = m_enhTrackList.GetMainTrackList();
paneState.SetIntSetting(cTrackListPane_ShowInfoIcons, list.IsShowInfoIconsEnabled());
paneState.SetIntSetting(cTrackListPane_SyncWithPlayer, m_bSyncWithPlayer);
paneState.SetIntSetting(cTrackListPane_SyncWithSectionChanger, m_bSyncWithSectionChanger);
//=== Write Column Visibility / Width / Position Info
TCHAR bf[500];
CMainListCtrl::SColumnInfo* colInfo = list.GetColumnInfo();
for (int i = 0; i < CMainListCtrl::CL_Last; i++)
{
_sntprintf(bf, 500, _T("%s_%02d_vis"), cTrackListPane_ColumnInfo, i);
paneState.SetIntSetting(bf, colInfo[i].bVisible);
_sntprintf(bf, 500, _T("%s_%02d_order"), cTrackListPane_ColumnInfo, i);
paneState.SetIntSetting(bf, colInfo[i].iOrder);
_sntprintf(bf, 500, _T("%s_%02d_cx"), cTrackListPane_ColumnInfo, i);
paneState.SetIntSetting(bf, colInfo[i].cx);
}
//=== Write the sorting information
SortOptionCollection& soc = list.GetSortingInfo();
paneState.SetIntSetting(cTrackListPane_SortingCount, soc.GetSortOptionsCount());
for (UINT i =0; i< soc.GetSortOptionsCount(); i++)
{
SortOption so = soc.GetSortOption(i);
_sntprintf(bf, 500, _T("%s_%02d_option"), cTrackListPane_Sorting, i);
paneState.SetIntSetting(bf, so.option);
_sntprintf(bf, 500, _T("%s_%02d_asc"), cTrackListPane_Sorting, i);
paneState.SetIntSetting(bf, so.ascending);
}
return TRUE;
}
//void TrackListPane::SaveSettings()
//{
// FullTrackRecordSP rec;
// m_trackList.GetItem(rec, 0);
// UINT lastID = 0;
// if (rec.get())
// lastID = rec->track.ID;
// PRGAPI()->SetOption(OPT_TREE_LastSectionID, lastID);
//}
void TrackListPane::ApplyTranslation(ITranslation& translation)
{
//=== The menus are stored in MenuManager so they automatically reset
if (m_poptionsMenu != NULL)
m_poptionsMenu->Destroy();
}
| [
"outcast1000@dc1b949e-fa36-4f9e-8e5c-de004ec35678"
]
| [
[
[
1,
339
]
]
]
|
95b31481a03c963c4b27cb5cc20f22c4114cf3b9 | fcdddf0f27e52ece3f594c14fd47d1123f4ac863 | /TeCom/src/TdkLayout/Header Files/TdkLineWidthProperty.h | bf6ddd860f2b56acc02971e7db57b9803108c88a | []
| no_license | radtek/terra-printer | 32a2568b1e92cb5a0495c651d7048db6b2bbc8e5 | 959241e52562128d196ccb806b51fda17d7342ae | refs/heads/master | 2020-06-11T01:49:15.043478 | 2011-12-12T13:31:19 | 2011-12-12T13:31:19 | null | 0 | 0 | null | null | null | null | ISO-8859-2 | C++ | false | false | 2,010 | h | /******************************************************************************
* FUNCATE - GIS development team
*
* TerraLib Components - TeCOM
*
* @(#) TdkLineWidthProperty.h
*
*******************************************************************************
*
* $Rev$:
*
* $Author: rui.gregorio $:
*
* $Date: 2010/08/23 13:21:19 $:
*
******************************************************************************/
// Elaborated by Rui Mauricio Gregório
#ifndef __TDK_LINE_WIDTH_PROPERTY_H
#define __TDK_LINE_WIDTH_PROPERTY_H
#include <TdkAbstractProperty.h>
//! \class TdkLineWidthProperty
/*! Class to represent the rectangle border property
*/
class TdkLineWidthProperty : public TdkAbstractProperty
{
protected:
double _value; //!< rectangle border value
public :
//! \brief TdkLineWidthProperty
/*! Constructor
\param newVale new rectangle border value
*/
TdkLineWidthProperty(const double &newVal=0.0);
//! \brief ~TdkLineWidthProperty
/*! Destructor
*/
virtual ~TdkLineWidthProperty();
//! \brief setValue
/*! Method to set the new value to
rectangle border property
\param newVal new angle value
*/
virtual void setValue(const double &newVal);
//! \brief getValue
/*! Method to return the rectangle border value
\return returns the angle value
*/
virtual double getValue();
//! \brief getValue
/*! Method to return the rectangle border value
by reference
*/
virtual void getValue(double &value);
//! \brief operator
/*! Operator = overload
\param other other TdkLineWidthProperty object
\return returns the object with same values that old object
*/
TdkLineWidthProperty& operator=(const TdkLineWidthProperty &other);
//! \brief operator
/*! Operator = overload
\param other other TdkAbstractProperty object
\return returns the object with same values that old object
*/
TdkLineWidthProperty& operator=(const TdkAbstractProperty &other);
};
#endif
| [
"[email protected]@58180da6-ba8b-8960-36a5-00cc02a3ddec"
]
| [
[
[
1,
79
]
]
]
|
4bd246e9f15f4d7164acb64d1d94877bec0389b8 | da48afcbd478f79d70767170da625b5f206baf9a | /tbmessage/src5.75/WebSendDlg.cpp | 600885ff065174d1a7301f69ba0a307a6f62a87c | []
| no_license | haokeyy/fahister | 5ba50a99420dbaba2ad4e5ab5ee3ab0756563d04 | c71dc56a30b862cc4199126d78f928fce11b12e5 | refs/heads/master | 2021-01-10T19:09:22.227340 | 2010-05-06T13:17:35 | 2010-05-06T13:17:35 | null | 0 | 0 | null | null | null | null | GB18030 | C++ | false | false | 1,703 | cpp | // WebSendDlg.cpp : 实现文件
//
#include "stdafx.h"
#include "WebSendDlg.h"
// CWebSendDlg 对话框
IMPLEMENT_DYNAMIC(CWebSendDlg, CDialog)
CWebSendDlg::CWebSendDlg(CWnd* pParent /*=NULL*/)
: CDialog(CWebSendDlg::IDD, pParent)
{
}
CWebSendDlg::~CWebSendDlg()
{
}
void CWebSendDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
DDX_Control(pDX, IDC_RICHEDIT21, m_Message);
DDX_Control(pDX, IDC_RICHEDIT22, m_Message2);
}
BEGIN_MESSAGE_MAP(CWebSendDlg, CDialog)
ON_BN_CLICKED(IDC_BTN_COPY, &CWebSendDlg::OnBnClickedBtnCopy)
ON_BN_CLICKED(IDC_BTN_SETFONT, &CWebSendDlg::OnBnClickedBtnSetfont)
ON_BN_CLICKED(IDC_BUTTON3, &CWebSendDlg::OnBnClickedButton3)
END_MESSAGE_MAP()
// CWebSendDlg 消息处理程序
void CWebSendDlg::OnBnClickedBtnCopy()
{
m_Message.SetSel(0, -1);
m_Message.Copy();
}
void CWebSendDlg::OnBnClickedBtnSetfont()
{
CHARFORMAT cf;
DWORD d = m_Message.GetSelectionCharFormat(cf);
CFontDialog dlg(cf);
if (dlg.DoModal() == IDOK)
{
dlg.GetCharFormat(cf);
m_Message.SetSelectionCharFormat(cf);
}
}
static DWORD CALLBACK MyStreamOutCallback(DWORD dwCookie, LPBYTE pbBuff, LONG cb, LONG *pcb)
{
CString *buf = (CString*)dwCookie;
buf->Append((char*)pbBuff);
*pcb = cb;
return 0;
}
void CWebSendDlg::OnBnClickedButton3()
{
CString buf;
EDITSTREAM es;
es.dwCookie = (DWORD) &buf;
es.pfnCallback = MyStreamOutCallback;
m_Message.StreamOut(SF_RTF, es);
m_Message2.SetWindowText(buf);
//char buf[256];
//buf[0] = 255;
//
//m_Message.SetTextMode(TM_RICHTEXT);
//m_Message.GetLine(0,buf);
//MessageBox(buf);
}
| [
"[email protected]@d41c10be-1f87-11de-a78b-a7aca27b2395"
]
| [
[
[
1,
85
]
]
]
|
73ac01336e9dbbf84d4bce2305a950185c547fde | 91ac219c4cde8c08a6b23ac3d207c1b21124b627 | /common/mlc/ViterbiDecoder.h | 15859f83f2004914bf44cb54dbbb75d9021c819f | []
| no_license | DazDSP/hamdrm-dll | e41b78d5f5efb34f44eb3f0c366d7c1368acdbac | 287da5949fd927e1d3993706204fe4392c35b351 | refs/heads/master | 2023-04-03T16:21:12.206998 | 2008-01-05T19:48:59 | 2008-01-05T19:48:59 | 354,168,520 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 4,554 | h | /******************************************************************************\
* Technische Universitaet Darmstadt, Institut fuer Nachrichtentechnik
* Copyright (c) 2001
*
* Author(s):
* Volker Fischer
*
* Description:
*
*
******************************************************************************
*
* 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.,
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
\******************************************************************************/
#if !defined(VITERBI_DECODER_H__3B0BA660_CA63_4344_BB2B_23E7A0D31912__INCLUDED_)
#define VITERBI_DECODER_H__3B0BA660_CA63_4344_BB2B_23E7A0D31912__INCLUDED_
#include "../GlobalDefinitions.h"
#include "../tables/TableMLC.h"
#include "ConvEncoder.h"
#include "ChannelCode.h"
/* Definitions ****************************************************************/
/* Using max-log MAP decoder */
#undef USE_MAX_LOG_MAP
/* SIMD implementation is always fixed-point */
#define USE_SIMD
#undef USE_SIMD
/* Use MMX or SSE2 */
#define USE_MMX
#undef USE_MMX
#ifdef USE_SIMD
/* No MAP implementation for SIMD */
# undef USE_MAX_LOG_MAP
# ifndef USE_MMX
# define USE_SSE2
# endif
#endif
/* Data type for Viterbi metric */
#ifdef USE_SIMD
# define _VITMETRTYPE unsigned char
# define _DECISIONTYPE unsigned char
#else
# define _VITMETRTYPE float
# define _DECISIONTYPE _BINARY
#endif
/* We initialize each new block of data all branches-metrics with the following
value exept of the zero-state. This can be done since we actually KNOW that
the zero state MUST be the transmitted one. The initialization vaule should
be fairly high. But we have to be careful choosing this parameter. We
should not take the largest value possible of the data type of the metric
variable since in the Viterbi-routine we add something to this value and
in that case we would force an overrun! */
#ifdef USE_SIMD
# define MC_METRIC_INIT_VALUE ((_VITMETRTYPE) 60)
#else
# define MC_METRIC_INIT_VALUE ((_VITMETRTYPE) 1e10)
#endif
/* In case of MAP decoder, all metrics must be stored for the entire input
vector since we need them for the forward and backward direction */
#ifdef USE_MAX_LOG_MAP
# define METRICSET(a) matrMetricSet[a]
#else
# define METRICSET(a) vecrMetricSet
#endif
/* Classes ********************************************************************/
class CViterbiDecoder : public CChannelCode
{
public:
CViterbiDecoder();
virtual ~CViterbiDecoder() {}
_REAL Decode(CVector<CDistance>& vecNewDistance,
CVector<_BINARY>& vecbiOutputBits);
void Init(CParameter::ECodScheme eNewCodingScheme,
CParameter::EChanType eNewChannelType, int iN1, int iN2,
int iNewNumOutBitsPartA, int iNewNumOutBitsPartB,
int iPunctPatPartA, int iPunctPatPartB, int iLevel);
protected:
/* Two trellis data vectors are needed for current and old state */
_VITMETRTYPE vecTrelMetric1[MC_NUM_STATES];
_VITMETRTYPE vecTrelMetric2[MC_NUM_STATES];
#ifdef USE_MAX_LOG_MAP
CMatrix<_REAL> matrAlpha;
CMatrix<_REAL> matrMetricSet;
#else
_REAL vecrMetricSet[MC_NUM_OUTPUT_COMBINATIONS];
#endif
CVector<int> veciTablePuncPat;
int iNumOutBits;
int iNumOutBitsWithMemory;
CMatrix<_DECISIONTYPE> matdecDecisions;
#ifdef USE_SIMD
/* Fields for storing the reodered metrics for MMX trellis */
_VITMETRTYPE chMet1[MC_NUM_STATES / 2];
_VITMETRTYPE chMet2[MC_NUM_STATES / 2];
#ifdef USE_MMX
void TrellisUpdateMMX(
#endif
#ifdef USE_SSE2
void TrellisUpdateSSE2(
#endif
const _DECISIONTYPE* pCurDec,
const _VITMETRTYPE* pCurTrelMetric, const _VITMETRTYPE* pOldTrelMetric,
const _VITMETRTYPE* pchMet1, const _VITMETRTYPE* pchMet2);
#endif
};
#endif // !defined(VITERBI_DECODER_H__3B0BA660_CA63_4344_BB2B_23E7A0D31912__INCLUDED_)
| [
"[email protected]"
]
| [
[
[
1,
144
]
]
]
|
7e6e023300148acb19e2b59009a52cba49416ed4 | 764d9c91475147d6aeeb893f0685f8f4543b7db2 | /cpp/plugins/lastfmscrobbler/urlclient.cpp | 559fa943b77322e68b75258dd8e557d8a43ae44a | []
| no_license | mderezynski/rimokon | cdfb1303e5b8b9e18f41d9353b7b3011ff36e90f | efe783d05e2011b6be8a17e2ac33a4dfc0ada567 | refs/heads/master | 2016-09-05T16:52:15.934694 | 2010-12-18T21:23:11 | 2010-12-18T21:23:11 | 1,063,350 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,983 | cpp | // Copyright (C) 2008 Dirk Vanden Boer <[email protected]>
//
// 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#include "urlclient.h"
#include <curl/curl.h>
#include <assert.h>
#include <stdexcept>
using namespace std;
size_t receiveData(char* data, size_t size, size_t nmemb, string* pBuffer);
UrlClient::UrlClient()
{
initialize();
}
UrlClient::~UrlClient()
{
cleanup();
}
void UrlClient::initialize()
{
#ifdef WIN32
CURLcode rc = curl_global_init(CURL_GLOBAL_WIN32 | CURL_GLOBAL_ALL);
#else
CURLcode rc = curl_global_init(CURL_GLOBAL_ALL);
#endif
if (CURLE_OK != rc)
{
throw std::logic_error("Failed to initialize libcurl");
}
}
void UrlClient::cleanup()
{
curl_global_cleanup();
}
void UrlClient::get(const string& url, string& response)
{
CURL* curlHandle = curl_easy_init();
assert(curlHandle);
curl_easy_setopt(curlHandle, CURLOPT_URL, url.c_str());
curl_easy_setopt(curlHandle, CURLOPT_WRITEFUNCTION, receiveData);
curl_easy_setopt(curlHandle, CURLOPT_WRITEDATA, &response);
curl_easy_setopt(curlHandle, CURLOPT_FAILONERROR, 1);
curl_easy_setopt(curlHandle, CURLOPT_CONNECTTIMEOUT, 5);
curl_easy_setopt(curlHandle, CURLOPT_NOSIGNAL, 1);
CURLcode rc = curl_easy_perform(curlHandle);
curl_easy_cleanup(curlHandle);
if (CURLE_OK != rc)
{
throw std::logic_error("Failed to get " + url + ": " + curl_easy_strerror(rc));
}
}
void UrlClient::getBinary(const string& url, void* callback, void* parameter)
{
CURL* curlHandle = curl_easy_init();
assert(curlHandle);
curl_easy_setopt(curlHandle, CURLOPT_URL, url.c_str());
curl_easy_setopt(curlHandle, CURLOPT_WRITEFUNCTION, callback);
curl_easy_setopt(curlHandle, CURLOPT_WRITEDATA, parameter);
curl_easy_setopt(curlHandle, CURLOPT_FAILONERROR, 1);
curl_easy_setopt(curlHandle, CURLOPT_CONNECTTIMEOUT, 5);
curl_easy_setopt(curlHandle, CURLOPT_NOSIGNAL, 1);
CURLcode rc = curl_easy_perform(curlHandle);
curl_easy_cleanup(curlHandle);
if (CURLE_OK != rc)
{
throw std::logic_error("Failed to get " + url + ": " + curl_easy_strerror(rc));
}
}
void UrlClient::post(const string& url, const string& data, string& response)
{
CURL* curlHandle = curl_easy_init();
assert(curlHandle);
curl_easy_setopt(curlHandle, CURLOPT_POSTFIELDS, data.c_str());
curl_easy_setopt(curlHandle, CURLOPT_URL, url.c_str());
curl_easy_setopt(curlHandle, CURLOPT_WRITEFUNCTION, receiveData);
curl_easy_setopt(curlHandle, CURLOPT_WRITEDATA, &response);
curl_easy_setopt(curlHandle, CURLOPT_FAILONERROR, 1);
curl_easy_setopt(curlHandle, CURLOPT_CONNECTTIMEOUT, 5);
curl_easy_setopt(curlHandle, CURLOPT_NOSIGNAL, 1);
CURLcode rc = curl_easy_perform(curlHandle);
curl_easy_cleanup(curlHandle);
if(CURLE_OK != rc)
{
throw std::logic_error("Failed to post " + url + ": " + curl_easy_strerror(rc));
}
}
size_t receiveData(char* data, size_t size, size_t nmemb, string* pBuffer)
{
assert(pBuffer);
size_t dataSize = size * nmemb;
pBuffer->append(data, dataSize);
return dataSize;
}
| [
"[email protected]"
]
| [
[
[
1,
127
]
]
]
|
ff02356621ec740422e3df8aade16295e91d2efe | 7187367ac851bc306af5ae5333375a955596035f | /BarChart.cpp | fd62fbc913d2154f0cd473ccdd94c7c7dc476ff5 | []
| no_license | lucernae/smor2 | d325759aeac816e36bf2b49c5507d4e4c548536b | acec5c407137c2ff7c55e116fa5349f16bd7d127 | refs/heads/master | 2020-06-02T18:47:45.614042 | 2011-11-22T20:10:59 | 2011-11-22T20:10:59 | 32,124,179 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 6,212 | cpp | #include "BarChart.h"
#include "Graph.h"
using namespace Graph_lib;
BarChart::~BarChart(void)
{
removeAllShape();
}
// RMN some nasty and complicated init function, but i implement it as flexible as possible...
// time spent here : 4 hours
// and it takes my sleep time... lol... 3 hours spent wondering what to do with the shapes objects...
// oh man... and another hour to style the chart... and a couple of minute typing comment because i had
// nothing to do...
void BarChart::initChartValue(string legendH, string legendV, vector<string>* labels, vector<double>* src, Color color) {
//assign vars
_legend_h = legendH;
_legend_v = legendV;
_labels = labels;
_src = src;
// RMN initialize axis label
initAxisLabel(legendH,legendV,labels,src);
// RMN now we draw the value...
Shape * s;
int barLen=0;
int padding=5;
for(int i=0;i+page<src->size() && i<maxXLabel;i++)
{
if(maxValue!=0)
{
barLen=(int)(src->at(i+page)*height/maxValue);
//cout << "debug barlen " << i << "\n";
}
else
{
barLen=0;
}
if(barLen>0 && notchW>0)
{
//the bar
Point p(loc.x+i*notchW+padding,loc.y+height-barLen);
s=new Rectangle(p,notchW-2*padding,barLen);
s->set_fill_color(color);
s->set_color(color);
addShape(s);
//the value
stringstream ss; ss << (src->at(i+page));
addShape(
new Text(
Point(p.x, p.y - 5),
ss.str()
)
);
}
}
}
void BarChart::initPercentageChartValue(string legendH, string legendV,vector<string>* legendCategory,vector<string> * labels, vector<vector<double>>* src,vector<Color>* color)
{
// RMN initialize axis label
vector<double> dsrc;
dsrc.push_back(100);
initAxisLabel(legendH,legendV,labels,&dsrc);
// percentage the value...
vector<vector<double>> srcPercentage;
for(int i=0;i+page<src->size() && i<maxXLabel;i++)
{
double total=0;
int index=i+page;
for(int j=0;j<src->at(index).size();j++)
{
total+=src->at(index).at(j);
}
vector<double> percent;
// check to avoid division by zero
if(total!=0)
{
for(int j=0;j<src->at(index).size();j++)
{
percent.push_back(src->at(index).at(j)*100/total);
}
}
srcPercentage.push_back(percent);
}
Shape * s;
// RMN now we draw the value...
int barLen=0;
int padding=5;
for(int i=0;i+page<srcPercentage.size() && i<maxXLabel;i++)
{
int totalBar=0;
int index=i+page;
for(int j=0;j<srcPercentage.at(index).size();j++)
{
barLen=(int)(srcPercentage.at(index).at(j)*height/100);
if((int)barLen>0)
{
s=new Rectangle(Point(loc.x+i*notchW+padding,loc.y+height-totalBar-barLen),notchW-2*padding,barLen);
s->set_fill_color(color->at(j));
s->set_color(color->at(j));
addShape(s);
totalBar+=barLen;
}
}
}
// RMN add legend
int legendspace=20;
int legendmargin=70;
for(int i=0;i<color->size();i++)
{
s=new Rectangle(Point(loc.x,loc.y+height+legendmargin+legendspace*(i-1)),legendspace,legendspace);
s->set_fill_color(color->at(i));
addShape(s);
s=new Text(Point(loc.x+legendspace*2,loc.y+height+legendmargin+legendspace*i),legendCategory->at(i));
addShape(s);
}
}
void BarChart::addShape(Shape* s)
{
shapes.push_back(s);
own->attach(*s);
}
void BarChart::removeAllShape()
{
// RMN yeah... just delete everything....
if(shapes.size()>0)
{
for(int i=0;i<shapes.size();i++)
{
Shape* s=shapes[i];
own->detach(*s);
delete s;
}
shapes.clear();
}
}
void BarChart::initAxisLabel(string legendH, string legendV, vector<string>* labels, vector<double>* src)
{
//destroy previous attached shapes (if any)
removeAllShape();
//attach new shapes to the window ... (window an be referenced to own)
// RMN create a new object along the way and store its reference.
// You know, I cannot instantiate any local variable to use, because if I do that,
// the engine cannot draw the shapes. The engine can't draw the shapes because the
// object is gone... well, because it is local variable...
// So, instead making local variable like: Axis xAxis(...,...,...) , we had to use 'new'
// keywords and carefully deleted it, when it is not required anymore
Shape *s;
adjustPage(labels->size());
int minimalNotchW=12;
if(width/maxXLabel<minimalNotchW)
{
notchW=minimalNotchW;
}
else
{
notchW=width/maxXLabel;
}
// RMN x axis. The Axis is placed so it will become a widget box when it is drawn
s=new Axis(Axis::Orientation::x,Point(loc.x,loc.y+height),notchW*maxXLabel,maxXLabel,"");
s->set_color(Color::red);
addShape(s);
// RMN y axis. same here...
int yNotch=10; // Y not? Just kidding...
s=new Axis(Axis::Orientation::y,Point(loc.x,loc.y+height),height,yNotch,"");
s->set_color(Color::red);
addShape(s);
// RMN horizontal labels. We carefully take the size of the notch to match this size of labels
for(int i=0;i+page<labels->size() && i<maxXLabel;i++)
{
addShape(new Text(Point(loc.x+(i)*notchW,loc.y+height+15),labels->at(i+page)));
}
// RMN vertical labels. We also carefully take the size of the notch and its label to match src vector
maxValue=0;
for(int i=0;i<src->size();i++)
{
if(src->at(i)>maxValue)
{
maxValue=src->at(i);
}
}
notchH=height/yNotch;
notchHValue=maxValue/yNotch;
if(notchHValue==0)
{
notchHValue=10; // RMN set default value, in case src contains nothing
}
for(int i=0;i<=yNotch;i++)
{
stringstream stream;
stream<<notchHValue*i;
addShape(new Text(Point(loc.x-10*stream.str().size(),loc.y+height-i*notchH+10),stream.str()));
}
// RMN draw the legendH and legendV
addShape(new Text(Point(loc.x+width/2-legendH.size()*10/2,loc.y+height+50),legendH));
addShape(new Text(Point(loc.x-legendV.size()*30/2,loc.y+height/2),legendV));
}
void BarChart::nextPage()
{
page+=maxXLabel;
}
void BarChart::prevPage()
{
page-=maxXLabel;
}
void BarChart::adjustPage(int xAxisSize)
{
if(page>xAxisSize)
{
page=(page/xAxisSize)*xAxisSize;
}
else if(page==xAxisSize)
{
page-=maxXLabel;
}
else if(page<0)
{
page=0;
}
} | [
"[email protected]@ce1152ac-b3a1-b03a-0f24-ae7c1841c481",
"[email protected]@ce1152ac-b3a1-b03a-0f24-ae7c1841c481"
]
| [
[
[
1,
7
],
[
9,
10
],
[
17,
22
],
[
44,
46
],
[
50,
58
],
[
152,
152
],
[
154,
155
],
[
245,
245
]
],
[
[
8,
8
],
[
11,
16
],
[
23,
43
],
[
47,
49
],
[
59,
151
],
[
153,
153
],
[
156,
244
]
]
]
|
b05c16b56bf35c8e02a5187dc75684f1a5853ab5 | 58ef4939342d5253f6fcb372c56513055d589eb8 | /SimulateMessage/Client/source/SMS/inc/KCContactEntry.h | 59c623f286f305d36a804a88c37cfec43286af87 | []
| no_license | flaithbheartaigh/lemonplayer | 2d77869e4cf787acb0aef51341dc784b3cf626ba | ea22bc8679d4431460f714cd3476a32927c7080e | refs/heads/master | 2021-01-10T11:29:49.953139 | 2011-04-25T03:15:18 | 2011-04-25T03:15:18 | 50,263,327 | 0 | 0 | null | null | null | null | GB18030 | C++ | false | false | 1,359 | h | /*
============================================================================
Name : KCContactEntry.h
Author : zengcity
Version : 1.0
Copyright : sohu
Description : 联系人信息 主要数据传递 以后手机号处理应该还有控件,所以最好写成类,提供接口
============================================================================
*/
#ifndef KCCONTACTENTRY_H
#define KCCONTACTENTRY_H
// INCLUDES
#include <e32std.h>
#include <e32base.h>
// CLASS DECLARATION
/**
* CKCContactEntry
*
*/
class CKCContactEntry : public CBase
{
public:
// Constructors and destructor
/**
* Destructor.
*/
~CKCContactEntry();
/**
* Two-phased constructor.
*/
static CKCContactEntry* NewL();
/**
* Two-phased constructor.
*/
static CKCContactEntry* NewLC();
private:
/**
* Constructor for performing 1st stage construction
*/
CKCContactEntry();
/**
* EPOC default constructor for performing 2nd stage construction
*/
void ConstructL();
public:
void SetNameL(const TDesC& aName);
const TDesC& GetName() const {return *iName;};
void SetNumberL(const TDesC& aNumber);
const TDesC& GetNumber()const {return *iNumber;};
private:
HBufC* iName; //显示名字
HBufC* iNumber; //手机号
};
#endif // KCCONTACTENTRY_H
| [
"zengcity@415e30b0-1e86-11de-9c9a-2d325a3e6494"
]
| [
[
[
1,
69
]
]
]
|
c52383b0c9a67b068d69c37c841abd11155225fc | f5a3e2fcfe01bfe95d125a903c0af454c1b9cdd6 | /Library.h | 474e1f53f8655283031d2f16b225ffdf19c2e8ed | []
| no_license | congchenutd/congchenmywords | 11418c97d3d260d35766cdfbb9968a54f569fad7 | 29fd31f7e7a99b17fe789e9d97879728ea9dbb80 | refs/heads/master | 2021-01-02T09:08:59.667661 | 2011-02-21T02:05:05 | 2011-02-21T02:05:05 | 32,358,808 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,214 | h | #ifndef LIBRARY_H
#define LIBRARY_H
/*
* Some library related sql queries, uglily encapsulated
*/
#include <QStringList>
class QTextStream;
struct DictSetting;
namespace Library
{
bool openDB(const QString& name);
void createTables();
void addUser(const QString& name);
void delUser(const QString& name);
QString getDBFileName();
QStringList getDictList();
QStringList getUserList();
int getDictSize(const QString& dictName);
QString getChinese(const QString& dictName, const QString& english);
int getCredit (const QString& userName, const QString& english);
void setCredit(const QString& dictName, const QString& userName,
const QString& word, int credit);
int searchEnglish(const QString& dictName, const QString& english);
int getNextID(const QString& tableName);
void exportMp3(const QString& destDir, const QString& english);
void addDictToLibrary(const QString& dict);
void delDict(const QString& dict);
bool createDictTable(const QString& dict);
void addWord(const QString& dictName, const QString& word, const QString& phonetic,
const QString& explanation, const QString& note);
};
#endif | [
"congchenutd@33c296ca-c6a8-bfc7-d74f-b3a1fff04ced"
]
| [
[
[
1,
38
]
]
]
|
2597936cff2642266e598e25da9ea94e00908085 | 0f67f4b756d4618c470f9c940d5bb7b902c98585 | /UiModule/Inworld/View/MainPanelButton.h | 53b0ad498c8c124d9a74d17a2dfa5b61259c8436 | [
"LicenseRef-scancode-unknown-license-reference",
"Apache-2.0"
]
| permissive | jonnenauha/naali | 8dc7e5a9802f0206c97b067d8675f49e602f6488 | 50060338255e9e5f6427b2f57b93bb884954d14b | refs/heads/master | 2020-12-25T08:38:09.291039 | 2010-03-20T13:22:58 | 2010-03-20T13:22:58 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 902 | h | // For conditions of distribution and use, see copyright notice in license.txt
#ifndef incl_UiModule_MainPanelButton_h
#define incl_UiModule_MainPanelButton_h
#include <QPushButton>
namespace UiServices
{
class UiProxyWidget;
}
QT_BEGIN_NAMESPACE
class QWidget;
class QString;
QT_END_NAMESPACE
namespace CoreUi
{
class MainPanelButton : public QPushButton
{
Q_OBJECT
public:
MainPanelButton(QWidget *parent, UiServices::UiProxyWidget *widget, const QString &widget_name);
virtual ~MainPanelButton();
public slots:
void ToggleShow();
void ControlledWidgetHidden();
void ControlledWidgetFocusIn();
void ControlledWidgetFocusOut();
private:
QString widget_name_;
UiServices::UiProxyWidget *controlled_widget_;
};
}
#endif //incl_UiModule_MainPanelButton_h
| [
"jonnenau@5b2332b8-efa3-11de-8684-7d64432d61a3",
"jaakkoallander@5b2332b8-efa3-11de-8684-7d64432d61a3",
"Stinkfist0@5b2332b8-efa3-11de-8684-7d64432d61a3",
"[email protected]@5b2332b8-efa3-11de-8684-7d64432d61a3"
]
| [
[
[
1,
7
],
[
18,
20
],
[
23,
23
],
[
26,
27
],
[
38,
40
]
],
[
[
8,
12
],
[
21,
22
],
[
24,
25
],
[
28,
29
],
[
34,
37
]
],
[
[
13,
17
],
[
33,
33
]
],
[
[
30,
32
]
]
]
|
a5f6f9f2f58a5e85a23b317e7eb03f4e7c71a692 | 91b964984762870246a2a71cb32187eb9e85d74e | /SRC/OFFI SRC!/_Common/Campus.cpp | 19eec9e997255fc63f9c390b8aa34f363dc2e40c | []
| no_license | 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 | 7,130 | cpp | //
//////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "Campus.h"
#if __VER >= 15 // __CAMPUS
#ifdef __WORLDSERVER
#include "User.h"
extern CUserMng g_UserMng;
#endif // __WORLDSERVER
//////////////////////////////////////////////////////////////////////
// CCampusMember Construction/Destruction
//////////////////////////////////////////////////////////////////////
CCampusMember::CCampusMember()
: m_idPlayer( 0 ), m_nMemberLv( 0 )
{
}
CCampusMember::~CCampusMember()
{
}
void CCampusMember::Serialize( CAr & ar )
{
if( ar.IsStoring() )
ar << m_idPlayer << m_nMemberLv;
else
ar >> m_idPlayer >> m_nMemberLv;
}
//////////////////////////////////////////////////////////////////////
// CCampus Construction/Destruction
//////////////////////////////////////////////////////////////////////
CCampus::CCampus()
: m_idCampus( 0 ), m_idMaster( 0 )
{
}
CCampus::~CCampus()
{
Clear();
}
void CCampus::Clear()
{
for( MAP_CM::iterator it = m_mapCM.begin(); it != m_mapCM.end(); ++it )
SAFE_DELETE( it->second );
m_mapCM.clear();
}
void CCampus::Serialize( CAr & ar )
{
if( ar.IsStoring() )
{
ar << m_idCampus << m_idMaster << m_mapCM.size();
for( MAP_CM::iterator it = m_mapCM.begin(); it != m_mapCM.end(); ++it )
( it->second )->Serialize( ar );
}
else
{
Clear();
size_t nSize;
ar >> m_idCampus >> m_idMaster >> nSize;
int i; for( i = 0; i < (int)( nSize ); ++i )
{
CCampusMember* pMember = new CCampusMember;
pMember->Serialize( ar );
m_mapCM.insert( MAP_CM::value_type( pMember->GetPlayerId(), pMember ) );
}
}
}
BOOL CCampus::IsPupil( u_long idPlayer )
{
if( GetMemberLv( idPlayer ) == CAMPUS_PUPIL )
return TRUE;
return FALSE;
}
vector<u_long> CCampus::GetPupilPlayerId()
{
vector<u_long> vecPupil;
for( MAP_CM::iterator it = m_mapCM.begin(); it != m_mapCM.end(); ++it )
{
if( (it->second)->GetLevel() == CAMPUS_PUPIL )
vecPupil.push_back( (it->second)->GetPlayerId() );
}
return vecPupil;
}
int CCampus::GetPupilNum()
{
int nPupil = 0;
for( MAP_CM::iterator it = m_mapCM.begin(); it != m_mapCM.end(); ++it )
{
if( ( it->second )->GetLevel() == CAMPUS_PUPIL )
++nPupil;
}
return nPupil;
}
vector<u_long> CCampus::GetAllMemberPlayerId()
{
vector<u_long> vecMember;
for( MAP_CM::iterator it = m_mapCM.begin(); it != m_mapCM.end(); ++ it )
vecMember.push_back( (it->second)->GetPlayerId() );
return vecMember;
}
int CCampus::GetMemberLv( u_long idPlayer )
{
CCampusMember* pMember = GetMember( idPlayer );
if( pMember )
return pMember->GetLevel();
return 0;
}
BOOL CCampus::IsMember( u_long idPlayer )
{
CCampusMember* pCM = GetMember( idPlayer );
if( pCM )
return TRUE;
return FALSE;
}
BOOL CCampus::AddMember( CCampusMember* pMember )
{
if( GetMember( pMember->GetPlayerId() ) )
{
Error( "Pupil is already campus member - idCampus : %d, idPlayer : %d", GetCampusId(), pMember->GetPlayerId() );
return FALSE;
}
if( GetPupilNum() >= MAX_PUPIL_NUM )
{
Error( "Pupil is full - idCampus : %d", GetCampusId() );
return FALSE;
}
m_mapCM.insert( MAP_CM::value_type( pMember->GetPlayerId(), pMember ) );
return TRUE;
}
BOOL CCampus::RemoveMember( u_long idPlayer )
{
CCampusMember* pMember = GetMember( idPlayer );
if( pMember )
{
SAFE_DELETE( pMember );
m_mapCM.erase( idPlayer );
return TRUE;
}
Error( "Member not found - idCampus : %d, idPlayer : %d", GetCampusId(), idPlayer );
return FALSE;
}
CCampusMember* CCampus::GetMember( u_long idPlayer )
{
MAP_CM::iterator it = m_mapCM.find( idPlayer );
if( it != m_mapCM.end() )
return it->second;
return NULL;
}
#ifdef __WORLDSERVER
BOOL CCampus::IsChangeBuffLevel( u_long idPlayer )
{
if( IsMaster( idPlayer ) )
{
int nLevel = GetBuffLevel( idPlayer );
if( m_nPreBuffLevel != nLevel )
{
m_nPreBuffLevel = nLevel;
return TRUE;
}
}
return FALSE;
}
int CCampus::GetBuffLevel( u_long idPlayer )
{
int nLevel = 0;
if( IsMaster( idPlayer ) )
{
for( MAP_CM::iterator it = m_mapCM.begin(); it != m_mapCM.end(); ++it )
{
CUser* pPupil = g_UserMng.GetUserByPlayerID( ( it->second )->GetPlayerId() );
if( IsValidObj( pPupil ) && ( it->second )->GetLevel() == CAMPUS_PUPIL )
++nLevel;
}
}
else
{
CUser* pMaster = g_UserMng.GetUserByPlayerID( GetMaster() );
if( IsValidObj( pMaster ) )
++nLevel;
}
return nLevel;
}
#endif // __WORLDSERVER
//////////////////////////////////////////////////////////////////////
// CCampus Construction/Destruction
//////////////////////////////////////////////////////////////////////
CCampusMng::CCampusMng()
:m_idCampus( 0 )
{
}
CCampusMng::~CCampusMng()
{
Clear();
}
void CCampusMng::Clear()
{
for( MAP_CAMPUS::iterator it = m_mapCampus.begin(); it != m_mapCampus.end(); ++it )
SAFE_DELETE( it->second );
m_mapCampus.clear();
m_mapPid2Cid.clear();
}
void CCampusMng::Serialize( CAr & ar )
{
int i = 0;
if( ar.IsStoring() )
{
ar << m_idCampus << m_mapCampus.size();
for( MAP_CAMPUS::iterator it = m_mapCampus.begin(); it != m_mapCampus.end(); ++it )
( it->second )->Serialize( ar );
ar << m_mapPid2Cid.size();
for( MAP_PID2CID::iterator it2 = m_mapPid2Cid.begin(); it2 != m_mapPid2Cid.end(); ++it2 )
ar << it2->first << it2->second;
}
else
{
Clear();
size_t nSize;
ar >> m_idCampus >> nSize;
for( i = 0; i < (int)( nSize ); ++i )
{
CCampus* pCampus = new CCampus;
pCampus->Serialize( ar );
m_mapCampus.insert( MAP_CAMPUS::value_type( pCampus->GetCampusId(), pCampus ) );
}
ar >> nSize;
for( i = 0; i < (int)( nSize ); ++i )
{
u_long idPlayer, idCampus;
ar >> idPlayer >> idCampus;
AddPlayerId2CampusId( idPlayer, idCampus );
}
}
}
u_long CCampusMng::AddCampus( CCampus* pCampus )
{
m_idCampus = ( pCampus->GetCampusId() != 0? pCampus->GetCampusId(): m_idCampus + 1 );
if( GetCampus( m_idCampus ) )
return 0;
pCampus->SetCampusId( m_idCampus );
m_mapCampus.insert( MAP_CAMPUS::value_type( m_idCampus, pCampus ) );
return m_idCampus;
}
BOOL CCampusMng::RemoveCampus( u_long idCampus )
{
CCampus* pCampus = GetCampus( idCampus );
if( pCampus )
{
SAFE_DELETE( pCampus );
m_mapCampus.erase( idCampus );
return TRUE;
}
return FALSE;
}
CCampus* CCampusMng::GetCampus( u_long idCampus )
{
MAP_CAMPUS::iterator it = m_mapCampus.find( idCampus );
if( it != m_mapCampus.end() )
return it->second;
return NULL;
}
bool CCampusMng::AddPlayerId2CampusId( u_long idPlayer, u_long idCampus )
{
bool bResult = m_mapPid2Cid.insert( MAP_PID2CID::value_type( idPlayer, idCampus ) ).second;
return bResult;
}
u_long CCampusMng::GetCampusIdByPlayerId( u_long idPlayer )
{
MAP_PID2CID::iterator it = m_mapPid2Cid.find( idPlayer );
if( it != m_mapPid2Cid.end() )
return it->second;
return NULL;
}
#endif // __CAMPUS | [
"[email protected]@e2c90bd7-ee55-cca0-76d2-bbf4e3699278"
]
| [
[
[
1,
317
]
]
]
|
ab2874e27efa301d758140545a1428bf260a31e5 | f9351a01f0e2dec478e5b60c6ec6445dcd1421ec | /itl/boost/itl/interval_maps.hpp | 47311bdd65054fa9637974b59066a9ba89f66e0e | [
"BSL-1.0"
]
| permissive | WolfgangSt/itl | e43ed68933f554c952ddfadefef0e466612f542c | 6609324171a96565cabcf755154ed81943f07d36 | refs/heads/master | 2016-09-05T20:35:36.628316 | 2008-11-04T11:44:44 | 2008-11-04T11:44:44 | 327,076 | 0 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 16,558 | hpp | /*----------------------------------------------------------------------------+
Copyright (c) 2008-2008: Joachim Faulhaber
+-----------------------------------------------------------------------------+
Distributed under the Boost Software License, Version 1.0.
(See accompanying file LICENCE.txt or copy at
http://www.boost.org/LICENSE_1_0.txt)
+----------------------------------------------------------------------------*/
#ifndef __itl_interval_maps_h_JOFA_081008__
#define __itl_interval_maps_h_JOFA_081008__
#include <boost/itl/interval_base_map.hpp>
#include <boost/itl/interval_map_algo.hpp>
namespace boost{namespace itl
{
template
<
class, class, class, template<class>class,
template<class>class, template<class>class
>
class interval_map;
//-----------------------------------------------------------------------------
// addition +=
//-----------------------------------------------------------------------------
template
<
class SubType, class DomainT, class CodomainT,
class Traits, template<class>class Interval,
template<class>class Compare, template<class>class Alloc,
template
<
class, class, class, template<class>class,
template<class>class, template<class>class
>
class IntervalMap
>
interval_base_map<SubType,DomainT,CodomainT,Traits,Interval,Compare,Alloc>&
operator +=
(
interval_base_map<SubType,DomainT,CodomainT,
Traits,Interval,Compare,Alloc>& object,
const IntervalMap<DomainT,CodomainT,
Traits,Interval,Compare,Alloc>& operand
)
{
typedef IntervalMap<DomainT,CodomainT,
Traits,Interval,Compare,Alloc> operand_type;
const_FORALL(typename operand_type, elem_, operand)
object.add(*elem_);
return object;
}
//--- value_type --------------------------------------------------------------
template
<
class DomainT, class CodomainT,
class Traits, template<class>class Interval,
template<class>class Compare, template<class>class Alloc,
template
<
class, class, class, template<class>class,
template<class>class, template<class>class
>
class IntervalMap
>
IntervalMap<DomainT,CodomainT,Traits,Interval,Compare,Alloc>&
operator +=
(
IntervalMap<DomainT,CodomainT,
Traits,Interval,Compare,Alloc>& object,
const typename
IntervalMap<DomainT,CodomainT,
Traits,Interval,Compare,Alloc>::value_type& operand
)
{
return object.add(operand);
}
//--- base_value_type ---------------------------------------------------------
// Addition (+=) of a base value pair.
/* Addition of an value pair <tt>x=(I,y)</tt>
This adds (inserts) a value <tt>y</tt> for an interval <tt>I</tt> into the
map, identical member function add.
If no values are associated already within the range of <tt>I</tt>,
<tt>y</tt> will be associated to that interval.
If there are associated values, in the range of <tt>I</tt>, then all
those values within the ranges of their intervals,
are incremented by <tt>y</tt>. This is done via operator <tt>+=</tt>
which has to be implemented for CodomainT.
*/
template
<
class DomainT, class CodomainT,
class Traits, template<class>class Interval,
template<class>class Compare, template<class>class Alloc,
template
<
class, class, class, template<class>class,
template<class>class, template<class>class
>
class IntervalMap
>
IntervalMap<DomainT,CodomainT,Traits,Interval,Compare,Alloc>&
operator +=
(
IntervalMap<DomainT,CodomainT,
Traits,Interval,Compare,Alloc>& object,
const typename
IntervalMap<DomainT,CodomainT,
Traits,Interval,Compare,Alloc>::base_pair_type& operand
)
{
return object.add(operand);
}
//-----------------------------------------------------------------------------
// subtraction -=
//-----------------------------------------------------------------------------
template
<
class SubType, class DomainT, class CodomainT,
class Traits, template<class>class Interval,
template<class>class Compare, template<class>class Alloc,
template
<
class, class, class, template<class>class,
template<class>class, template<class>class
>
class IntervalMap
>
interval_base_map<SubType,DomainT,CodomainT,Traits,Interval,Compare,Alloc>&
operator -=
(
interval_base_map<SubType,DomainT,CodomainT,
Traits,Interval,Compare,Alloc>& object,
const IntervalMap<DomainT,CodomainT,
Traits,Interval,Compare,Alloc>& operand
)
{
typedef IntervalMap<DomainT,CodomainT,
Traits,Interval,Compare,Alloc> operand_type;
const_FORALL(typename operand_type, elem_, operand)
object.subtract(*elem_);
return object;
}
//--- value_type --------------------------------------------------------------
// Subtraction of an interval value pair
/* Subtraction of an interval value pair <tt>x=(I,y)</tt>.
This subtracts a value <tt>y</tt> for an interval <tt>I</tt> from the map.
If there are associated values, in the range of <tt>I</tt>, all
those values within the ranges of their intervals,
are decremented by <tt>y</tt>. This is done usign operator -=.
If <tt>y</tt> becomes the neutral element CodomainT() <tt>k</tt> will
also be removed from the map, if the Traits include the property
neutron_absorber.
*/
template
<
class DomainT, class CodomainT,
class Traits, template<class>class Interval,
template<class>class Compare, template<class>class Alloc,
template
<
class, class, class, template<class>class,
template<class>class, template<class>class
>
class IntervalMap
>
IntervalMap<DomainT,CodomainT,Traits,Interval,Compare,Alloc>&
operator -=
(
IntervalMap<DomainT,CodomainT,
Traits,Interval,Compare,Alloc>& object,
const typename
IntervalMap<DomainT,CodomainT,
Traits,Interval,Compare,Alloc>::value_type& operand
)
{
return object.subtract(operand);
}
//--- base_value_type ---------------------------------------------------------
template
<
class DomainT, class CodomainT,
class Traits, template<class>class Interval,
template<class>class Compare, template<class>class Alloc,
template
<
class, class, class, template<class>class,
template<class>class, template<class>class
>
class IntervalMap
>
IntervalMap<DomainT,CodomainT,Traits,Interval,Compare,Alloc>&
operator -=
(
IntervalMap<DomainT,CodomainT,
Traits,Interval,Compare,Alloc>& object,
const typename
IntervalMap<DomainT,CodomainT,
Traits,Interval,Compare,Alloc>::base_pair_type& operand
)
{
return object.subtract(operand);
}
//-----------------------------------------------------------------------------
// erasure -= of elements given by an interval_set
//-----------------------------------------------------------------------------
template
<
class SubType, class DomainT, class CodomainT,
class Traits, template<class>class Interval,
template<class>class Compare, template<class>class Alloc,
template
<
class, template<class>class,
template<class>class, template<class>class
>
class IntervalSet
>
interval_base_map<SubType,DomainT,CodomainT,Traits,Interval,Compare,Alloc>&
operator -=
(
interval_base_map<SubType,DomainT,CodomainT,
Traits,Interval,Compare,Alloc>& object,
const IntervalSet<DomainT,Interval,Compare,Alloc>& erasure
)
{
typedef IntervalSet<DomainT,Interval,Compare,Alloc> set_type;
const_FORALL(typename set_type, interval_, erasure)
object.erase(*interval_);
return object;
}
//--- value_type --------------------------------------------------------------
template
<
class DomainT, class CodomainT,
class Traits, template<class>class Interval,
template<class>class Compare, template<class>class Alloc,
template
<
class, class, class, template<class>class,
template<class>class, template<class>class
>
class IntervalMap
>
IntervalMap<DomainT,CodomainT,Traits,Interval,Compare,Alloc>&
operator -=
(
IntervalMap<DomainT,CodomainT,
Traits,Interval,Compare,Alloc>& object,
const typename
IntervalMap<DomainT,CodomainT,
Traits,Interval,Compare,Alloc>::interval_type& operand
)
{
return object.erase(operand);
}
//-----------------------------------------------------------------------------
// insert
//-----------------------------------------------------------------------------
template
<
class SubType, class DomainT, class CodomainT,
class Traits, template<class>class Interval,
template<class>class Compare, template<class>class Alloc,
class OperandT
>
interval_base_map<SubType,DomainT,CodomainT,Traits,Interval,Compare,Alloc>&
insert
(
interval_base_map<SubType,DomainT,CodomainT,
Traits,Interval,Compare,Alloc>& object,
const OperandT& operand
)
{
const_FORALL(typename OperandT, elem_, operand)
object.insert(*elem_);
return object;
}
//-----------------------------------------------------------------------------
// erase
//-----------------------------------------------------------------------------
template
<
class SubType, class DomainT, class CodomainT,
class Traits, template<class>class Interval,
template<class>class Compare, template<class>class Alloc,
class OperandT
>
interval_base_map<SubType,DomainT,CodomainT,Traits,Interval,Compare,Alloc>&
erase
(
interval_base_map<SubType,DomainT,CodomainT,
Traits,Interval,Compare,Alloc>& object,
const OperandT& operand
)
{
const_FORALL(typename OperandT, elem_, operand)
object.erase(*elem_);
return object;
}
//-----------------------------------------------------------------------------
// intersection *=
//-----------------------------------------------------------------------------
template
<
class SubType, class DomainT, class CodomainT,
class Traits, template<class>class Interval,
template<class>class Compare, template<class>class Alloc,
class SectanT
>
interval_base_map<SubType,DomainT,CodomainT,Traits,Interval,Compare,Alloc>&
operator *=
(
interval_base_map<SubType,DomainT,CodomainT,
Traits,Interval,Compare,Alloc>& object,
const SectanT& operand
)
{
typedef interval_base_map<SubType,DomainT,CodomainT,
Traits,Interval,Compare,Alloc> object_type;
object_type intersection;
object.add_intersection(intersection,operand);
object.swap(intersection);
return object;
}
//-----------------------------------------------------------------------------
// is_element_equal
//-----------------------------------------------------------------------------
template
<
class DomainT, class CodomainT,
class Traits, template<class>class Interval,
template<class>class Compare, template<class>class Alloc,
template
<
class, class, class, template<class>class,
template<class>class, template<class>class
>
class LeftIntervalMap,
template
<
class, class, class, template<class>class,
template<class>class, template<class>class
>
class RightIntervalMap
>
bool is_element_equal
(
const LeftIntervalMap <DomainT,CodomainT,
Traits,Interval,Compare,Alloc>& left,
const RightIntervalMap<DomainT,CodomainT,
Traits,Interval,Compare,Alloc>& right
)
{
return Map::is_element_equal(left, right);
}
//-----------------------------------------------------------------------------
// is_disjoint
//-----------------------------------------------------------------------------
//--- IntervalMap -------------------------------------------------------------
template
<
class SubType, class DomainT, class CodomainT,
class Traits, template<class>class Interval,
template<class>class Compare, template<class>class Alloc,
template
<
class, class, class, template<class>class,
template<class>class, template<class>class
>
class IntervalMap
>
//JODO boost::enable_if
bool is_disjoint
(
interval_base_map<SubType,DomainT,CodomainT,
Traits,Interval,Compare,Alloc>& object,
const IntervalMap<DomainT,CodomainT,
Traits,Interval,Compare,Alloc>& operand
)
{
typedef interval_base_map<SubType,DomainT,CodomainT,
Traits,Interval,Compare,Alloc> object_type;
typedef IntervalMap<DomainT,CodomainT,
Traits,Interval,Compare,Alloc> operand_type;
object_type intersection;
if(operand.empty())
return true;
typename operand_type::const_iterator common_lwb;
typename operand_type::const_iterator common_upb;
if(!Set::common_range(common_lwb, common_upb, operand, object))
return true;
typename operand_type::const_iterator it = common_lwb;
while(it != common_upb)
{
object.add_intersection(intersection, (it++)->KEY_VALUE);
if(!intersection.empty())
return false;
}
return true;
}
//--- IntervalSet -------------------------------------------------------------
template
<
class SubType, class DomainT, class CodomainT,
class Traits, template<class>class Interval,
template<class>class Compare, template<class>class Alloc,
template
<
class, template<class>class,
template<class>class, template<class>class
>
class IntervalSet
>
//JODO boost::enable_if
bool is_disjoint
(
interval_base_map<SubType,DomainT,CodomainT,
Traits,Interval,Compare,Alloc>& object,
const IntervalSet<DomainT,Interval,Compare,Alloc>& operand
)
{
typedef interval_base_map<SubType,DomainT,CodomainT,
Traits,Interval,Compare,Alloc> object_type;
typedef IntervalSet<DomainT,Interval,Compare,Alloc> operand_type;
object_type intersection;
if(operand.empty())
return true;
typename operand_type::const_iterator common_lwb;
typename operand_type::const_iterator common_upb;
if(!Set::common_range(common_lwb, common_upb, operand, object))
return true;
typename operand_type::const_iterator it = common_lwb;
while(it != common_upb)
{
object.add_intersection(intersection, *it++);
if(!intersection.empty())
return false;
}
return true;
}
//-----------------------------------------------------------------------------
// enclosure
//-----------------------------------------------------------------------------
template
<
class DomainT, class CodomainT,
class Traits, template<class>class Interval,
template<class>class Compare, template<class>class Alloc,
template
<
class, class, class, template<class>class,
template<class>class, template<class>class
>
class IntervalMap
>
typename IntervalMap<DomainT,CodomainT,Traits,Interval,Compare,Alloc>::interval_type
enclosure(const IntervalMap<DomainT,CodomainT,Traits,Interval,Compare,Alloc>& object)
{
typedef IntervalMap<DomainT,CodomainT,Traits,Interval,Compare,Alloc> IntervalMapT;
typedef typename IntervalMapT::interval_type interval_type;
return
object.empty() ? neutron<interval_type>::value()
: (object.begin()->KEY_VALUE)
.span(object.rbegin()->KEY_VALUE);
}
}} // namespace itl boost
#endif
| [
"jofaber@6b8beb3d-354a-0410-8f2b-82c74c7fef9a"
]
| [
[
[
1,
512
]
]
]
|
e1528808571f3e6f273693963a2f4cdce95cb38d | 8a8873b129313b24341e8fa88a49052e09c3fa51 | /inc/NewestDownload.h | a39c19236799d0fe94243e2af77d3e28f327a765 | []
| no_license | flaithbheartaigh/wapbrowser | ba09f7aa981d65df810dba2156a3f153df071dcf | b0d93ce8517916d23104be608548e93740bace4e | refs/heads/master | 2021-01-10T11:29:49.555342 | 2010-03-08T09:36:03 | 2010-03-08T09:36:03 | 50,261,329 | 1 | 0 | null | null | null | null | GB18030 | C++ | false | false | 5,226 | h | /*
============================================================================
Name : NewestDownload.h
Author :
Version :
Copyright : Your copyright notice
Description : NewestDownload declaration
============================================================================
*/
#ifndef NEWESTDOWNLOAD_H
#define NEWESTDOWNLOAD_H
//上面两句很重要勒。
// INCLUDES
#include <e32std.h>
#include <e32base.h>
// CLASS DECLARATION
#include "ControlFactory.h"
#include "MainEngine.h"
#include "Window.h"
#include "TypeDefine.h"
#include"ListBox.h"
#include "PopUpMenu.h"
#include "NaviPane.h"
#include "TitleBar.h"
#include "NewDownload.h"
#include "BitmapFactory.h"
#include "PictureEngine.h"
//add by hesanyuan
#include "Dialog.h"
/**
* NewestDownload
*
*/
#include "CacheObserver.h"//cacheobserver.
#include "MControlObserver.h"
#include "PopUpMenuObserver.h"
#include "DialogObserver.h"
#include "ContentInfoDialog.h"
class CHandleGrade;
class CInputDialog;
class CHandleSynchronization;
class CCacheEngine;
class CHandleInfo;
class NewestDownload : public CWindow
,public MPopUpMenuObserver
,public MGradeObserver
,public MHandleEventObserver
,public MDialogObserver
,public MInputObserver// public CBase
, public MCacheObserver
, public MInfoObserver
,public MContentInfoObserver
{
public: // Constructors and destructor
/**
* Destructor.
*/
~NewestDownload();
/**
* Two-phased constructor.
*/
static NewestDownload* NewL(CWindow* aParent,CMainEngine& aMainEngine);
/**
* Two-phased constructor.
*/
static NewestDownload* NewLC(CWindow* aParent,CMainEngine& aMainEngine);
public:
virtual void DoActivateL();
//派生类实现冻结视图
virtual void DoDeactivate();
//派生类实现绘图
virtual void DoDraw(CGraphic& aGraphic)const;
//派生类实现按键事件响应
virtual TBool DoKeyEventL(TInt aKeyCode);
virtual TBool DoHandleCommandL(TInt aCommand);
//派生类实现界面尺寸改变
virtual void DoSizeChanged();
//派生类实现设置左右按钮,以便覆盖按钮的控件返回时回复原样
virtual void ChangeButton();
public://From ContentInfoDialog
virtual void ContentInfoEvent(TInt aLeftCommond);
void InitInfoDialog(const TDesC& aName,const TDesC& aSize,const TDesC& aType,const TDesC& aRemark,TInt aCommand,TBool aBool);
public:
virtual void DialogEvent(TInt aCommand);
virtual void GradeEvent(TInt aEvent,TInt aGrade);//From GradeDialog
virtual void HandleResponseEvent(TInt aEvent,TInt aType);//From MHandleEventObserver
void InitDialog(const TDesC& aText);//用来初始化对话框
void InitGradeDialog();//评分界面。
void InitWaitDialog(const TDesC& aText);
void SendMyGrade();//发送评分
virtual void InputResponseEvent(TInt aEvent,const TDesC& aText);//From InputDialog;
virtual void InfoResponseEvent(TInt aEvent);//From MInfoObserver
// void InitInfoDialog(const TDesC& aTitle,const TDesC& aInfo);//信息详情。
void GetInfo();
void CheckDowndtype();//检查文件类型.
public:
void AddListITemL();
TBool HandleIconKeyL(TInt aKeyCode);
void InitMenu();
void EnterModel(TInt atype);
virtual void DoPopUpMenuCommand(TInt aCommand);
void ReadXML(const TDesC& aFileName);
void Goto(TInt apage);//跳转
void Changpage(TBool aflalgs);//翻页;
void ShowList();//显示列表
CDesCArray* iDesArray;//用于存放数列表里的数据。
void InputDialog();//跳到的输入框
//下载
void GetDownLoadInfo(TDes& aUrl,TDes& aFileName,TInt iFileSize);
void DownLoadFile(TInt adowntype);
TInt AdvertisMent();//广告.
void GetGradid(TInt& aFirstid,TInt& aSecondid,TInt& aInput);//ainput:你想要得到的一二级的值。
void CreateTileAndList();
TBool UpData();
void DrawRightInfo();
void Search();
TInt iSearchid;
void Changdrawpage(TBool aflages);//用于翻页
public://From MCacheObserver
virtual void CacheUpdate(const TDesC& aFileName);
virtual void CacheFailed();
private:
TBool iflalgs;//add
const TDesC *itempdes;//add
TBool iGradeFlage;//add
CListBox* ilistbox;
CTitleBar* iTitlebar;
TInt iCurpage;//当前页.
TInt iAllpage;//总页
CDialog* iDialog;
CHandleGrade* iShowGrade;//评分
CInputDialog* iInputDialog;
//图标
const CFbsBitmap* iIconBitmap;
const CFbsBitmap* iIconBitmapMask;
TInt iGrade;
CCacheEngine* iCacheEngine;
CHandleSynchronization& iSyschr;//同步
TInt iInputid;
TInt *iMenuArray;
TInt iArrayNo;
TInt iJumpPage; //add这个表示跳的页数。
TInt iJumpFlage;//共有三个值:0表示没有触发,1表示跳动。
TInt iDownType;
CContentInfoDialog* iContentInfo;//信息详情的对话框.
CHandleInfo* iShowInfo;//信息详情/
/**
* Constructor for performing 1st stage construction
*/
NewestDownload(CWindow* aParent,CMainEngine& aMainEngine);
/**
* EPOC default constructor for performing 2nd stage construction
*/
void ConstructL();
};
#endif // FRIENDLINK_H
| [
"sungrass.xp@37a08ede-ebbd-11dd-bd7b-b12b6590754f"
]
| [
[
[
1,
185
]
]
]
|
127c3794cff5baae21c08afe0758ad0fb9e214f0 | 6996a66a1a3434203d0b9a6433902654c41309c8 | /Utils.h | 17cb1ecddfa464739a14719e0d41615e5905d9c9 | []
| no_license | dtbinh/CATALST-Robot-Formations-Simulator | 83509eba833f20f56311078049038da866d0b5a5 | f389557358588dcdf60c058c5ac0b55a5d2a7ae5 | refs/heads/master | 2020-05-29T08:45:57.510135 | 2011-06-29T08:54:27 | 2011-06-29T08:54:27 | 69,551,189 | 1 | 0 | null | 2016-09-29T09:12:48 | 2016-09-29T09:12:47 | null | UTF-8 | C++ | false | false | 4,122 | h | //
// Filename: "Utils.h"
//
// Programmer: Ross Mead
// Last modified: 30Nov2009
//
// Description: This file contains various utility functions.
//
// preprocessor directives
#ifndef UTILS_H
#define UTILS_H
#include <cstdlib>
#include <iostream>
#include "GLIncludes.h"
using namespace std;
// debug definitions
//#define DEBUG (1)
// math pi definition
#ifndef PI
#define PI (M_PI)
#endif
// global constants
static const GLfloat TWO_PI = 2.0f * PI;
static const GLfloat PI_OVER_180 = PI / 180.0f;
//
// GLfloat scaleDegrees(theta)
// Last modified: 26Aug2006
//
// Scales the parameterized angle (in degrees) to an angle [-180, 180].
//
// Returns: the scaled angle (in degrees)
// Parameters:
// theta in the angle (in degrees) to be scaled
//
inline GLfloat scaleDegrees(GLfloat theta)
{
if (theta > 0.0f)
while ((theta >= 360.0f) || (theta > 180.0f)) theta -= 360.0f;
else if (theta < 0.0f)
while ((theta <= -360.0f) || (theta < -180.0f)) theta += 360.0f;
return theta;
} // scaleDegrees(GLfloat)
//
// GLfloat scaleRadians(theta)
// Last modified: 26Aug2006
//
// Scales the parameterized angle (in radians) to an angle [-2 * PI, 2 * PI].
//
// Returns: the scaled angle (in radians)
// Parameters:
// theta in the angle (in radians) to be scaled
//
inline GLfloat scaleRadians(GLfloat theta)
{
if (theta > 0.0f)
while ((theta >= TWO_PI) || (theta > PI)) theta -= TWO_PI;
else if (theta < 0.0f)
while ((theta <= -TWO_PI) || (theta < -PI)) theta += TWO_PI;
return theta;
} // scaleRadians(GLfloat)
//
// GLfloat degreesToRadians(theta)
// Last modified: 26Aug2006
//
// Converts the parameterized angle (in degrees) to an angle in radians.
//
// Returns: the converted angle (in radians)
// Parameters:
// theta in the angle (in degrees) to converted to radians
//
inline GLfloat degreesToRadians(GLfloat theta)
{
return scaleDegrees(theta) * PI_OVER_180;
} // degreesToRadians(GLfloat)
//
// GLfloat radiansToDegrees(theta)
// Last modified: 26Aug2006
//
// Converts the parameterized angle (in radians) to an angle in degrees.
//
// Returns: the converted angle (in degrees)
// Parameters:
// theta in the angle (in radians) to converted to degrees
//
inline GLfloat radiansToDegrees(GLfloat theta)
{
return scaleRadians(theta) / PI_OVER_180;
} // radiansToDegrees(GLfloat)
//
// GLfloat frand(min, max)
// Last modified: 08Nov2009
//
// Returns a floating-point number [min, max].
//
// Returns: a floating-point number [min, max]
// Parameters:
// min in the minimum of the number being returned
// max in the maximum of the number being returned
//
inline GLfloat frand(const GLfloat min = 0.0f, const GLfloat max = 1.0f)
{
return min + (max - min) * GLfloat(rand()) / GLfloat(RAND_MAX);
} // frand()
//
// GLint irand(min, max)
// Last modified: 08Nov2009
//
// Returns an integer number [min, max].
//
// Returns: an integer number [min, max]
// Parameters:
// min in the minimum of the number being returned
// max in the maximum of the number being returned
//
inline GLint irand(const GLint min = 0, const GLint max = 1)
{
return min + rand() % (max + 1);
} // irand()
//
// GLfloat randSign()
// Last modified: 26Aug2006
//
// Returns -1 or 1.
//
// Returns: -1 or 1
// Parameters: <none>
//
inline GLfloat randSign()
{
return (rand() % 2) ? -1.0f : 1.0f;
} // randSign()
//
// GLfloat sign()
// Last modified: 26Aug2006
//
// Returns the sign of the parameterized number.
//
// Returns: the sign of the parameterized number
// Parameters:
// f in the number to determine the sign of
//
inline GLfloat sign(const GLfloat f)
{
return (f < 0.0f) ? -1.0f : 1.0f;
} // sign(const GLfloat)
#endif
| [
"rossmead@larry.(none)"
]
| [
[
[
1,
181
]
]
]
|
28357d0c3f181d81c010795f76d8e44e8ed8e225 | d2996420f8c3a6bbeef63a311dd6adc4acc40436 | /src/server/ServerPlayer.h | 54a8003bb0c0f3cf4f2655b6d56445e445c78c73 | []
| no_license | aruwen/graviator | 4d2e06e475492102fbf5d65754be33af641c0d6c | 9a881db9bb0f0de2e38591478429626ab8030e1d | refs/heads/master | 2021-01-19T00:13:10.843905 | 2011-03-13T13:15:25 | 2011-03-13T13:15:25 | 32,136,578 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,292 | h | //*********************************************************
// Graviator - QPT2a - FH Salzburg
// Stefan Ebner - Malte Langkabel - Christian Winkler
//
// Player
// manages Player
//
//*********************************************************
#ifndef SERVER_PLAYER_H
#define SERVER_PLAYER_H
#include "ServerObject.h"
#include "../src/vec3f.h"
#include "LuaStateManager.h"
#include "../server/ServerEnergyManager.h"
#include "ServerObjectFactory.h"
#include "../PrecisionTimer.h"
#define LUA LuaStateManager::getInstance()
class ServerPlayer : public ServerObject
{
public:
ServerPlayer();
~ServerPlayer();
void update();
vec3f getForce(vec3f affectedLocation);
vec3f getEnergy();
bool canSteerLeft();
bool canSteerRight();
bool canShoot();
void steerLeft();
void steerRight();
void shoot();
void resetEnergy();
void increaseScore();
unsigned int getScore();
void resetScore();
void die();
bool isDead();
bool shouldRespawn();
float getRespawnTime();
private:
ServerEnergyManager mServerEnergyManager;
unsigned int mScore;
PrecisionTimer *mResawnTimer;
PrecisionTimer* mTimerShot;
PrecisionTimer* mTimerSteerLeft;
PrecisionTimer* mTimerSteerRight;
};
#endif | [
"[email protected]@c8d5bfcc-1391-a108-90e5-e810ef6ef867"
]
| [
[
[
1,
60
]
]
]
|
902c0b97ed8b53f823cbb6ad277bf75bd6c29346 | 27d5670a7739a866c3ad97a71c0fc9334f6875f2 | /CPP/Targets/MapLib/Shared/src/WFDRMUtil.cpp | 51d4759771bccde1316c0da2fac3515db730cdba | [
"BSD-3-Clause"
]
| permissive | ravustaja/Wayfinder-S60-Navigator | ef506c418b8c2e6498ece6dcae67e583fb8a4a95 | 14d1b729b2cea52f726874687e78f17492949585 | refs/heads/master | 2021-01-16T20:53:37.630909 | 2010-06-28T09:51:10 | 2010-06-28T09:51:10 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,862 | cpp | /*
Copyright (c) 1999 - 2010, Vodafone Group Services Ltd
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 Vodafone Group Services Ltd 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 COPYRIGHT HOLDERS AND CONTRIBUTORS "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 COPYRIGHT HOLDER OR CONTRIBUTORS 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 "config.h"
#include "WFDRMUtil.h"
#include "SharedBuffer.h"
const uint8
WFDRMUtil::c_randBytes[] = {
0xd0, 0x41, 0x09, 0x1b, 0xe6, 0x12, 0xa9, 0x69,
0x0a, 0xfa, 0xe5, 0x61, 0x4c, 0x6d, 0x15, 0x35,
0x55, 0x4d, 0x80, 0x82, 0x7d, 0x19, 0xa9, 0xa9,
0xb0, 0xaa, 0x03, 0x80, 0xce, 0x2b, 0x2a, 0x63,
0xba, 0x63, 0xa8, 0x82, 0x00, 0x5d, 0x82, 0x0f,
0x41, 0x43, 0xba, 0x64, 0x09, 0x48, 0x02, 0x20,
0xbb, 0xc0, 0x55, 0x49, 0xe8, 0xa6, 0xa0, 0x05,
0x00, 0x57, 0x03, 0x27, 0x56, 0xc3, 0x99, 0x9e,
0xbc, 0xb9, 0xb1, 0x16, 0x12, 0x33, 0x97, 0x40,
0x47, 0x32, 0x12, 0xe9, 0x52, 0x97, 0x0a, 0x03,
0xa3, 0x25, 0x95, 0xf8, 0x85, 0x8f, 0xfb, 0x7e,
0xe8, 0x26, 0x5a, 0x1e, 0x06, 0x6e, 0x2c, 0x21,
0xb2, 0x16, 0x91, 0x50, 0xda, 0x1e, 0x37, 0xff,
0x93, 0x55, 0x44, 0x7b, 0x86, 0x00, 0x8e, 0x4a,
0x49, 0xd0, 0x98, 0x03, 0xe2, 0x1c, 0x4e, 0x00,
0xfd, 0x3f, 0x88, 0x46, 0xde, 0x5c, 0xe0, 0xcc,
0x61, 0x18, 0x26, 0x5c, 0x9d, 0x20, 0x37, 0x81,
0xc9, 0x15, 0x8e, 0x25, 0x1a, 0x30, 0x67, 0x03,
0xff, 0xff, 0xe6, 0xff, 0x80, 0xe3, 0x0f, 0x60,
0x29, 0x1a, 0x9b, 0x02, 0x8f, 0x06, 0xcd, 0x67,
0x00, 0x00, 0x12, 0x02, 0x45, 0x49, 0x0e, 0x20,
0x3c, 0x3c, 0x0d, 0xf8, 0x0c, 0x7d, 0x0a, 0x8c,
0x4b, 0x98, 0x06, 0xa7, 0x8a, 0xc0, 0x36, 0x1e,
0xb0, 0x2a, 0x81, 0xeb, 0x74, 0x3e, 0x06, 0x42,
0x6a, 0x24, 0xe0, 0xa2, 0x00, 0x37, 0xea, 0x06,
0x4c, 0xd2, 0x66, 0xbe, 0x14, 0x57, 0x37, 0x90,
0x6e, 0x2c, 0x6b, 0x2d, 0x82, 0xb9, 0xf1, 0x25,
0x89, 0x71, 0x09, 0x88, 0x52, 0x51, 0xae, 0x46,
0x10, 0xa4, 0x65, 0x58, 0x53, 0xf1, 0x44, 0x23,
0x44, 0x78, 0xfa, 0x53, 0xf5, 0x05, 0x99, 0xd6,
0x5e, 0x0a, 0x0e, 0x28, 0xa7, 0x03, 0xb6, 0x2d,
0x0c, 0x9a, 0xf5, 0x99, 0xe1, 0x20, 0x00, 0x7b };
SharedBuffer*
WFDRMUtil::createXorKey( const SharedBuffer& inKey )
{
const uint8* keyBytes = inKey.getBufferAddress();
const int keySize = inKey.getBufferSize();
const int nbrRandBytes = sizeof( c_randBytes );
SharedBuffer* retBuf = new SharedBuffer( nbrRandBytes );
int keyPos = 0;
for ( int i = 0; i < nbrRandBytes; ++i ) {
retBuf->writeNextBAByte( c_randBytes[i] ^ keyBytes[keyPos++] );
if ( keyPos >= keySize ) {
keyPos = 0;
}
}
return retBuf;
}
| [
"[email protected]"
]
| [
[
[
1,
72
]
]
]
|
bd2fb27913a762c222da1b15bba00f1107f1a19c | 580738f96494d426d6e5973c5b3493026caf8b6a | /Include/Vcl/teeprevi.hpp | e5ba360e62664a05a46c18279ebb64bb736526a3 | []
| no_license | bravesoftdz/cbuilder-vcl | 6b460b4d535d17c309560352479b437d99383d4b | 7b91ef1602681e094a6a7769ebb65ffd6f291c59 | refs/heads/master | 2021-01-10T14:21:03.726693 | 2010-01-11T11:23:45 | 2010-01-11T11:23:45 | 48,485,606 | 2 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 7,726 | hpp | // Borland C++ Builder
// Copyright (c) 1995, 2002 by Borland Software Corporation
// All rights reserved
// (DO NOT EDIT: machine generated header) 'TeePrevi.pas' rev: 6.00
#ifndef TeePreviHPP
#define TeePreviHPP
#pragma delphiheader begin
#pragma option push -w-
#pragma option push -Vx
#include <TeCanvas.hpp> // Pascal unit
#include <TeeProcs.hpp> // Pascal unit
#include <ComCtrls.hpp> // Pascal unit
#include <Buttons.hpp> // Pascal unit
#include <StdCtrls.hpp> // Pascal unit
#include <ExtCtrls.hpp> // Pascal unit
#include <Dialogs.hpp> // Pascal unit
#include <Forms.hpp> // Pascal unit
#include <Controls.hpp> // Pascal unit
#include <Graphics.hpp> // Pascal unit
#include <Classes.hpp> // Pascal unit
#include <SysUtils.hpp> // Pascal unit
#include <Messages.hpp> // Pascal unit
#include <Windows.hpp> // Pascal unit
#include <SysInit.hpp> // Pascal unit
#include <System.hpp> // Pascal unit
//-- user supplied -----------------------------------------------------------
namespace Teeprevi
{
//-- type declarations -------------------------------------------------------
typedef void __fastcall (__closure *TOnChangeMarginsEvent)(System::TObject* Sender, bool DisableProportional, const Types::TRect &NewMargins);
#pragma option push -b-
enum TeePreviewZones { teePrev_None, teePrev_Left, teePrev_Top, teePrev_Right, teePrev_Bottom, teePrev_Image, teePrev_LeftTop, teePrev_RightTop, teePrev_LeftBottom, teePrev_RightBottom };
#pragma option pop
class DELPHICLASS TTeePreviewPage;
class PASCALIMPLEMENTATION TTeePreviewPage : public Controls::TGraphicControl
{
typedef Controls::TGraphicControl inherited;
private:
bool FAllowResize;
bool FAllowMove;
bool FAsBitmap;
Teeprocs::TCustomTeePanel* FImage;
bool FDragImage;
TOnChangeMarginsEvent FOnChangeMargins;
bool FOldShowImage;
Graphics::TColor FPaperColor;
bool FShowImage;
bool FShowMargins;
TeePreviewZones FDragged;
int OldX;
int OldY;
#pragma pack(push, 1)
Types::TRect OldRect;
#pragma pack(pop)
#pragma pack(push, 1)
Types::TRect ImageRect;
#pragma pack(pop)
#pragma pack(push, 1)
Types::TRect PaperRect;
#pragma pack(pop)
void __fastcall SetShowMargins(bool Value);
void __fastcall SetImage(Teeprocs::TCustomTeePanel* Value);
Graphics::TBitmap* __fastcall GetPrintingBitmap(void);
protected:
virtual void __fastcall Paint(void);
DYNAMIC void __fastcall MouseDown(Controls::TMouseButton Button, Classes::TShiftState Shift, int X, int Y);
DYNAMIC void __fastcall MouseUp(Controls::TMouseButton Button, Classes::TShiftState Shift, int X, int Y);
DYNAMIC void __fastcall MouseMove(Classes::TShiftState Shift, int X, int Y);
public:
__fastcall virtual TTeePreviewPage(Classes::TComponent* AOwner);
Types::TRect __fastcall CalcImagePrintMargins();
void __fastcall DrawPaper(Graphics::TCanvas* ACanvas);
void __fastcall DrawBack(Graphics::TCanvas* ACanvas);
void __fastcall DrawImage(Graphics::TCanvas* ACanvas);
void __fastcall DrawMargins(Graphics::TCanvas* ACanvas);
TeePreviewZones __fastcall WhereIsCursor(int x, int y);
void __fastcall Print(void);
__published:
__property bool AllowResize = {read=FAllowResize, write=FAllowResize, default=1};
__property bool AllowMove = {read=FAllowMove, write=FAllowMove, default=1};
__property bool AsBitmap = {read=FAsBitmap, write=FAsBitmap, nodefault};
__property bool DragImage = {read=FDragImage, write=FDragImage, default=0};
__property Graphics::TColor PaperColor = {read=FPaperColor, write=FPaperColor, nodefault};
__property bool ShowImage = {read=FShowImage, write=FShowImage, default=1};
__property bool ShowMargins = {read=FShowMargins, write=SetShowMargins, default=1};
__property TOnChangeMarginsEvent OnChangeMargins = {read=FOnChangeMargins, write=FOnChangeMargins};
__property Teeprocs::TCustomTeePanel* Image = {read=FImage, write=SetImage};
public:
#pragma option push -w-inl
/* TGraphicControl.Destroy */ inline __fastcall virtual ~TTeePreviewPage(void) { }
#pragma option pop
};
class DELPHICLASS TChartPreview;
class PASCALIMPLEMENTATION TChartPreview : public Forms::TForm
{
typedef Forms::TForm inherited;
__published:
Extctrls::TPanel* Panel1;
Stdctrls::TComboBox* Printers;
Stdctrls::TLabel* Label1;
Buttons::TBitBtn* BSetupPrinter;
Extctrls::TPanel* Panel2;
Extctrls::TRadioGroup* Orientation;
Stdctrls::TGroupBox* GBMargins;
Stdctrls::TEdit* SETopMa;
Stdctrls::TEdit* SELeftMa;
Stdctrls::TEdit* SEBotMa;
Stdctrls::TEdit* SERightMa;
Dialogs::TPrinterSetupDialog* PrinterSetupDialog1;
Stdctrls::TCheckBox* ShowMargins;
Stdctrls::TButton* BReset;
Stdctrls::TGroupBox* ChangeDetailGroup;
Stdctrls::TLabel* Label2;
Stdctrls::TLabel* Label3;
Stdctrls::TButton* BClose;
Stdctrls::TScrollBar* Resolution;
Stdctrls::TButton* BPrint;
Comctrls::TUpDown* UDLeftMa;
Comctrls::TUpDown* UDTopMa;
Comctrls::TUpDown* UDRightMa;
Comctrls::TUpDown* UDBotMa;
Stdctrls::TCheckBox* CBProp;
void __fastcall FormShow(System::TObject* Sender);
void __fastcall BSetupPrinterClick(System::TObject* Sender);
void __fastcall PrintersChange(System::TObject* Sender);
void __fastcall OrientationClick(System::TObject* Sender);
void __fastcall SETopMaChange(System::TObject* Sender);
void __fastcall SERightMaChange(System::TObject* Sender);
void __fastcall SEBotMaChange(System::TObject* Sender);
void __fastcall SELeftMaChange(System::TObject* Sender);
void __fastcall ShowMarginsClick(System::TObject* Sender);
void __fastcall FormCreate(System::TObject* Sender);
void __fastcall BResetClick(System::TObject* Sender);
void __fastcall ResolutionChange(System::TObject* Sender);
void __fastcall BPrintClick(System::TObject* Sender);
void __fastcall FormDestroy(System::TObject* Sender);
void __fastcall BCloseClick(System::TObject* Sender);
void __fastcall CBPropClick(System::TObject* Sender);
private:
bool CreatingForm;
bool ChangingMargins;
bool ChangingProp;
void __fastcall ResetMargins(void);
protected:
HIDESBASE MESSAGE void __fastcall WMEraseBkgnd(Messages::TWMEraseBkgnd &Message);
public:
TTeePreviewPage* PreviewPage;
#pragma pack(push, 1)
Types::TRect OldMargins;
#pragma pack(pop)
void __fastcall RefreshPage(void);
void __fastcall RecalcControls(void);
void __fastcall PreviewPageChangeMargins(System::TObject* Sender, bool DisableProportional, const Types::TRect &NewMargins);
void __fastcall ChangeMargin(Comctrls::TUpDown* UpDown, int &APos, int OtherSide);
public:
#pragma option push -w-inl
/* TCustomForm.Create */ inline __fastcall virtual TChartPreview(Classes::TComponent* AOwner) : Forms::TForm(AOwner) { }
#pragma option pop
#pragma option push -w-inl
/* TCustomForm.CreateNew */ inline __fastcall virtual TChartPreview(Classes::TComponent* AOwner, int Dummy) : Forms::TForm(AOwner, Dummy) { }
#pragma option pop
#pragma option push -w-inl
/* TCustomForm.Destroy */ inline __fastcall virtual ~TChartPreview(void) { }
#pragma option pop
public:
#pragma option push -w-inl
/* TWinControl.CreateParented */ inline __fastcall TChartPreview(HWND ParentWindow) : Forms::TForm(ParentWindow) { }
#pragma option pop
};
//-- var, const, procedure ---------------------------------------------------
extern PACKAGE void __fastcall ChartPreview(Classes::TComponent* AOwner, Teeprocs::TCustomTeePanel* TeePanel);
} /* namespace Teeprevi */
using namespace Teeprevi;
#pragma option pop // -w-
#pragma option pop // -Vx
#pragma delphiheader end.
//-- end unit ----------------------------------------------------------------
#endif // TeePrevi
| [
"bitscode@7bd08ab0-fa70-11de-930f-d36749347e7b"
]
| [
[
[
1,
206
]
]
]
|
f76cce5e5b7466d5039cfbdb6bbf72c7c3cd1330 | bdb8fc8eb5edc84cf92ba80b8541ba2b6c2b0918 | /TPs CPOO/Gareth & Maxime/Projet/CanonNoir_Moteur_C++/fichiers/Duel.h | 65ba0f573fdf3b8a68f53be82f65d3f1f78eaccf | []
| no_license | Issam-Engineer/tp4infoinsa | 3538644b40d19375b6bb25f030580004ed4a056d | 1576c31862ffbc048890e72a81efa11dba16338b | refs/heads/master | 2021-01-10T17:53:31.102683 | 2011-01-27T07:46:51 | 2011-01-27T07:46:51 | 55,446,817 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 518 | h | /**
*\file Duel.h
*\brief File containing the functionalities and the attributes of the Duel class
*\author Maxime HAVEZ
*\author Gareth THIVEUX
*\version 1.0
*/
#ifndef DUEL_H
#define DUEL_H
#include "Etat.h"
class Duel : public Etat
{
private :
bool touche;
public :
/**
*\fn void execute()
*\brief function which execute the current state
*/
virtual void execute();
/**
*\fn Duel(MoteurJeu* m)
*\brief Constructor
*/
Duel(MoteurJeu * m);
};
#endif | [
"havez.maxime.01@9f3b02c3-fd90-5378-97a3-836ae78947c6",
"garethiveux@9f3b02c3-fd90-5378-97a3-836ae78947c6"
]
| [
[
[
1,
1
],
[
7,
8
],
[
12,
25
],
[
31,
32
]
],
[
[
2,
6
],
[
9,
11
],
[
26,
30
],
[
33,
34
]
]
]
|
9127c11594606de786c1043b4b3920d56444cae4 | d54d8b1bbc9575f3c96853e0c67f17c1ad7ab546 | /hlsdk-2.3-p3/multiplayer/dlls/effects.cpp | c352b0e02364f88e75b56fb088135c4ecc81820a | []
| no_license | joropito/amxxgroup | 637ee71e250ffd6a7e628f77893caef4c4b1af0a | f948042ee63ebac6ad0332f8a77393322157fa8f | refs/heads/master | 2021-01-10T09:21:31.449489 | 2010-04-11T21:34:27 | 2010-04-11T21:34:27 | 47,087,485 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 52,772 | cpp | /***
*
* Copyright (c) 1996-2002, Valve LLC. All rights reserved.
*
* This product contains software technology licensed from Id
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
* All Rights Reserved.
*
* Use, distribution, and modification of this source code and/or resulting
* object code is restricted to non-commercial enhancements to products from
* Valve LLC. All other use, distribution, or modification is prohibited
* without written permission from Valve LLC.
*
****/
#include "extdll.h"
#include "util.h"
#include "cbase.h"
#include "monsters.h"
#include "customentity.h"
#include "effects.h"
#include "weapons.h"
#include "decals.h"
#include "func_break.h"
#include "shake.h"
#define SF_GIBSHOOTER_REPEATABLE 1 // allows a gibshooter to be refired
#define SF_FUNNEL_REVERSE 1 // funnel effect repels particles instead of attracting them.
// Lightning target, just alias landmark
LINK_ENTITY_TO_CLASS( info_target, CPointEntity );
class CBubbling : public CBaseEntity
{
public:
void Spawn( void );
void Precache( void );
void KeyValue( KeyValueData *pkvd );
void EXPORT FizzThink( void );
void Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value );
virtual int Save( CSave &save );
virtual int Restore( CRestore &restore );
virtual int ObjectCaps( void ) { return CBaseEntity::ObjectCaps() & ~FCAP_ACROSS_TRANSITION; }
static TYPEDESCRIPTION m_SaveData[];
int m_density;
int m_frequency;
int m_bubbleModel;
int m_state;
};
LINK_ENTITY_TO_CLASS( env_bubbles, CBubbling );
TYPEDESCRIPTION CBubbling::m_SaveData[] =
{
DEFINE_FIELD( CBubbling, m_density, FIELD_INTEGER ),
DEFINE_FIELD( CBubbling, m_frequency, FIELD_INTEGER ),
DEFINE_FIELD( CBubbling, m_state, FIELD_INTEGER ),
// Let spawn restore this!
// DEFINE_FIELD( CBubbling, m_bubbleModel, FIELD_INTEGER ),
};
IMPLEMENT_SAVERESTORE( CBubbling, CBaseEntity );
#define SF_BUBBLES_STARTOFF 0x0001
void CBubbling::Spawn( void )
{
Precache( );
SET_MODEL( ENT(pev), STRING(pev->model) ); // Set size
pev->solid = SOLID_NOT; // Remove model & collisions
pev->renderamt = 0; // The engine won't draw this model if this is set to 0 and blending is on
pev->rendermode = kRenderTransTexture;
int speed = pev->speed > 0 ? pev->speed : -pev->speed;
// HACKHACK!!! - Speed in rendercolor
pev->rendercolor.x = speed >> 8;
pev->rendercolor.y = speed & 255;
pev->rendercolor.z = (pev->speed < 0) ? 1 : 0;
if ( !(pev->spawnflags & SF_BUBBLES_STARTOFF) )
{
SetThink( FizzThink );
pev->nextthink = gpGlobals->time + 2.0;
m_state = 1;
}
else
m_state = 0;
}
void CBubbling::Precache( void )
{
m_bubbleModel = PRECACHE_MODEL("sprites/bubble.spr"); // Precache bubble sprite
}
void CBubbling::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value )
{
if ( ShouldToggle( useType, m_state ) )
m_state = !m_state;
if ( m_state )
{
SetThink( FizzThink );
pev->nextthink = gpGlobals->time + 0.1;
}
else
{
SetThink( NULL );
pev->nextthink = 0;
}
}
void CBubbling::KeyValue( KeyValueData *pkvd )
{
if (FStrEq(pkvd->szKeyName, "density"))
{
m_density = atoi(pkvd->szValue);
pkvd->fHandled = TRUE;
}
else if (FStrEq(pkvd->szKeyName, "frequency"))
{
m_frequency = atoi(pkvd->szValue);
pkvd->fHandled = TRUE;
}
else if (FStrEq(pkvd->szKeyName, "current"))
{
pev->speed = atoi(pkvd->szValue);
pkvd->fHandled = TRUE;
}
else
CBaseEntity::KeyValue( pkvd );
}
void CBubbling::FizzThink( void )
{
MESSAGE_BEGIN( MSG_PAS, SVC_TEMPENTITY, VecBModelOrigin(pev) );
WRITE_BYTE( TE_FIZZ );
WRITE_SHORT( (short)ENTINDEX( edict() ) );
WRITE_SHORT( (short)m_bubbleModel );
WRITE_BYTE( m_density );
MESSAGE_END();
if ( m_frequency > 19 )
pev->nextthink = gpGlobals->time + 0.5;
else
pev->nextthink = gpGlobals->time + 2.5 - (0.1 * m_frequency);
}
// --------------------------------------------------
//
// Beams
//
// --------------------------------------------------
LINK_ENTITY_TO_CLASS( beam, CBeam );
void CBeam::Spawn( void )
{
pev->solid = SOLID_NOT; // Remove model & collisions
Precache( );
}
void CBeam::Precache( void )
{
if ( pev->owner )
SetStartEntity( ENTINDEX( pev->owner ) );
if ( pev->aiment )
SetEndEntity( ENTINDEX( pev->aiment ) );
}
void CBeam::SetStartEntity( int entityIndex )
{
pev->sequence = (entityIndex & 0x0FFF) | ((pev->sequence&0xF000)<<12);
pev->owner = g_engfuncs.pfnPEntityOfEntIndex( entityIndex );
}
void CBeam::SetEndEntity( int entityIndex )
{
pev->skin = (entityIndex & 0x0FFF) | ((pev->skin&0xF000)<<12);
pev->aiment = g_engfuncs.pfnPEntityOfEntIndex( entityIndex );
}
// These don't take attachments into account
const Vector &CBeam::GetStartPos( void )
{
if ( GetType() == BEAM_ENTS )
{
edict_t *pent = g_engfuncs.pfnPEntityOfEntIndex( GetStartEntity() );
return pent->v.origin;
}
return pev->origin;
}
const Vector &CBeam::GetEndPos( void )
{
int type = GetType();
if ( type == BEAM_POINTS || type == BEAM_HOSE )
{
return pev->angles;
}
edict_t *pent = g_engfuncs.pfnPEntityOfEntIndex( GetEndEntity() );
if ( pent )
return pent->v.origin;
return pev->angles;
}
CBeam *CBeam::BeamCreate( const char *pSpriteName, int width )
{
// Create a new entity with CBeam private data
CBeam *pBeam = GetClassPtr( (CBeam *)NULL );
pBeam->pev->classname = MAKE_STRING("beam");
pBeam->BeamInit( pSpriteName, width );
return pBeam;
}
void CBeam::BeamInit( const char *pSpriteName, int width )
{
pev->flags |= FL_CUSTOMENTITY;
SetColor( 255, 255, 255 );
SetBrightness( 255 );
SetNoise( 0 );
SetFrame( 0 );
SetScrollRate( 0 );
pev->model = MAKE_STRING( pSpriteName );
SetTexture( PRECACHE_MODEL( (char *)pSpriteName ) );
SetWidth( width );
pev->skin = 0;
pev->sequence = 0;
pev->rendermode = 0;
}
void CBeam::PointsInit( const Vector &start, const Vector &end )
{
SetType( BEAM_POINTS );
SetStartPos( start );
SetEndPos( end );
SetStartAttachment( 0 );
SetEndAttachment( 0 );
RelinkBeam();
}
void CBeam::HoseInit( const Vector &start, const Vector &direction )
{
SetType( BEAM_HOSE );
SetStartPos( start );
SetEndPos( direction );
SetStartAttachment( 0 );
SetEndAttachment( 0 );
RelinkBeam();
}
void CBeam::PointEntInit( const Vector &start, int endIndex )
{
SetType( BEAM_ENTPOINT );
SetStartPos( start );
SetEndEntity( endIndex );
SetStartAttachment( 0 );
SetEndAttachment( 0 );
RelinkBeam();
}
void CBeam::EntsInit( int startIndex, int endIndex )
{
SetType( BEAM_ENTS );
SetStartEntity( startIndex );
SetEndEntity( endIndex );
SetStartAttachment( 0 );
SetEndAttachment( 0 );
RelinkBeam();
}
void CBeam::RelinkBeam( void )
{
const Vector &startPos = GetStartPos(), &endPos = GetEndPos();
pev->mins.x = min( startPos.x, endPos.x );
pev->mins.y = min( startPos.y, endPos.y );
pev->mins.z = min( startPos.z, endPos.z );
pev->maxs.x = max( startPos.x, endPos.x );
pev->maxs.y = max( startPos.y, endPos.y );
pev->maxs.z = max( startPos.z, endPos.z );
pev->mins = pev->mins - pev->origin;
pev->maxs = pev->maxs - pev->origin;
UTIL_SetSize( pev, pev->mins, pev->maxs );
UTIL_SetOrigin( pev, pev->origin );
}
#if 0
void CBeam::SetObjectCollisionBox( void )
{
const Vector &startPos = GetStartPos(), &endPos = GetEndPos();
pev->absmin.x = min( startPos.x, endPos.x );
pev->absmin.y = min( startPos.y, endPos.y );
pev->absmin.z = min( startPos.z, endPos.z );
pev->absmax.x = max( startPos.x, endPos.x );
pev->absmax.y = max( startPos.y, endPos.y );
pev->absmax.z = max( startPos.z, endPos.z );
}
#endif
void CBeam::TriggerTouch( CBaseEntity *pOther )
{
if ( pOther->pev->flags & (FL_CLIENT | FL_MONSTER) )
{
if ( pev->owner )
{
CBaseEntity *pOwner = CBaseEntity::Instance(pev->owner);
pOwner->Use( pOther, this, USE_TOGGLE, 0 );
}
ALERT( at_console, "Firing targets!!!\n" );
}
}
CBaseEntity *CBeam::RandomTargetname( const char *szName )
{
int total = 0;
CBaseEntity *pEntity = NULL;
CBaseEntity *pNewEntity = NULL;
while ((pNewEntity = UTIL_FindEntityByTargetname( pNewEntity, szName )) != NULL)
{
total++;
if (RANDOM_LONG(0,total-1) < 1)
pEntity = pNewEntity;
}
return pEntity;
}
void CBeam::DoSparks( const Vector &start, const Vector &end )
{
if ( pev->spawnflags & (SF_BEAM_SPARKSTART|SF_BEAM_SPARKEND) )
{
if ( pev->spawnflags & SF_BEAM_SPARKSTART )
{
UTIL_Sparks( start );
}
if ( pev->spawnflags & SF_BEAM_SPARKEND )
{
UTIL_Sparks( end );
}
}
}
class CLightning : public CBeam
{
public:
void Spawn( void );
void Precache( void );
void KeyValue( KeyValueData *pkvd );
void Activate( void );
void EXPORT StrikeThink( void );
void EXPORT DamageThink( void );
void RandomArea( void );
void RandomPoint( Vector &vecSrc );
void Zap( const Vector &vecSrc, const Vector &vecDest );
void EXPORT StrikeUse( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value );
void EXPORT ToggleUse( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value );
inline BOOL ServerSide( void )
{
if ( m_life == 0 && !(pev->spawnflags & SF_BEAM_RING) )
return TRUE;
return FALSE;
}
virtual int Save( CSave &save );
virtual int Restore( CRestore &restore );
static TYPEDESCRIPTION m_SaveData[];
void BeamUpdateVars( void );
int m_active;
int m_iszStartEntity;
int m_iszEndEntity;
float m_life;
int m_boltWidth;
int m_noiseAmplitude;
int m_brightness;
int m_speed;
float m_restrike;
int m_spriteTexture;
int m_iszSpriteName;
int m_frameStart;
float m_radius;
};
LINK_ENTITY_TO_CLASS( env_lightning, CLightning );
LINK_ENTITY_TO_CLASS( env_beam, CLightning );
// UNDONE: Jay -- This is only a test
#if _DEBUG
class CTripBeam : public CLightning
{
void Spawn( void );
};
LINK_ENTITY_TO_CLASS( trip_beam, CTripBeam );
void CTripBeam::Spawn( void )
{
CLightning::Spawn();
SetTouch( TriggerTouch );
pev->solid = SOLID_TRIGGER;
RelinkBeam();
}
#endif
TYPEDESCRIPTION CLightning::m_SaveData[] =
{
DEFINE_FIELD( CLightning, m_active, FIELD_INTEGER ),
DEFINE_FIELD( CLightning, m_iszStartEntity, FIELD_STRING ),
DEFINE_FIELD( CLightning, m_iszEndEntity, FIELD_STRING ),
DEFINE_FIELD( CLightning, m_life, FIELD_FLOAT ),
DEFINE_FIELD( CLightning, m_boltWidth, FIELD_INTEGER ),
DEFINE_FIELD( CLightning, m_noiseAmplitude, FIELD_INTEGER ),
DEFINE_FIELD( CLightning, m_brightness, FIELD_INTEGER ),
DEFINE_FIELD( CLightning, m_speed, FIELD_INTEGER ),
DEFINE_FIELD( CLightning, m_restrike, FIELD_FLOAT ),
DEFINE_FIELD( CLightning, m_spriteTexture, FIELD_INTEGER ),
DEFINE_FIELD( CLightning, m_iszSpriteName, FIELD_STRING ),
DEFINE_FIELD( CLightning, m_frameStart, FIELD_INTEGER ),
DEFINE_FIELD( CLightning, m_radius, FIELD_FLOAT ),
};
IMPLEMENT_SAVERESTORE( CLightning, CBeam );
void CLightning::Spawn( void )
{
if ( FStringNull( m_iszSpriteName ) )
{
SetThink( SUB_Remove );
return;
}
pev->solid = SOLID_NOT; // Remove model & collisions
Precache( );
pev->dmgtime = gpGlobals->time;
if ( ServerSide() )
{
SetThink( NULL );
if ( pev->dmg > 0 )
{
SetThink( DamageThink );
pev->nextthink = gpGlobals->time + 0.1;
}
if ( pev->targetname )
{
if ( !(pev->spawnflags & SF_BEAM_STARTON) )
{
pev->effects = EF_NODRAW;
m_active = 0;
pev->nextthink = 0;
}
else
m_active = 1;
SetUse( ToggleUse );
}
}
else
{
m_active = 0;
if ( !FStringNull(pev->targetname) )
{
SetUse( StrikeUse );
}
if ( FStringNull(pev->targetname) || FBitSet(pev->spawnflags, SF_BEAM_STARTON) )
{
SetThink( StrikeThink );
pev->nextthink = gpGlobals->time + 1.0;
}
}
}
void CLightning::Precache( void )
{
m_spriteTexture = PRECACHE_MODEL( (char *)STRING(m_iszSpriteName) );
CBeam::Precache();
}
void CLightning::Activate( void )
{
if ( ServerSide() )
BeamUpdateVars();
}
void CLightning::KeyValue( KeyValueData *pkvd )
{
if (FStrEq(pkvd->szKeyName, "LightningStart"))
{
m_iszStartEntity = ALLOC_STRING( pkvd->szValue );
pkvd->fHandled = TRUE;
}
else if (FStrEq(pkvd->szKeyName, "LightningEnd"))
{
m_iszEndEntity = ALLOC_STRING( pkvd->szValue );
pkvd->fHandled = TRUE;
}
else if (FStrEq(pkvd->szKeyName, "life"))
{
m_life = atof(pkvd->szValue);
pkvd->fHandled = TRUE;
}
else if (FStrEq(pkvd->szKeyName, "BoltWidth"))
{
m_boltWidth = atoi(pkvd->szValue);
pkvd->fHandled = TRUE;
}
else if (FStrEq(pkvd->szKeyName, "NoiseAmplitude"))
{
m_noiseAmplitude = atoi(pkvd->szValue);
pkvd->fHandled = TRUE;
}
else if (FStrEq(pkvd->szKeyName, "TextureScroll"))
{
m_speed = atoi(pkvd->szValue);
pkvd->fHandled = TRUE;
}
else if (FStrEq(pkvd->szKeyName, "StrikeTime"))
{
m_restrike = atof(pkvd->szValue);
pkvd->fHandled = TRUE;
}
else if (FStrEq(pkvd->szKeyName, "texture"))
{
m_iszSpriteName = ALLOC_STRING(pkvd->szValue);
pkvd->fHandled = TRUE;
}
else if (FStrEq(pkvd->szKeyName, "framestart"))
{
m_frameStart = atoi(pkvd->szValue);
pkvd->fHandled = TRUE;
}
else if (FStrEq(pkvd->szKeyName, "Radius"))
{
m_radius = atof( pkvd->szValue );
pkvd->fHandled = TRUE;
}
else if (FStrEq(pkvd->szKeyName, "damage"))
{
pev->dmg = atof(pkvd->szValue);
pkvd->fHandled = TRUE;
}
else
CBeam::KeyValue( pkvd );
}
void CLightning::ToggleUse( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value )
{
if ( !ShouldToggle( useType, m_active ) )
return;
if ( m_active )
{
m_active = 0;
pev->effects |= EF_NODRAW;
pev->nextthink = 0;
}
else
{
m_active = 1;
pev->effects &= ~EF_NODRAW;
DoSparks( GetStartPos(), GetEndPos() );
if ( pev->dmg > 0 )
{
pev->nextthink = gpGlobals->time;
pev->dmgtime = gpGlobals->time;
}
}
}
void CLightning::StrikeUse( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value )
{
if ( !ShouldToggle( useType, m_active ) )
return;
if ( m_active )
{
m_active = 0;
SetThink( NULL );
}
else
{
SetThink( StrikeThink );
pev->nextthink = gpGlobals->time + 0.1;
}
if ( !FBitSet( pev->spawnflags, SF_BEAM_TOGGLE ) )
SetUse( NULL );
}
int IsPointEntity( CBaseEntity *pEnt )
{
if ( !pEnt->pev->modelindex )
return 1;
if ( FClassnameIs( pEnt->pev, "info_target" ) || FClassnameIs( pEnt->pev, "info_landmark" ) || FClassnameIs( pEnt->pev, "path_corner" ) )
return 1;
return 0;
}
void CLightning::StrikeThink( void )
{
if ( m_life != 0 )
{
if ( pev->spawnflags & SF_BEAM_RANDOM )
pev->nextthink = gpGlobals->time + m_life + RANDOM_FLOAT( 0, m_restrike );
else
pev->nextthink = gpGlobals->time + m_life + m_restrike;
}
m_active = 1;
if (FStringNull(m_iszEndEntity))
{
if (FStringNull(m_iszStartEntity))
{
RandomArea( );
}
else
{
CBaseEntity *pStart = RandomTargetname( STRING(m_iszStartEntity) );
if (pStart != NULL)
RandomPoint( pStart->pev->origin );
else
ALERT( at_console, "env_beam: unknown entity \"%s\"\n", STRING(m_iszStartEntity) );
}
return;
}
CBaseEntity *pStart = RandomTargetname( STRING(m_iszStartEntity) );
CBaseEntity *pEnd = RandomTargetname( STRING(m_iszEndEntity) );
if ( pStart != NULL && pEnd != NULL )
{
if ( IsPointEntity( pStart ) || IsPointEntity( pEnd ) )
{
if ( pev->spawnflags & SF_BEAM_RING)
{
// don't work
return;
}
}
MESSAGE_BEGIN( MSG_BROADCAST, SVC_TEMPENTITY );
if ( IsPointEntity( pStart ) || IsPointEntity( pEnd ) )
{
if ( !IsPointEntity( pEnd ) ) // One point entity must be in pEnd
{
CBaseEntity *pTemp;
pTemp = pStart;
pStart = pEnd;
pEnd = pTemp;
}
if ( !IsPointEntity( pStart ) ) // One sided
{
WRITE_BYTE( TE_BEAMENTPOINT );
WRITE_SHORT( pStart->entindex() );
WRITE_COORD( pEnd->pev->origin.x);
WRITE_COORD( pEnd->pev->origin.y);
WRITE_COORD( pEnd->pev->origin.z);
}
else
{
WRITE_BYTE( TE_BEAMPOINTS);
WRITE_COORD( pStart->pev->origin.x);
WRITE_COORD( pStart->pev->origin.y);
WRITE_COORD( pStart->pev->origin.z);
WRITE_COORD( pEnd->pev->origin.x);
WRITE_COORD( pEnd->pev->origin.y);
WRITE_COORD( pEnd->pev->origin.z);
}
}
else
{
if ( pev->spawnflags & SF_BEAM_RING)
WRITE_BYTE( TE_BEAMRING );
else
WRITE_BYTE( TE_BEAMENTS );
WRITE_SHORT( pStart->entindex() );
WRITE_SHORT( pEnd->entindex() );
}
WRITE_SHORT( m_spriteTexture );
WRITE_BYTE( m_frameStart ); // framestart
WRITE_BYTE( (int)pev->framerate); // framerate
WRITE_BYTE( (int)(m_life*10.0) ); // life
WRITE_BYTE( m_boltWidth ); // width
WRITE_BYTE( m_noiseAmplitude ); // noise
WRITE_BYTE( (int)pev->rendercolor.x ); // r, g, b
WRITE_BYTE( (int)pev->rendercolor.y ); // r, g, b
WRITE_BYTE( (int)pev->rendercolor.z ); // r, g, b
WRITE_BYTE( pev->renderamt ); // brightness
WRITE_BYTE( m_speed ); // speed
MESSAGE_END();
DoSparks( pStart->pev->origin, pEnd->pev->origin );
if ( pev->dmg > 0 )
{
TraceResult tr;
UTIL_TraceLine( pStart->pev->origin, pEnd->pev->origin, dont_ignore_monsters, NULL, &tr );
BeamDamageInstant( &tr, pev->dmg );
}
}
}
void CBeam::BeamDamage( TraceResult *ptr )
{
RelinkBeam();
if ( ptr->flFraction != 1.0 && ptr->pHit != NULL )
{
CBaseEntity *pHit = CBaseEntity::Instance(ptr->pHit);
if ( pHit )
{
ClearMultiDamage();
pHit->TraceAttack( pev, pev->dmg * (gpGlobals->time - pev->dmgtime), (ptr->vecEndPos - pev->origin).Normalize(), ptr, DMG_ENERGYBEAM );
ApplyMultiDamage( pev, pev );
if ( pev->spawnflags & SF_BEAM_DECALS )
{
if ( pHit->IsBSPModel() )
UTIL_DecalTrace( ptr, DECAL_BIGSHOT1 + RANDOM_LONG(0,4) );
}
}
}
pev->dmgtime = gpGlobals->time;
}
void CLightning::DamageThink( void )
{
pev->nextthink = gpGlobals->time + 0.1;
TraceResult tr;
UTIL_TraceLine( GetStartPos(), GetEndPos(), dont_ignore_monsters, NULL, &tr );
BeamDamage( &tr );
}
void CLightning::Zap( const Vector &vecSrc, const Vector &vecDest )
{
#if 1
MESSAGE_BEGIN( MSG_BROADCAST, SVC_TEMPENTITY );
WRITE_BYTE( TE_BEAMPOINTS);
WRITE_COORD(vecSrc.x);
WRITE_COORD(vecSrc.y);
WRITE_COORD(vecSrc.z);
WRITE_COORD(vecDest.x);
WRITE_COORD(vecDest.y);
WRITE_COORD(vecDest.z);
WRITE_SHORT( m_spriteTexture );
WRITE_BYTE( m_frameStart ); // framestart
WRITE_BYTE( (int)pev->framerate); // framerate
WRITE_BYTE( (int)(m_life*10.0) ); // life
WRITE_BYTE( m_boltWidth ); // width
WRITE_BYTE( m_noiseAmplitude ); // noise
WRITE_BYTE( (int)pev->rendercolor.x ); // r, g, b
WRITE_BYTE( (int)pev->rendercolor.y ); // r, g, b
WRITE_BYTE( (int)pev->rendercolor.z ); // r, g, b
WRITE_BYTE( pev->renderamt ); // brightness
WRITE_BYTE( m_speed ); // speed
MESSAGE_END();
#else
MESSAGE_BEGIN( MSG_BROADCAST, SVC_TEMPENTITY );
WRITE_BYTE(TE_LIGHTNING);
WRITE_COORD(vecSrc.x);
WRITE_COORD(vecSrc.y);
WRITE_COORD(vecSrc.z);
WRITE_COORD(vecDest.x);
WRITE_COORD(vecDest.y);
WRITE_COORD(vecDest.z);
WRITE_BYTE(10);
WRITE_BYTE(50);
WRITE_BYTE(40);
WRITE_SHORT(m_spriteTexture);
MESSAGE_END();
#endif
DoSparks( vecSrc, vecDest );
}
void CLightning::RandomArea( void )
{
int iLoops = 0;
for (iLoops = 0; iLoops < 10; iLoops++)
{
Vector vecSrc = pev->origin;
Vector vecDir1 = Vector( RANDOM_FLOAT( -1.0, 1.0 ), RANDOM_FLOAT( -1.0, 1.0 ),RANDOM_FLOAT( -1.0, 1.0 ) );
vecDir1 = vecDir1.Normalize();
TraceResult tr1;
UTIL_TraceLine( vecSrc, vecSrc + vecDir1 * m_radius, ignore_monsters, ENT(pev), &tr1 );
if (tr1.flFraction == 1.0)
continue;
Vector vecDir2;
do {
vecDir2 = Vector( RANDOM_FLOAT( -1.0, 1.0 ), RANDOM_FLOAT( -1.0, 1.0 ),RANDOM_FLOAT( -1.0, 1.0 ) );
} while (DotProduct(vecDir1, vecDir2 ) > 0);
vecDir2 = vecDir2.Normalize();
TraceResult tr2;
UTIL_TraceLine( vecSrc, vecSrc + vecDir2 * m_radius, ignore_monsters, ENT(pev), &tr2 );
if (tr2.flFraction == 1.0)
continue;
if ((tr1.vecEndPos - tr2.vecEndPos).Length() < m_radius * 0.1)
continue;
UTIL_TraceLine( tr1.vecEndPos, tr2.vecEndPos, ignore_monsters, ENT(pev), &tr2 );
if (tr2.flFraction != 1.0)
continue;
Zap( tr1.vecEndPos, tr2.vecEndPos );
break;
}
}
void CLightning::RandomPoint( Vector &vecSrc )
{
int iLoops = 0;
for (iLoops = 0; iLoops < 10; iLoops++)
{
Vector vecDir1 = Vector( RANDOM_FLOAT( -1.0, 1.0 ), RANDOM_FLOAT( -1.0, 1.0 ),RANDOM_FLOAT( -1.0, 1.0 ) );
vecDir1 = vecDir1.Normalize();
TraceResult tr1;
UTIL_TraceLine( vecSrc, vecSrc + vecDir1 * m_radius, ignore_monsters, ENT(pev), &tr1 );
if ((tr1.vecEndPos - vecSrc).Length() < m_radius * 0.1)
continue;
if (tr1.flFraction == 1.0)
continue;
Zap( vecSrc, tr1.vecEndPos );
break;
}
}
void CLightning::BeamUpdateVars( void )
{
int beamType;
int pointStart, pointEnd;
edict_t *pStart = FIND_ENTITY_BY_TARGETNAME ( NULL, STRING(m_iszStartEntity) );
edict_t *pEnd = FIND_ENTITY_BY_TARGETNAME ( NULL, STRING(m_iszEndEntity) );
pointStart = IsPointEntity( CBaseEntity::Instance(pStart) );
pointEnd = IsPointEntity( CBaseEntity::Instance(pEnd) );
pev->skin = 0;
pev->sequence = 0;
pev->rendermode = 0;
pev->flags |= FL_CUSTOMENTITY;
pev->model = m_iszSpriteName;
SetTexture( m_spriteTexture );
beamType = BEAM_ENTS;
if ( pointStart || pointEnd )
{
if ( !pointStart ) // One point entity must be in pStart
{
edict_t *pTemp;
// Swap start & end
pTemp = pStart;
pStart = pEnd;
pEnd = pTemp;
int swap = pointStart;
pointStart = pointEnd;
pointEnd = swap;
}
if ( !pointEnd )
beamType = BEAM_ENTPOINT;
else
beamType = BEAM_POINTS;
}
SetType( beamType );
if ( beamType == BEAM_POINTS || beamType == BEAM_ENTPOINT || beamType == BEAM_HOSE )
{
SetStartPos( pStart->v.origin );
if ( beamType == BEAM_POINTS || beamType == BEAM_HOSE )
SetEndPos( pEnd->v.origin );
else
SetEndEntity( ENTINDEX(pEnd) );
}
else
{
SetStartEntity( ENTINDEX(pStart) );
SetEndEntity( ENTINDEX(pEnd) );
}
RelinkBeam();
SetWidth( m_boltWidth );
SetNoise( m_noiseAmplitude );
SetFrame( m_frameStart );
SetScrollRate( m_speed );
if ( pev->spawnflags & SF_BEAM_SHADEIN )
SetFlags( BEAM_FSHADEIN );
else if ( pev->spawnflags & SF_BEAM_SHADEOUT )
SetFlags( BEAM_FSHADEOUT );
}
LINK_ENTITY_TO_CLASS( env_laser, CLaser );
TYPEDESCRIPTION CLaser::m_SaveData[] =
{
DEFINE_FIELD( CLaser, m_pSprite, FIELD_CLASSPTR ),
DEFINE_FIELD( CLaser, m_iszSpriteName, FIELD_STRING ),
DEFINE_FIELD( CLaser, m_firePosition, FIELD_POSITION_VECTOR ),
};
IMPLEMENT_SAVERESTORE( CLaser, CBeam );
void CLaser::Spawn( void )
{
if ( FStringNull( pev->model ) )
{
SetThink( SUB_Remove );
return;
}
pev->solid = SOLID_NOT; // Remove model & collisions
Precache( );
SetThink( StrikeThink );
pev->flags |= FL_CUSTOMENTITY;
PointsInit( pev->origin, pev->origin );
if ( !m_pSprite && m_iszSpriteName )
m_pSprite = CSprite::SpriteCreate( STRING(m_iszSpriteName), pev->origin, TRUE );
else
m_pSprite = NULL;
if ( m_pSprite )
m_pSprite->SetTransparency( kRenderGlow, pev->rendercolor.x, pev->rendercolor.y, pev->rendercolor.z, pev->renderamt, pev->renderfx );
if ( pev->targetname && !(pev->spawnflags & SF_BEAM_STARTON) )
TurnOff();
else
TurnOn();
}
void CLaser::Precache( void )
{
pev->modelindex = PRECACHE_MODEL( (char *)STRING(pev->model) );
if ( m_iszSpriteName )
PRECACHE_MODEL( (char *)STRING(m_iszSpriteName) );
}
void CLaser::KeyValue( KeyValueData *pkvd )
{
if (FStrEq(pkvd->szKeyName, "LaserTarget"))
{
pev->message = ALLOC_STRING( pkvd->szValue );
pkvd->fHandled = TRUE;
}
else if (FStrEq(pkvd->szKeyName, "width"))
{
SetWidth( atof(pkvd->szValue) );
pkvd->fHandled = TRUE;
}
else if (FStrEq(pkvd->szKeyName, "NoiseAmplitude"))
{
SetNoise( atoi(pkvd->szValue) );
pkvd->fHandled = TRUE;
}
else if (FStrEq(pkvd->szKeyName, "TextureScroll"))
{
SetScrollRate( atoi(pkvd->szValue) );
pkvd->fHandled = TRUE;
}
else if (FStrEq(pkvd->szKeyName, "texture"))
{
pev->model = ALLOC_STRING(pkvd->szValue);
pkvd->fHandled = TRUE;
}
else if (FStrEq(pkvd->szKeyName, "EndSprite"))
{
m_iszSpriteName = ALLOC_STRING(pkvd->szValue);
pkvd->fHandled = TRUE;
}
else if (FStrEq(pkvd->szKeyName, "framestart"))
{
pev->frame = atoi(pkvd->szValue);
pkvd->fHandled = TRUE;
}
else if (FStrEq(pkvd->szKeyName, "damage"))
{
pev->dmg = atof(pkvd->szValue);
pkvd->fHandled = TRUE;
}
else
CBeam::KeyValue( pkvd );
}
int CLaser::IsOn( void )
{
if (pev->effects & EF_NODRAW)
return 0;
return 1;
}
void CLaser::TurnOff( void )
{
pev->effects |= EF_NODRAW;
pev->nextthink = 0;
if ( m_pSprite )
m_pSprite->TurnOff();
}
void CLaser::TurnOn( void )
{
pev->effects &= ~EF_NODRAW;
if ( m_pSprite )
m_pSprite->TurnOn();
pev->dmgtime = gpGlobals->time;
pev->nextthink = gpGlobals->time;
}
void CLaser::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value )
{
int active = IsOn();
if ( !ShouldToggle( useType, active ) )
return;
if ( active )
{
TurnOff();
}
else
{
TurnOn();
}
}
void CLaser::FireAtPoint( TraceResult &tr )
{
SetEndPos( tr.vecEndPos );
if ( m_pSprite )
UTIL_SetOrigin( m_pSprite->pev, tr.vecEndPos );
BeamDamage( &tr );
DoSparks( GetStartPos(), tr.vecEndPos );
}
void CLaser::StrikeThink( void )
{
CBaseEntity *pEnd = RandomTargetname( STRING(pev->message) );
if ( pEnd )
m_firePosition = pEnd->pev->origin;
TraceResult tr;
UTIL_TraceLine( pev->origin, m_firePosition, dont_ignore_monsters, NULL, &tr );
FireAtPoint( tr );
pev->nextthink = gpGlobals->time + 0.1;
}
class CGlow : public CPointEntity
{
public:
void Spawn( void );
void Think( void );
void Animate( float frames );
virtual int Save( CSave &save );
virtual int Restore( CRestore &restore );
static TYPEDESCRIPTION m_SaveData[];
float m_lastTime;
float m_maxFrame;
};
LINK_ENTITY_TO_CLASS( env_glow, CGlow );
TYPEDESCRIPTION CGlow::m_SaveData[] =
{
DEFINE_FIELD( CGlow, m_lastTime, FIELD_TIME ),
DEFINE_FIELD( CGlow, m_maxFrame, FIELD_FLOAT ),
};
IMPLEMENT_SAVERESTORE( CGlow, CPointEntity );
void CGlow::Spawn( void )
{
pev->solid = SOLID_NOT;
pev->movetype = MOVETYPE_NONE;
pev->effects = 0;
pev->frame = 0;
PRECACHE_MODEL( (char *)STRING(pev->model) );
SET_MODEL( ENT(pev), STRING(pev->model) );
m_maxFrame = (float) MODEL_FRAMES( pev->modelindex ) - 1;
if ( m_maxFrame > 1.0 && pev->framerate != 0 )
pev->nextthink = gpGlobals->time + 0.1;
m_lastTime = gpGlobals->time;
}
void CGlow::Think( void )
{
Animate( pev->framerate * (gpGlobals->time - m_lastTime) );
pev->nextthink = gpGlobals->time + 0.1;
m_lastTime = gpGlobals->time;
}
void CGlow::Animate( float frames )
{
if ( m_maxFrame > 0 )
pev->frame = fmod( pev->frame + frames, m_maxFrame );
}
LINK_ENTITY_TO_CLASS( env_sprite, CSprite );
TYPEDESCRIPTION CSprite::m_SaveData[] =
{
DEFINE_FIELD( CSprite, m_lastTime, FIELD_TIME ),
DEFINE_FIELD( CSprite, m_maxFrame, FIELD_FLOAT ),
};
IMPLEMENT_SAVERESTORE( CSprite, CPointEntity );
void CSprite::Spawn( void )
{
pev->solid = SOLID_NOT;
pev->movetype = MOVETYPE_NONE;
pev->effects = 0;
pev->frame = 0;
Precache();
SET_MODEL( ENT(pev), STRING(pev->model) );
m_maxFrame = (float) MODEL_FRAMES( pev->modelindex ) - 1;
if ( pev->targetname && !(pev->spawnflags & SF_SPRITE_STARTON) )
TurnOff();
else
TurnOn();
// Worldcraft only sets y rotation, copy to Z
if ( pev->angles.y != 0 && pev->angles.z == 0 )
{
pev->angles.z = pev->angles.y;
pev->angles.y = 0;
}
}
void CSprite::Precache( void )
{
PRECACHE_MODEL( (char *)STRING(pev->model) );
// Reset attachment after save/restore
if ( pev->aiment )
SetAttachment( pev->aiment, pev->body );
else
{
// Clear attachment
pev->skin = 0;
pev->body = 0;
}
}
void CSprite::SpriteInit( const char *pSpriteName, const Vector &origin )
{
pev->model = MAKE_STRING(pSpriteName);
pev->origin = origin;
Spawn();
}
CSprite *CSprite::SpriteCreate( const char *pSpriteName, const Vector &origin, BOOL animate )
{
CSprite *pSprite = GetClassPtr( (CSprite *)NULL );
pSprite->SpriteInit( pSpriteName, origin );
pSprite->pev->classname = MAKE_STRING("env_sprite");
pSprite->pev->solid = SOLID_NOT;
pSprite->pev->movetype = MOVETYPE_NOCLIP;
if ( animate )
pSprite->TurnOn();
return pSprite;
}
void CSprite::AnimateThink( void )
{
Animate( pev->framerate * (gpGlobals->time - m_lastTime) );
pev->nextthink = gpGlobals->time + 0.1;
m_lastTime = gpGlobals->time;
}
void CSprite::AnimateUntilDead( void )
{
if ( gpGlobals->time > pev->dmgtime )
UTIL_Remove(this);
else
{
AnimateThink();
pev->nextthink = gpGlobals->time;
}
}
void CSprite::Expand( float scaleSpeed, float fadeSpeed )
{
pev->speed = scaleSpeed;
pev->health = fadeSpeed;
SetThink( ExpandThink );
pev->nextthink = gpGlobals->time;
m_lastTime = gpGlobals->time;
}
void CSprite::ExpandThink( void )
{
float frametime = gpGlobals->time - m_lastTime;
pev->scale += pev->speed * frametime;
pev->renderamt -= pev->health * frametime;
if ( pev->renderamt <= 0 )
{
pev->renderamt = 0;
UTIL_Remove( this );
}
else
{
pev->nextthink = gpGlobals->time + 0.1;
m_lastTime = gpGlobals->time;
}
}
void CSprite::Animate( float frames )
{
pev->frame += frames;
if ( pev->frame > m_maxFrame )
{
if ( pev->spawnflags & SF_SPRITE_ONCE )
{
TurnOff();
}
else
{
if ( m_maxFrame > 0 )
pev->frame = fmod( pev->frame, m_maxFrame );
}
}
}
void CSprite::TurnOff( void )
{
pev->effects = EF_NODRAW;
pev->nextthink = 0;
}
void CSprite::TurnOn( void )
{
pev->effects = 0;
if ( (pev->framerate && m_maxFrame > 1.0) || (pev->spawnflags & SF_SPRITE_ONCE) )
{
SetThink( AnimateThink );
pev->nextthink = gpGlobals->time;
m_lastTime = gpGlobals->time;
}
pev->frame = 0;
}
void CSprite::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value )
{
int on = pev->effects != EF_NODRAW;
if ( ShouldToggle( useType, on ) )
{
if ( on )
{
TurnOff();
}
else
{
TurnOn();
}
}
}
class CGibShooter : public CBaseDelay
{
public:
void Spawn( void );
void Precache( void );
void KeyValue( KeyValueData *pkvd );
void EXPORT ShootThink( void );
void Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value );
virtual CGib *CreateGib( void );
virtual int Save( CSave &save );
virtual int Restore( CRestore &restore );
static TYPEDESCRIPTION m_SaveData[];
int m_iGibs;
int m_iGibCapacity;
int m_iGibMaterial;
int m_iGibModelIndex;
float m_flGibVelocity;
float m_flVariance;
float m_flGibLife;
};
TYPEDESCRIPTION CGibShooter::m_SaveData[] =
{
DEFINE_FIELD( CGibShooter, m_iGibs, FIELD_INTEGER ),
DEFINE_FIELD( CGibShooter, m_iGibCapacity, FIELD_INTEGER ),
DEFINE_FIELD( CGibShooter, m_iGibMaterial, FIELD_INTEGER ),
DEFINE_FIELD( CGibShooter, m_iGibModelIndex, FIELD_INTEGER ),
DEFINE_FIELD( CGibShooter, m_flGibVelocity, FIELD_FLOAT ),
DEFINE_FIELD( CGibShooter, m_flVariance, FIELD_FLOAT ),
DEFINE_FIELD( CGibShooter, m_flGibLife, FIELD_FLOAT ),
};
IMPLEMENT_SAVERESTORE( CGibShooter, CBaseDelay );
LINK_ENTITY_TO_CLASS( gibshooter, CGibShooter );
void CGibShooter :: Precache ( void )
{
if ( g_Language == LANGUAGE_GERMAN )
{
m_iGibModelIndex = PRECACHE_MODEL ("models/germanygibs.mdl");
}
else
{
m_iGibModelIndex = PRECACHE_MODEL ("models/hgibs.mdl");
}
}
void CGibShooter::KeyValue( KeyValueData *pkvd )
{
if (FStrEq(pkvd->szKeyName, "m_iGibs"))
{
m_iGibs = m_iGibCapacity = atoi(pkvd->szValue);
pkvd->fHandled = TRUE;
}
else if (FStrEq(pkvd->szKeyName, "m_flVelocity"))
{
m_flGibVelocity = atof(pkvd->szValue);
pkvd->fHandled = TRUE;
}
else if (FStrEq(pkvd->szKeyName, "m_flVariance"))
{
m_flVariance = atof(pkvd->szValue);
pkvd->fHandled = TRUE;
}
else if (FStrEq(pkvd->szKeyName, "m_flGibLife"))
{
m_flGibLife = atof(pkvd->szValue);
pkvd->fHandled = TRUE;
}
else
{
CBaseDelay::KeyValue( pkvd );
}
}
void CGibShooter::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value )
{
SetThink( ShootThink );
pev->nextthink = gpGlobals->time;
}
void CGibShooter::Spawn( void )
{
Precache();
pev->solid = SOLID_NOT;
pev->effects = EF_NODRAW;
if ( m_flDelay == 0 )
{
m_flDelay = 0.1;
}
if ( m_flGibLife == 0 )
{
m_flGibLife = 25;
}
SetMovedir ( pev );
pev->body = MODEL_FRAMES( m_iGibModelIndex );
}
CGib *CGibShooter :: CreateGib ( void )
{
if ( CVAR_GET_FLOAT("violence_hgibs") == 0 )
return NULL;
CGib *pGib = GetClassPtr( (CGib *)NULL );
pGib->Spawn( "models/hgibs.mdl" );
pGib->m_bloodColor = BLOOD_COLOR_RED;
if ( pev->body <= 1 )
{
ALERT ( at_aiconsole, "GibShooter Body is <= 1!\n" );
}
pGib->pev->body = RANDOM_LONG ( 1, pev->body - 1 );// avoid throwing random amounts of the 0th gib. (skull).
return pGib;
}
void CGibShooter :: ShootThink ( void )
{
pev->nextthink = gpGlobals->time + m_flDelay;
Vector vecShootDir;
vecShootDir = pev->movedir;
vecShootDir = vecShootDir + gpGlobals->v_right * RANDOM_FLOAT( -1, 1) * m_flVariance;;
vecShootDir = vecShootDir + gpGlobals->v_forward * RANDOM_FLOAT( -1, 1) * m_flVariance;;
vecShootDir = vecShootDir + gpGlobals->v_up * RANDOM_FLOAT( -1, 1) * m_flVariance;;
vecShootDir = vecShootDir.Normalize();
CGib *pGib = CreateGib();
if ( pGib )
{
pGib->pev->origin = pev->origin;
pGib->pev->velocity = vecShootDir * m_flGibVelocity;
pGib->pev->avelocity.x = RANDOM_FLOAT ( 100, 200 );
pGib->pev->avelocity.y = RANDOM_FLOAT ( 100, 300 );
float thinkTime = pGib->pev->nextthink - gpGlobals->time;
pGib->m_lifeTime = (m_flGibLife * RANDOM_FLOAT( 0.95, 1.05 )); // +/- 5%
if ( pGib->m_lifeTime < thinkTime )
{
pGib->pev->nextthink = gpGlobals->time + pGib->m_lifeTime;
pGib->m_lifeTime = 0;
}
}
if ( --m_iGibs <= 0 )
{
if ( pev->spawnflags & SF_GIBSHOOTER_REPEATABLE )
{
m_iGibs = m_iGibCapacity;
SetThink ( NULL );
pev->nextthink = gpGlobals->time;
}
else
{
SetThink ( SUB_Remove );
pev->nextthink = gpGlobals->time;
}
}
}
class CEnvShooter : public CGibShooter
{
void Precache( void );
void KeyValue( KeyValueData *pkvd );
CGib *CreateGib( void );
};
LINK_ENTITY_TO_CLASS( env_shooter, CEnvShooter );
void CEnvShooter :: KeyValue( KeyValueData *pkvd )
{
if (FStrEq(pkvd->szKeyName, "shootmodel"))
{
pev->model = ALLOC_STRING(pkvd->szValue);
pkvd->fHandled = TRUE;
}
else if (FStrEq(pkvd->szKeyName, "shootsounds"))
{
int iNoise = atoi(pkvd->szValue);
pkvd->fHandled = TRUE;
switch( iNoise )
{
case 0:
m_iGibMaterial = matGlass;
break;
case 1:
m_iGibMaterial = matWood;
break;
case 2:
m_iGibMaterial = matMetal;
break;
case 3:
m_iGibMaterial = matFlesh;
break;
case 4:
m_iGibMaterial = matRocks;
break;
default:
case -1:
m_iGibMaterial = matNone;
break;
}
}
else
{
CGibShooter::KeyValue( pkvd );
}
}
void CEnvShooter :: Precache ( void )
{
m_iGibModelIndex = PRECACHE_MODEL( (char *)STRING(pev->model) );
CBreakable::MaterialSoundPrecache( (Materials)m_iGibMaterial );
}
CGib *CEnvShooter :: CreateGib ( void )
{
CGib *pGib = GetClassPtr( (CGib *)NULL );
pGib->Spawn( STRING(pev->model) );
int bodyPart = 0;
if ( pev->body > 1 )
bodyPart = RANDOM_LONG( 0, pev->body-1 );
pGib->pev->body = bodyPart;
pGib->m_bloodColor = DONT_BLEED;
pGib->m_material = m_iGibMaterial;
pGib->pev->rendermode = pev->rendermode;
pGib->pev->renderamt = pev->renderamt;
pGib->pev->rendercolor = pev->rendercolor;
pGib->pev->renderfx = pev->renderfx;
pGib->pev->scale = pev->scale;
pGib->pev->skin = pev->skin;
return pGib;
}
class CTestEffect : public CBaseDelay
{
public:
void Spawn( void );
void Precache( void );
// void KeyValue( KeyValueData *pkvd );
void EXPORT TestThink( void );
void Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value );
int m_iLoop;
int m_iBeam;
CBeam *m_pBeam[24];
float m_flBeamTime[24];
float m_flStartTime;
};
LINK_ENTITY_TO_CLASS( test_effect, CTestEffect );
void CTestEffect::Spawn( void )
{
Precache( );
}
void CTestEffect::Precache( void )
{
PRECACHE_MODEL( "sprites/lgtning.spr" );
}
void CTestEffect::TestThink( void )
{
int i;
float t = (gpGlobals->time - m_flStartTime);
if (m_iBeam < 24)
{
CBeam *pbeam = CBeam::BeamCreate( "sprites/lgtning.spr", 100 );
TraceResult tr;
Vector vecSrc = pev->origin;
Vector vecDir = Vector( RANDOM_FLOAT( -1.0, 1.0 ), RANDOM_FLOAT( -1.0, 1.0 ),RANDOM_FLOAT( -1.0, 1.0 ) );
vecDir = vecDir.Normalize();
UTIL_TraceLine( vecSrc, vecSrc + vecDir * 128, ignore_monsters, ENT(pev), &tr);
pbeam->PointsInit( vecSrc, tr.vecEndPos );
// pbeam->SetColor( 80, 100, 255 );
pbeam->SetColor( 255, 180, 100 );
pbeam->SetWidth( 100 );
pbeam->SetScrollRate( 12 );
m_flBeamTime[m_iBeam] = gpGlobals->time;
m_pBeam[m_iBeam] = pbeam;
m_iBeam++;
#if 0
Vector vecMid = (vecSrc + tr.vecEndPos) * 0.5;
MESSAGE_BEGIN( MSG_BROADCAST, SVC_TEMPENTITY );
WRITE_BYTE(TE_DLIGHT);
WRITE_COORD(vecMid.x); // X
WRITE_COORD(vecMid.y); // Y
WRITE_COORD(vecMid.z); // Z
WRITE_BYTE( 20 ); // radius * 0.1
WRITE_BYTE( 255 ); // r
WRITE_BYTE( 180 ); // g
WRITE_BYTE( 100 ); // b
WRITE_BYTE( 20 ); // time * 10
WRITE_BYTE( 0 ); // decay * 0.1
MESSAGE_END( );
#endif
}
if (t < 3.0)
{
for (i = 0; i < m_iBeam; i++)
{
t = (gpGlobals->time - m_flBeamTime[i]) / ( 3 + m_flStartTime - m_flBeamTime[i]);
m_pBeam[i]->SetBrightness( 255 * t );
// m_pBeam[i]->SetScrollRate( 20 * t );
}
pev->nextthink = gpGlobals->time + 0.1;
}
else
{
for (i = 0; i < m_iBeam; i++)
{
UTIL_Remove( m_pBeam[i] );
}
m_flStartTime = gpGlobals->time;
m_iBeam = 0;
// pev->nextthink = gpGlobals->time;
SetThink( NULL );
}
}
void CTestEffect::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value )
{
SetThink( TestThink );
pev->nextthink = gpGlobals->time + 0.1;
m_flStartTime = gpGlobals->time;
}
// Blood effects
class CBlood : public CPointEntity
{
public:
void Spawn( void );
void Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value );
void KeyValue( KeyValueData *pkvd );
inline int Color( void ) { return pev->impulse; }
inline float BloodAmount( void ) { return pev->dmg; }
inline void SetColor( int color ) { pev->impulse = color; }
inline void SetBloodAmount( float amount ) { pev->dmg = amount; }
Vector Direction( void );
Vector BloodPosition( CBaseEntity *pActivator );
private:
};
LINK_ENTITY_TO_CLASS( env_blood, CBlood );
#define SF_BLOOD_RANDOM 0x0001
#define SF_BLOOD_STREAM 0x0002
#define SF_BLOOD_PLAYER 0x0004
#define SF_BLOOD_DECAL 0x0008
void CBlood::Spawn( void )
{
pev->solid = SOLID_NOT;
pev->movetype = MOVETYPE_NONE;
pev->effects = 0;
pev->frame = 0;
SetMovedir( pev );
}
void CBlood::KeyValue( KeyValueData *pkvd )
{
if (FStrEq(pkvd->szKeyName, "color"))
{
int color = atoi(pkvd->szValue);
switch( color )
{
case 1:
SetColor( BLOOD_COLOR_YELLOW );
break;
default:
SetColor( BLOOD_COLOR_RED );
break;
}
pkvd->fHandled = TRUE;
}
else if (FStrEq(pkvd->szKeyName, "amount"))
{
SetBloodAmount( atof(pkvd->szValue) );
pkvd->fHandled = TRUE;
}
else
CPointEntity::KeyValue( pkvd );
}
Vector CBlood::Direction( void )
{
if ( pev->spawnflags & SF_BLOOD_RANDOM )
return UTIL_RandomBloodVector();
return pev->movedir;
}
Vector CBlood::BloodPosition( CBaseEntity *pActivator )
{
if ( pev->spawnflags & SF_BLOOD_PLAYER )
{
edict_t *pPlayer;
if ( pActivator && pActivator->IsPlayer() )
{
pPlayer = pActivator->edict();
}
else
pPlayer = g_engfuncs.pfnPEntityOfEntIndex( 1 );
if ( pPlayer )
return (pPlayer->v.origin + pPlayer->v.view_ofs) + Vector( RANDOM_FLOAT(-10,10), RANDOM_FLOAT(-10,10), RANDOM_FLOAT(-10,10) );
}
return pev->origin;
}
void CBlood::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value )
{
if ( pev->spawnflags & SF_BLOOD_STREAM )
UTIL_BloodStream( BloodPosition(pActivator), Direction(), (Color() == BLOOD_COLOR_RED) ? 70 : Color(), BloodAmount() );
else
UTIL_BloodDrips( BloodPosition(pActivator), Direction(), Color(), BloodAmount() );
if ( pev->spawnflags & SF_BLOOD_DECAL )
{
Vector forward = Direction();
Vector start = BloodPosition( pActivator );
TraceResult tr;
UTIL_TraceLine( start, start + forward * BloodAmount() * 2, ignore_monsters, NULL, &tr );
if ( tr.flFraction != 1.0 )
UTIL_BloodDecalTrace( &tr, Color() );
}
}
// Screen shake
class CShake : public CPointEntity
{
public:
void Spawn( void );
void Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value );
void KeyValue( KeyValueData *pkvd );
inline float Amplitude( void ) { return pev->scale; }
inline float Frequency( void ) { return pev->dmg_save; }
inline float Duration( void ) { return pev->dmg_take; }
inline float Radius( void ) { return pev->dmg; }
inline void SetAmplitude( float amplitude ) { pev->scale = amplitude; }
inline void SetFrequency( float frequency ) { pev->dmg_save = frequency; }
inline void SetDuration( float duration ) { pev->dmg_take = duration; }
inline void SetRadius( float radius ) { pev->dmg = radius; }
private:
};
LINK_ENTITY_TO_CLASS( env_shake, CShake );
// pev->scale is amplitude
// pev->dmg_save is frequency
// pev->dmg_take is duration
// pev->dmg is radius
// radius of 0 means all players
// NOTE: UTIL_ScreenShake() will only shake players who are on the ground
#define SF_SHAKE_EVERYONE 0x0001 // Don't check radius
// UNDONE: These don't work yet
#define SF_SHAKE_DISRUPT 0x0002 // Disrupt controls
#define SF_SHAKE_INAIR 0x0004 // Shake players in air
void CShake::Spawn( void )
{
pev->solid = SOLID_NOT;
pev->movetype = MOVETYPE_NONE;
pev->effects = 0;
pev->frame = 0;
if ( pev->spawnflags & SF_SHAKE_EVERYONE )
pev->dmg = 0;
}
void CShake::KeyValue( KeyValueData *pkvd )
{
if (FStrEq(pkvd->szKeyName, "amplitude"))
{
SetAmplitude( atof(pkvd->szValue) );
pkvd->fHandled = TRUE;
}
else if (FStrEq(pkvd->szKeyName, "frequency"))
{
SetFrequency( atof(pkvd->szValue) );
pkvd->fHandled = TRUE;
}
else if (FStrEq(pkvd->szKeyName, "duration"))
{
SetDuration( atof(pkvd->szValue) );
pkvd->fHandled = TRUE;
}
else if (FStrEq(pkvd->szKeyName, "radius"))
{
SetRadius( atof(pkvd->szValue) );
pkvd->fHandled = TRUE;
}
else
CPointEntity::KeyValue( pkvd );
}
void CShake::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value )
{
UTIL_ScreenShake( pev->origin, Amplitude(), Frequency(), Duration(), Radius() );
}
class CFade : public CPointEntity
{
public:
void Spawn( void );
void Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value );
void KeyValue( KeyValueData *pkvd );
inline float Duration( void ) { return pev->dmg_take; }
inline float HoldTime( void ) { return pev->dmg_save; }
inline void SetDuration( float duration ) { pev->dmg_take = duration; }
inline void SetHoldTime( float hold ) { pev->dmg_save = hold; }
private:
};
LINK_ENTITY_TO_CLASS( env_fade, CFade );
// pev->dmg_take is duration
// pev->dmg_save is hold duration
#define SF_FADE_IN 0x0001 // Fade in, not out
#define SF_FADE_MODULATE 0x0002 // Modulate, don't blend
#define SF_FADE_ONLYONE 0x0004
void CFade::Spawn( void )
{
pev->solid = SOLID_NOT;
pev->movetype = MOVETYPE_NONE;
pev->effects = 0;
pev->frame = 0;
}
void CFade::KeyValue( KeyValueData *pkvd )
{
if (FStrEq(pkvd->szKeyName, "duration"))
{
SetDuration( atof(pkvd->szValue) );
pkvd->fHandled = TRUE;
}
else if (FStrEq(pkvd->szKeyName, "holdtime"))
{
SetHoldTime( atof(pkvd->szValue) );
pkvd->fHandled = TRUE;
}
else
CPointEntity::KeyValue( pkvd );
}
void CFade::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value )
{
int fadeFlags = 0;
if ( !(pev->spawnflags & SF_FADE_IN) )
fadeFlags |= FFADE_OUT;
if ( pev->spawnflags & SF_FADE_MODULATE )
fadeFlags |= FFADE_MODULATE;
if ( pev->spawnflags & SF_FADE_ONLYONE )
{
if ( pActivator->IsNetClient() )
{
UTIL_ScreenFade( pActivator, pev->rendercolor, Duration(), HoldTime(), pev->renderamt, fadeFlags );
}
}
else
{
UTIL_ScreenFadeAll( pev->rendercolor, Duration(), HoldTime(), pev->renderamt, fadeFlags );
}
SUB_UseTargets( this, USE_TOGGLE, 0 );
}
class CMessage : public CPointEntity
{
public:
void Spawn( void );
void Precache( void );
void Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value );
void KeyValue( KeyValueData *pkvd );
private:
};
LINK_ENTITY_TO_CLASS( env_message, CMessage );
void CMessage::Spawn( void )
{
Precache();
pev->solid = SOLID_NOT;
pev->movetype = MOVETYPE_NONE;
switch( pev->impulse )
{
case 1: // Medium radius
pev->speed = ATTN_STATIC;
break;
case 2: // Large radius
pev->speed = ATTN_NORM;
break;
case 3: //EVERYWHERE
pev->speed = ATTN_NONE;
break;
default:
case 0: // Small radius
pev->speed = ATTN_IDLE;
break;
}
pev->impulse = 0;
// No volume, use normal
if ( pev->scale <= 0 )
pev->scale = 1.0;
}
void CMessage::Precache( void )
{
if ( pev->noise )
PRECACHE_SOUND( (char *)STRING(pev->noise) );
}
void CMessage::KeyValue( KeyValueData *pkvd )
{
if (FStrEq(pkvd->szKeyName, "messagesound"))
{
pev->noise = ALLOC_STRING(pkvd->szValue);
pkvd->fHandled = TRUE;
}
else if (FStrEq(pkvd->szKeyName, "messagevolume"))
{
pev->scale = atof(pkvd->szValue) * 0.1;
pkvd->fHandled = TRUE;
}
else if (FStrEq(pkvd->szKeyName, "messageattenuation"))
{
pev->impulse = atoi(pkvd->szValue);
pkvd->fHandled = TRUE;
}
else
CPointEntity::KeyValue( pkvd );
}
void CMessage::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value )
{
CBaseEntity *pPlayer = NULL;
if ( pev->spawnflags & SF_MESSAGE_ALL )
UTIL_ShowMessageAll( STRING(pev->message) );
else
{
if ( pActivator && pActivator->IsPlayer() )
pPlayer = pActivator;
else
{
pPlayer = CBaseEntity::Instance( g_engfuncs.pfnPEntityOfEntIndex( 1 ) );
}
if ( pPlayer )
UTIL_ShowMessage( STRING(pev->message), pPlayer );
}
if ( pev->noise )
{
EMIT_SOUND( edict(), CHAN_BODY, STRING(pev->noise), pev->scale, pev->speed );
}
if ( pev->spawnflags & SF_MESSAGE_ONCE )
UTIL_Remove( this );
SUB_UseTargets( this, USE_TOGGLE, 0 );
}
//=========================================================
// FunnelEffect
//=========================================================
class CEnvFunnel : public CBaseDelay
{
public:
void Spawn( void );
void Precache( void );
void Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value );
int m_iSprite; // Don't save, precache
};
void CEnvFunnel :: Precache ( void )
{
m_iSprite = PRECACHE_MODEL ( "sprites/flare6.spr" );
}
LINK_ENTITY_TO_CLASS( env_funnel, CEnvFunnel );
void CEnvFunnel::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value )
{
MESSAGE_BEGIN( MSG_BROADCAST, SVC_TEMPENTITY );
WRITE_BYTE( TE_LARGEFUNNEL );
WRITE_COORD( pev->origin.x );
WRITE_COORD( pev->origin.y );
WRITE_COORD( pev->origin.z );
WRITE_SHORT( m_iSprite );
if ( pev->spawnflags & SF_FUNNEL_REVERSE )// funnel flows in reverse?
{
WRITE_SHORT( 1 );
}
else
{
WRITE_SHORT( 0 );
}
MESSAGE_END();
SetThink( SUB_Remove );
pev->nextthink = gpGlobals->time;
}
void CEnvFunnel::Spawn( void )
{
Precache();
pev->solid = SOLID_NOT;
pev->effects = EF_NODRAW;
}
//=========================================================
// Beverage Dispenser
// overloaded pev->frags, is now a flag for whether or not a can is stuck in the dispenser.
// overloaded pev->health, is now how many cans remain in the machine.
//=========================================================
class CEnvBeverage : public CBaseDelay
{
public:
void Spawn( void );
void Precache( void );
void Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value );
};
void CEnvBeverage :: Precache ( void )
{
PRECACHE_MODEL( "models/can.mdl" );
PRECACHE_SOUND( "weapons/g_bounce3.wav" );
}
LINK_ENTITY_TO_CLASS( env_beverage, CEnvBeverage );
void CEnvBeverage::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value )
{
if ( pev->frags != 0 || pev->health <= 0 )
{
// no more cans while one is waiting in the dispenser, or if I'm out of cans.
return;
}
CBaseEntity *pCan = CBaseEntity::Create( "item_sodacan", pev->origin, pev->angles, edict() );
if ( pev->skin == 6 )
{
// random
pCan->pev->skin = RANDOM_LONG( 0, 5 );
}
else
{
pCan->pev->skin = pev->skin;
}
pev->frags = 1;
pev->health--;
//SetThink (SUB_Remove);
//pev->nextthink = gpGlobals->time;
}
void CEnvBeverage::Spawn( void )
{
Precache();
pev->solid = SOLID_NOT;
pev->effects = EF_NODRAW;
pev->frags = 0;
if ( pev->health == 0 )
{
pev->health = 10;
}
}
//=========================================================
// Soda can
//=========================================================
class CItemSoda : public CBaseEntity
{
public:
void Spawn( void );
void Precache( void );
void EXPORT CanThink ( void );
void EXPORT CanTouch ( CBaseEntity *pOther );
};
void CItemSoda :: Precache ( void )
{
}
LINK_ENTITY_TO_CLASS( item_sodacan, CItemSoda );
void CItemSoda::Spawn( void )
{
Precache();
pev->solid = SOLID_NOT;
pev->movetype = MOVETYPE_TOSS;
SET_MODEL ( ENT(pev), "models/can.mdl" );
UTIL_SetSize ( pev, Vector ( 0, 0, 0 ), Vector ( 0, 0, 0 ) );
SetThink (CanThink);
pev->nextthink = gpGlobals->time + 0.5;
}
void CItemSoda::CanThink ( void )
{
EMIT_SOUND (ENT(pev), CHAN_WEAPON, "weapons/g_bounce3.wav", 1, ATTN_NORM );
pev->solid = SOLID_TRIGGER;
UTIL_SetSize ( pev, Vector ( -8, -8, 0 ), Vector ( 8, 8, 8 ) );
SetThink ( NULL );
SetTouch ( CanTouch );
}
void CItemSoda::CanTouch ( CBaseEntity *pOther )
{
if ( !pOther->IsPlayer() )
{
return;
}
// spoit sound here
pOther->TakeHealth( 1, DMG_GENERIC );// a bit of health.
if ( !FNullEnt( pev->owner ) )
{
// tell the machine the can was taken
pev->owner->v.frags = 0;
}
pev->solid = SOLID_NOT;
pev->movetype = MOVETYPE_NONE;
pev->effects = EF_NODRAW;
SetTouch ( NULL );
SetThink ( SUB_Remove );
pev->nextthink = gpGlobals->time;
}
| [
"joropito@23c7d628-c96c-11de-a380-73d83ba7c083"
]
| [
[
[
1,
2268
]
]
]
|
78aba2452772ac990daabb52a57825c9fbcb4723 | 5ff30d64df43c7438bbbcfda528b09bb8fec9e6b | /kcore/sys/DateTime.cpp | 26b11d60229aa3fd73f6a210b27537dbbad17e22 | []
| no_license | lvtx/gamekernel | c80cdb4655f6d4930a7d035a5448b469ac9ae924 | a84d9c268590a294a298a4c825d2dfe35e6eca21 | refs/heads/master | 2016-09-06T18:11:42.702216 | 2011-09-27T07:22:08 | 2011-09-27T07:22:08 | 38,255,025 | 3 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 21,303 | cpp | #include "stdafx.h"
#include <kcore/corebase.h>
#include <kcore/sys/DateTime.h>
#include <time.h>
namespace gk {
#define LLABS(i) (((i)<0)?-(i):(i))
#define MAX_TIME_BUFFER_SIZE 128
// Constant array with months # of days of year
int DateTime::anMonthDayInYear[13] = {0, 31, 59, 90, 120, 151, 181,
212, 243, 273, 304, 334, 365};
// Static member for getting the current time
const DateTime
DateTime::GetPresentTime()
{
SYSTEMTIME systime;
::GetLocalTime(&systime);
return DateTime(systime);
} // DateTime::GetPresentTime()
DateTime::DateTime(int nYear, int nMonth, int nDay,
int nHour, int nMinute, int nSecond,
int nMilli , int nMicro ,int nNano)
// nMilli, nMicro & nNano default = 0
{
_TimeFormat SrcTime;
SrcTime.nYear = nYear;
SrcTime.nMonth = nMonth;
SrcTime.nDay = nDay;
SrcTime.nHour = nHour;
SrcTime.nMinute = nMinute;
SrcTime.nSecond = nSecond;
SrcTime.nMilli = nMilli;
SrcTime.nMicro = nMicro;
SrcTime.nNano = nNano;
status_ = convertTimeToLongLong(SrcTime, time_) ? valid : invalid;
}
const DateTime&
DateTime::operator=(const SYSTEMTIME& systimeSrc)
{
_TimeFormat SrcTime;
SrcTime.nYear = systimeSrc.wYear;
SrcTime.nMonth = systimeSrc.wMonth;
SrcTime.nDay = systimeSrc.wDay;
SrcTime.nHour = systimeSrc.wHour;
SrcTime.nMinute = systimeSrc.wMinute;
SrcTime.nSecond = systimeSrc.wSecond;
SrcTime.nMilli = systimeSrc.wMilliseconds;
SrcTime.nMicro = 0;
SrcTime.nNano = 0;
status_ = convertTimeToLongLong(SrcTime, time_) ? valid : invalid;
return *this;
}
const DateTime&
DateTime::operator=(const FILETIME& filetimeSrc)
{
SYSTEMTIME systime;
if (FileTimeToSystemTime(&filetimeSrc, &systime)) {
_TimeFormat SrcTime;
SrcTime.nYear = systime.wYear;
SrcTime.nMonth = systime.wMonth;
SrcTime.nDay = systime.wDay;
SrcTime.nHour = systime.wHour;
SrcTime.nMinute = systime.wMinute;
SrcTime.nSecond = systime.wSecond;
SrcTime.nMilli = systime.wMilliseconds;
SrcTime.nMicro = 0;
SrcTime.nNano = 0;
status_ = convertTimeToLongLong(SrcTime, time_) ? valid : invalid;
}
else {
SetStatus(invalid);
}
return *this;
}
int
DateTime::SetDateTime(int nYear, int nMonth, int nDay,
int nHour, int nMinute, int nSecond,
int nMilli, int nMicro, int nNano)
{
_TimeFormat SrcTime;
SrcTime.nYear = nYear;
SrcTime.nMonth = nMonth;
SrcTime.nDay = nDay;
SrcTime.nHour = nHour;
SrcTime.nMinute = nMinute;
SrcTime.nSecond = nSecond;
SrcTime.nMilli = nMilli;
SrcTime.nMicro = nMicro;
SrcTime.nNano = nNano;
return (status_ = convertTimeToLongLong(SrcTime, time_) ? valid : invalid) == valid;
}
void
DateTime::Reset()
{
*this = GetPresentTime();
}
// HighTime helper function, static function
BOOL
DateTime::convertTimeToLongLong(const _TimeFormat &SrcTime,
LARGE_INTEGER &liDestTime)
{
LARGE_INTEGER nDate;
int iDays = SrcTime.nDay;
UINT nHour = SrcTime.nHour;
UINT nMinute = SrcTime.nMinute;
UINT nSecond = SrcTime.nSecond;
UINT nMilliSecond = SrcTime.nMilli;
UINT nMicroSecond = SrcTime.nMicro;
UINT nHundredsNano = (SrcTime.nNano +50) / 100;
// Validate year and month
if (SrcTime.nYear > 29000 || SrcTime.nYear < -29000 ||
SrcTime.nMonth < 1 || SrcTime.nMonth > 12)
return FALSE;
// Check for leap year
BOOL bIsLeapYear = ((SrcTime.nYear & 3) == 0) &&
((SrcTime.nYear % 100) != 0 || (SrcTime.nYear % 400) == 0);
/*int nDaysInMonth =
anMonthDayInYear[SrcTime.nMonth] - anMonthDayInYear[SrcTime.nMonth-1] +
((bIsLeapYear && SrcTime.nDay == 29 && SrcTime.nMonth == 2) ? 1 : 0);*/
// Adjust time and frac time
nMicroSecond += nHundredsNano / 10;
nHundredsNano %= 10;
nMilliSecond += nMicroSecond / 1000;
nMicroSecond %= 1000;
nSecond +=nMilliSecond / 1000;
nMilliSecond %= 1000;
nMinute += nSecond / 60;
nSecond %= 60;
nHour += nMinute / 60;
nMinute %= 60;
iDays += nHour / 24;
nHour %= 24;
//It is a valid date; make Jan 1, 1AD be 1
nDate.QuadPart = SrcTime.nYear*365L + SrcTime.nYear/4 - SrcTime.nYear/100 + SrcTime.nYear/400 +
anMonthDayInYear[SrcTime.nMonth-1] + iDays;
// If leap year and it's before March, subtract 1:
if (SrcTime.nMonth <= 2 && bIsLeapYear)
--nDate.QuadPart;
// Offset so that 01/01/1601 is 0
nDate.QuadPart -= 584754L;
// Change nDate to seconds
nDate.QuadPart *= 86400L;
nDate.QuadPart += (nHour * 3600L) + (nMinute * 60L) + nSecond;
// Change nDate to hundreds of nanoseconds
nDate.QuadPart *= 10000000L;
nDate.QuadPart += (nMilliSecond * 10000L) + (nMicroSecond * 10L) + nHundredsNano;
liDestTime = nDate;
return TRUE;
}
BOOL
DateTime::convertLongLongToTime(const LARGE_INTEGER &liSrcTime,
_TimeFormat &DestTime)
{
LARGE_INTEGER nTempTime;
long nDaysAbsolute; // Number of days since 1/1/0
long nSecsInDay; // Time in seconds since midnight
long nMinutesInDay; // Minutes in day
long n400Years; // Number of 400 year increments since 1/1/0
long n400Century; // Century within 400 year block (0,1,2 or 3)
long n4Years; // Number of 4 year increments since 1/1/0
long n4Day; // Day within 4 year block
// (0 is 1/1/yr1, 1460 is 12/31/yr4)
long n4Yr; // Year within 4 year block (0,1,2 or 3)
BOOL bLeap4 = TRUE; // TRUE if 4 year block includes leap year
long nHNanosThisDay;
long nMillisThisDay;
nTempTime = liSrcTime;
nHNanosThisDay = (long)(nTempTime.QuadPart % 10000000L);
nTempTime.QuadPart /= 10000000L;
nSecsInDay = (long)(nTempTime.QuadPart % 86400L);
nTempTime.QuadPart /= 86400L;
nDaysAbsolute = (long)(nTempTime.QuadPart);
nDaysAbsolute += 584754L; // Add days from 1/1/0 to 01/01/1601
// Calculate the day of week (sun=1, mon=2...)
// -1 because 1/1/0 is Sat. +1 because we want 1-based
DestTime.nDayOfWeek = (int)((nDaysAbsolute - 1) % 7L) + 1;
// Leap years every 4 yrs except centuries not multiples of 400.
n400Years = (long)(nDaysAbsolute / 146097L);
// Set nDaysAbsolute to day within 400-year block
nDaysAbsolute %= 146097L;
// -1 because first century has extra day
n400Century = (long)((nDaysAbsolute - 1) / 36524L);
// Non-leap century
if (n400Century != 0)
{
// Set nDaysAbsolute to day within century
nDaysAbsolute = (nDaysAbsolute - 1) % 36524L;
// +1 because 1st 4 year increment has 1460 days
n4Years = (long)((nDaysAbsolute + 1) / 1461L);
if (n4Years != 0)
n4Day = (long)((nDaysAbsolute + 1) % 1461L);
else
{
bLeap4 = FALSE;
n4Day = (long)nDaysAbsolute;
}
}
else
{
// Leap century - not special case!
n4Years = (long)(nDaysAbsolute / 1461L);
n4Day = (long)(nDaysAbsolute % 1461L);
}
if (bLeap4)
{
// -1 because first year has 366 days
n4Yr = (n4Day - 1) / 365;
if (n4Yr != 0)
n4Day = (n4Day - 1) % 365;
}
else
{
n4Yr = n4Day / 365;
n4Day %= 365;
}
// n4Day is now 0-based day of year. Save 1-based day of year, year number
DestTime.nDayOfYear = (int)n4Day + 1;
DestTime.nYear = n400Years * 400 + n400Century * 100 + n4Years * 4 + n4Yr;
// Handle leap year: before, on, and after Feb. 29.
if (n4Yr == 0 && bLeap4)
{
// Leap Year
if (n4Day == 59)
{
/* Feb. 29 */
DestTime.nMonth = 2;
DestTime.nDay = 29;
goto DoTime;
}
// Pretend it's not a leap year for month/day comp.
if (n4Day >= 60)
--n4Day;
}
// Make n4DaY a 1-based day of non-leap year and compute
// month/day for everything but Feb. 29.
++n4Day;
// Month number always >= n/32, so save some loop time */
for (DestTime.nMonth = (n4Day >> 5) + 1;
n4Day > anMonthDayInYear[DestTime.nMonth]; DestTime.nMonth++);
DestTime.nDay = (int)(n4Day - anMonthDayInYear[DestTime.nMonth-1]);
DoTime:
if (nSecsInDay == 0)
DestTime.nHour = DestTime.nMinute = DestTime.nSecond = 0;
else
{
DestTime.nSecond = (UINT)nSecsInDay % 60L;
nMinutesInDay = nSecsInDay / 60L;
DestTime.nMinute = (UINT)nMinutesInDay % 60;
DestTime.nHour = (UINT)nMinutesInDay / 60;
}
if (nHNanosThisDay == 0)
DestTime.nMilli = DestTime.nMicro = DestTime.nNano = 0;
else
{
DestTime.nNano = (UINT)((nHNanosThisDay % 10L) * 100L);
nMillisThisDay = nHNanosThisDay / 10L;
DestTime.nMicro = (UINT)nMillisThisDay % 1000;
DestTime.nMilli = (UINT)nMillisThisDay / 1000;
}
return TRUE;
}
void DateTime::convertToStandardFormat(_TimeFormat &tmTempHigh, tm &tmSrc)
{
// Convert internal tm to format expected by runtimes (sfrtime, etc)
tmSrc.tm_year = tmTempHigh.nYear-1900; // year is based on 1900
tmSrc.tm_mon = tmTempHigh.nMonth-1; // month of year is 0-based
tmSrc.tm_wday = tmTempHigh.nDayOfWeek-1; // day of week is 0-based
tmSrc.tm_yday = tmTempHigh.nDayOfYear-1; // day of year is 0-based
tmSrc.tm_mday = tmTempHigh.nDay;
tmSrc.tm_hour = tmTempHigh.nHour;
tmSrc.tm_min = tmTempHigh.nMinute;
tmSrc.tm_sec = tmTempHigh.nSecond;
tmSrc.tm_isdst = 0;
}
int DateTime::GetYear() const
{
_TimeFormat tmTemp;
if (GetStatus() == valid && convertLongLongToTime(time_, tmTemp))
return tmTemp.nYear;
else
return HIGH_DATETIME_ERROR;
}
int DateTime::GetMonth() const // month of year (1 = Jan)
{
_TimeFormat tmTemp;
if (GetStatus() == valid && convertLongLongToTime(time_, tmTemp))
return tmTemp.nMonth;
else
return HIGH_DATETIME_ERROR;
}
int DateTime::GetDay() const // day of month (0-31)
{
_TimeFormat tmTemp;
if (GetStatus() == valid && convertLongLongToTime(time_, tmTemp))
return tmTemp.nDay;
else
return HIGH_DATETIME_ERROR;
}
int DateTime::GetHour() const // hour in day (0-23)
{
_TimeFormat tmTemp;
if (GetStatus() == valid && convertLongLongToTime(time_, tmTemp))
return tmTemp.nHour;
else
return HIGH_DATETIME_ERROR;
}
int DateTime::GetMinute() const // minute in hour (0-59)
{
_TimeFormat tmTemp;
if (GetStatus() == valid && convertLongLongToTime(time_, tmTemp))
return tmTemp.nMinute;
else
return HIGH_DATETIME_ERROR;
}
int DateTime::GetSecond() const // second in minute (0-59)
{
_TimeFormat tmTemp;
if (GetStatus() == valid && convertLongLongToTime(time_, tmTemp))
return tmTemp.nSecond;
else
return HIGH_DATETIME_ERROR;
}
int DateTime::GetMilliSecond() const // millisecond in minute (0-999)
{
_TimeFormat tmTemp;
if (GetStatus() == valid && convertLongLongToTime(time_, tmTemp))
return tmTemp.nMilli;
else
return HIGH_DATETIME_ERROR;
}
int DateTime::GetMicroSecond() const // microsecond in minute (0-999)
{
_TimeFormat tmTemp;
if (GetStatus() == valid && convertLongLongToTime(time_, tmTemp))
return tmTemp.nMicro;
else
return HIGH_DATETIME_ERROR;
}
int DateTime::GetNanoSecond() const // nanosecond in minute (0-999), step of 100ns
{
_TimeFormat tmTemp;
if (GetStatus() == valid && convertLongLongToTime(time_, tmTemp))
return tmTemp.nNano;
else
return HIGH_DATETIME_ERROR;
}
int DateTime::GetDayOfWeek() const // 1=Sun, 2=Mon, ..., 7=Sat
{
_TimeFormat tmTemp;
if (GetStatus() == valid && convertLongLongToTime(time_, tmTemp))
return tmTemp.nDayOfWeek;
else
return HIGH_DATETIME_ERROR;
}
int DateTime::GetDayOfYear() const // days since start of year, Jan 1 = 1
{
_TimeFormat tmTemp;
if (GetStatus() == valid && convertLongLongToTime(time_, tmTemp))
return tmTemp.nDayOfYear;
else
return HIGH_DATETIME_ERROR;
}
void
DateTime::ToDateString( const TCHAR* fmt, tstring& v ) const
{
v.clear();
_TimeFormat SrcTime;
SrcTime.nYear = GetYear();
SrcTime.nMonth = GetMonth();
SrcTime.nDay = GetDay();
SrcTime.nHour = GetHour();
SrcTime.nMinute = GetMinute();
SrcTime.nSecond = GetSecond();
SrcTime.nMilli = GetMilliSecond();
SrcTime.nMicro = GetMicroSecond();
SrcTime.nNano = GetNanoSecond();
struct tm t;
TCHAR dest[128];
memset( dest, 0, 128*sizeof(TCHAR) );
convertToStandardFormat(SrcTime, t);
_tcsftime( dest, 128, fmt, &t);
v = dest;
}
void
DateTime::ToTimeString( const TCHAR* fmt, tstring& v ) const
{
v.clear();
_TimeFormat SrcTime;
SrcTime.nYear = GetYear();
SrcTime.nMonth = GetMonth();
SrcTime.nDay = GetDay();
SrcTime.nHour = GetHour();
SrcTime.nMinute = GetMinute();
SrcTime.nSecond = GetSecond();
SrcTime.nMilli = GetMilliSecond();
SrcTime.nMicro = GetMicroSecond();
SrcTime.nNano = GetNanoSecond();
struct tm t;
TCHAR dest[128];
memset( dest, 0, 128*sizeof(TCHAR) );
convertToStandardFormat(SrcTime, t);
_tcsftime( dest, 128, fmt, &t);
v = dest;
}
LONGLONG
DateTime::GetRawTime() const
{
return (LONGLONG)time_.QuadPart;
}
void
DateTime::SetRawTime(LONGLONG rt )
{
time_.QuadPart = rt;
}
BOOL DateTime::GetAsSystemTime(SYSTEMTIME& sysTime) const
{
BOOL bRetVal = FALSE;
if (GetStatus() == valid)
{
_TimeFormat tmTemp;
if (convertLongLongToTime(time_, tmTemp))
{
sysTime.wYear = (WORD) tmTemp.nYear;
sysTime.wMonth = (WORD) tmTemp.nMonth;
sysTime.wDayOfWeek = (WORD) (tmTemp.nDayOfWeek - 1);
sysTime.wDay = (WORD) tmTemp.nDay;
sysTime.wHour = (WORD) tmTemp.nHour;
sysTime.wMinute = (WORD) tmTemp.nMinute;
sysTime.wSecond = (WORD) tmTemp.nSecond;
sysTime.wMilliseconds = (WORD)tmTemp.nMilli;
bRetVal = TRUE;
}
}
return bRetVal;
}
// DateTime math
DateTime DateTime::operator+(const DateTimeSpan &dateSpan) const
{
DateTime dateResult; // Initializes status_ to valid
// If either operand NULL, result NULL
if (GetStatus() == null || dateSpan.GetStatus() == null)
{
dateResult.SetStatus(null);
return dateResult;
}
// If either operand invalid, result invalid
if (GetStatus() == invalid || dateSpan.GetStatus() == invalid)
{
dateResult.SetStatus(invalid);
return dateResult;
}
// Compute the actual date difference by adding underlying dates
dateResult.time_.QuadPart = time_.QuadPart + dateSpan.span_.QuadPart;
// Validate within range
//dateResult.CheckRange();
return dateResult;
}
DateTime DateTime::operator-(const DateTimeSpan &dateSpan) const
{
DateTime dateResult; // Initializes status_ to valid
// If either operand NULL, result NULL
if (GetStatus() == null || dateSpan.GetStatus() == null)
{
dateResult.SetStatus(null);
return dateResult;
}
// If either operand invalid, result invalid
if (GetStatus() == invalid || dateSpan.GetStatus() == invalid)
{
dateResult.SetStatus(invalid);
return dateResult;
}
// Compute the actual date difference by adding underlying dates
dateResult.time_.QuadPart = time_.QuadPart - dateSpan.span_.QuadPart;
// Validate within range
//dateResult.CheckRange();
return dateResult;
}
// DateTimeSpan math
DateTimeSpan DateTime::operator-(const DateTime& date) const
{
DateTimeSpan spanResult;
// If either operand NULL, result NULL
if (GetStatus() == null || date.GetStatus() == null)
{
spanResult.SetStatus(DateTimeSpan::null);
return spanResult;
}
// If either operand invalid, result invalid
if (GetStatus() == invalid || date.GetStatus() == invalid)
{
spanResult.SetStatus(DateTimeSpan::invalid);
return spanResult;
}
spanResult.span_.QuadPart = time_.QuadPart - date.time_.QuadPart;
return spanResult;
}
void DateTimeSpan::SetHighTimeSpan(long lDays, int nHours, int nMinutes, int nSeconds,
int nMillis, int nMicros, int nNanos)
// Milli, Micro & nano, default = 0
{
int nHundredsNanos;
if (nNanos >= 0)
nHundredsNanos = (nNanos+50) / 100;
else
nHundredsNanos = (nNanos-50) / 100;
nMicros += nHundredsNanos / 10;
nHundredsNanos %= 10;
nMillis += nMicros / 1000;
nMicros %= 1000;
nSeconds +=nMillis / 1000;
nMillis %= 1000;
nMinutes += nSeconds / 60;
nSeconds %= 60;
nHours += nMinutes / 60;
nMinutes %= 60;
lDays += nHours / 24;
nHours %= 24;
span_.QuadPart = lDays;
span_.QuadPart *= 86400L;
span_.QuadPart += (nHours * 3600L) +
(nMinutes * 60) +
nSeconds;
span_.QuadPart *= 10000000L;
span_.QuadPart += (nMillis * 10000L) +
(nMicros * 10L) +
nHundredsNanos;
SetStatus(valid);
}
LONGLONG DateTimeSpan::GetTotalDays() const // span in days (about -3.65e6 to 3.65e6)
{
LONGLONG liTemp;
liTemp = span_.QuadPart / 10000000L;
liTemp /= 86400L;
return liTemp;
}
LONGLONG DateTimeSpan::GetTotalHours() const // span in hours (about -8.77e7 to 8.77e6)
{
LONGLONG liTemp;
liTemp = span_.QuadPart / 10000000L;
liTemp /= 3600L;
return liTemp;
}
LONGLONG DateTimeSpan::GetTotalMinutes() const // span in minutes (about -5.26e9 to 5.26e9)
{
LONGLONG liTemp;
liTemp = span_.QuadPart / 10000000L;
liTemp /= 60L;
return liTemp;
}
LONGLONG DateTimeSpan::GetTotalSeconds() const // span in seconds (about -3.16e11 to 3.16e11)
{
LONGLONG liTemp;
liTemp = span_.QuadPart / 10000000L;
return liTemp;
}
LONGLONG DateTimeSpan::GetTotalMilliSeconds() const // span in milliseconds
{
LONGLONG liTemp;
liTemp = span_.QuadPart / 10000L;
return liTemp;
}
LONGLONG DateTimeSpan::GetTotalMicroSeconds() const // span in microseconds
{
LONGLONG liTemp;
liTemp = span_.QuadPart / 10L;
return liTemp;
}
LONGLONG DateTimeSpan::GetTotalNanoSeconds() const // span in nanoseconds
{
LONGLONG liTemp;
liTemp = span_.QuadPart * 100L;
return liTemp;
}
int DateTimeSpan::GetDays() const // component days in span
{
LONGLONG liTemp;
liTemp = span_.QuadPart / 10000000L;
liTemp = (liTemp / 86400L);
return (int)liTemp;
}
int DateTimeSpan::GetHours() const // component hours in span (-23 to 23)
{
LONGLONG liTemp;
liTemp = span_.QuadPart / 10000000L;
liTemp = (liTemp % 86400L) / 3600;
return (int)liTemp;
}
int DateTimeSpan::GetMinutes() const // component minutes in span (-59 to 59)
{
LONGLONG liTemp;
liTemp = span_.QuadPart / 10000000L;
liTemp = (liTemp % 3600L) / 60;
return (int)liTemp;
}
int DateTimeSpan::GetSeconds() const // component seconds in span (-59 to 59)
{
LONGLONG liTemp;
liTemp = span_.QuadPart / 10000000L;
liTemp = (liTemp % 60L);
return (int)liTemp;
}
int DateTimeSpan::GetMilliSeconds() const // component Milliseconds in span (-999 to 999)
{
LONGLONG liTemp;
liTemp = (span_.QuadPart % 10000000L) / 10000L;
return (int)liTemp;
}
int DateTimeSpan::GetMicroSeconds() const // component Microseconds in span (-999 to 999)
{
LONGLONG liTemp;
liTemp = (span_.QuadPart % 10000L) / 10L;
return (int)liTemp;
}
int DateTimeSpan::GetNanoSeconds() const // component Nanoseconds in span (-900 to 900)
{
LONGLONG liTemp;
liTemp = (span_.QuadPart % 10) * 100L;
return (int)liTemp;
}
// DateTimeSpan math
DateTimeSpan DateTimeSpan::operator+(const DateTimeSpan& dateSpan) const
{
DateTimeSpan dateSpanTemp;
// If either operand Null, result Null
if (GetStatus() == null || dateSpan.GetStatus() == null)
{
dateSpanTemp.SetStatus(null);
return dateSpanTemp;
}
// If either operand Invalid, result Invalid
if (GetStatus() == invalid || dateSpan.GetStatus() == invalid)
{
dateSpanTemp.SetStatus(invalid);
return dateSpanTemp;
}
// Add spans and validate within legal range
dateSpanTemp.span_.QuadPart = span_.QuadPart + dateSpan.span_.QuadPart;
return dateSpanTemp;
} // DateTimeSpan::operator+()
DateTimeSpan DateTimeSpan::operator-(const DateTimeSpan& dateSpan) const
{
DateTimeSpan dateSpanTemp;
// If either operand Null, result Null
if (GetStatus() == null || dateSpan.GetStatus() == null)
{
dateSpanTemp.SetStatus(null);
return dateSpanTemp;
}
// If either operand Invalid, result Invalid
if (GetStatus() == invalid || dateSpan.GetStatus() == invalid)
{
dateSpanTemp.SetStatus(invalid);
return dateSpanTemp;
}
// Add spans and validate within legal range
dateSpanTemp.span_.QuadPart = span_.QuadPart - dateSpan.span_.QuadPart;
return dateSpanTemp;
} // DateTimeSpan::operator-()
} // gk
| [
"darkface@localhost"
]
| [
[
[
1,
795
]
]
]
|
555c901186503258f732f698ea4826ebf439cb1d | 478570cde911b8e8e39046de62d3b5966b850384 | /apicompatanamdw/bcdrivers/mw/classicui/uifw/apps/S60_SDK3.0/bctestnote/inc/bctesteikprogressinfocase.h | 7bd45608140bb541e76b00cd46108d490345c40f | []
| 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 | 2,065 | h | /*
* Copyright (c) 2006 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: Declares test bc for eik progress info testcase.
*
*/
#ifndef C_CBCTESTEIKPROGRESSINFOCASE_H
#define C_CBCTESTEIKPROGRESSINFOCASE_H
#include "bctestcase.h"
class CBCTestNoteContainer;
class CCoeControl;
class CEikProgressInfo;
/**
* test case for various note classes
*/
class CBCTestEikProgressInfoCase: public CBCTestCase
{
public: // constructor and destructor
/**
* Symbian 2nd static constructor
*/
static CBCTestEikProgressInfoCase* NewL(
CBCTestNoteContainer* aContainer );
/**
* Destructor
*/
virtual ~CBCTestEikProgressInfoCase();
// from CBCTestCase
/**
* Execute corresponding test functions for UI command
* @param aCmd, UI command
*/
void RunL( TInt aCmd );
protected: // new functions
/**
* Build autotest script
*/
void BuildScriptL();
/**
* TestPublicFunctionsL function
*/
void TestPublicFunctionsL();
/**
* TestProtectedFunctionsL function
*/
void TestProtectedFunctionsL();
private: // constructor
/**
* C++ default constructor
*/
CBCTestEikProgressInfoCase( CBCTestNoteContainer* aContainer );
/**
* Symbian 2nd constructor
*/
void ConstructL();
private: // data
/**
* Pointer to container.
* not own
*/
CBCTestNoteContainer* iContainer;
/**
* Pointer to eikprogressinfo.
* own
*/
CEikProgressInfo* iEikProgressInfo;
};
#endif // C_CBCTESTEIKPROGRESSINFOCASE_H
| [
"none@none"
]
| [
[
[
1,
99
]
]
]
|
ad696d55979ec71177059a0353db997e854d4efa | 38926bfe477f933a307f51376dd3c356e7893ffc | /Source/GameDLL/ScriptBind_Actor.h | 02066ccf79ecde9fbabdc76045723fc134929c4c | []
| no_license | richmondx/dead6 | b0e9dd94a0ebb297c0c6e9c4f24c6482ef4d5161 | 955f76f35d94ed5f991871407f3d3ad83f06a530 | refs/heads/master | 2021-12-05T14:32:01.782047 | 2008-01-01T13:13:39 | 2008-01-01T13:13:39 | null | 0 | 0 | null | null | null | null | WINDOWS-1250 | C++ | false | false | 7,641 | h | /*************************************************************************
Crytek Source File.
Copyright (C), Crytek Studios, 2001-2004.
-------------------------------------------------------------------------
$Id$
$DateTime$
Description: Exposes actor functionality to LUA
-------------------------------------------------------------------------
History:
- 7:10:2004 14:19 : Created by Márcio Martins
*************************************************************************/
#ifndef __SCRIPTBIND_ACTOR_H__
#define __SCRIPTBIND_ACTOR_H__
#if _MSC_VER > 1000
# pragma once
#endif
#include <IScriptSystem.h>
#include <ScriptHelpers.h>
struct IGameFramework;
class CActor;
// <title Actor>
// Syntax: Actor
class CScriptBind_Actor :
public CScriptableBase
{
public:
CScriptBind_Actor(ISystem *pSystem);
virtual ~CScriptBind_Actor();
void AttachTo(CActor *pActor);
//------------------------------------------------------------------------
virtual int DumpActorInfo(IFunctionHandler *pH);
virtual int SetViewAngleOffset(IFunctionHandler *pH);
virtual int GetViewAngleOffset(IFunctionHandler *pH);
virtual int Revive(IFunctionHandler *pH);
virtual int Kill(IFunctionHandler *pH);
virtual int RagDollize(IFunctionHandler *pH);
virtual int SetStats(IFunctionHandler *pH);
virtual int SetParams(IFunctionHandler *pH);
virtual int GetParams(IFunctionHandler *pH);
virtual int GetHeadDir(IFunctionHandler *pH);
virtual int GetHeadPos(IFunctionHandler *pH);
virtual int PostPhysicalize(IFunctionHandler *pH);
virtual int GetChannel(IFunctionHandler *pH);
virtual int IsPlayer(IFunctionHandler *pH);
virtual int IsLocalClient(IFunctionHandler *pH);
virtual int GetLinkedVehicleId(IFunctionHandler *pH);
virtual int LinkToVehicle(IFunctionHandler *pH);
virtual int LinkToVehicleRemotely(IFunctionHandler *pH);
virtual int LinkToEntity(IFunctionHandler *pH);
virtual int IsGhostPit(IFunctionHandler *pH);
virtual int IsFlying(IFunctionHandler *pH);
virtual int SetAngles(IFunctionHandler *pH,Ang3 vAngles );
virtual int GetAngles(IFunctionHandler *pH);
virtual int AddAngularImpulse(IFunctionHandler *pH,Ang3 vAngular,float deceleration,float duration);
virtual int SetViewLimits(IFunctionHandler *pH,Vec3 dir,float rangeH,float rangeV);
virtual int PlayAction(IFunctionHandler *pH,const char *action,const char *extension);
virtual int SimulateOnAction(IFunctionHandler *pH,const char *action,int mode,float value);
virtual int SetMovementTarget(IFunctionHandler *pH, Vec3 pos, Vec3 target, Vec3 up, float speed);
virtual int CameraShake(IFunctionHandler *pH,float amount,float duration,float frequency,Vec3 pos);
virtual int SetViewShake(IFunctionHandler *pH, Ang3 shakeAngle, Vec3 shakeShift, float duration, float frequency, float randomness);
virtual int VectorToLocal(IFunctionHandler *pH);
virtual int EnableAspect(IFunctionHandler *pH, const char *aspect, bool enable);
virtual int SetExtensionActivation(IFunctionHandler *pH, const char *extension, bool activation);
virtual int SetExtensionParams(IFunctionHandler* pH, const char *extension, SmartScriptTable params);
virtual int GetExtensionParams(IFunctionHandler* pH, const char *extension, SmartScriptTable params);
// these functions are multiplayer safe
// these should be called by the server to set ammo on the clients
virtual int SetInventoryAmmo(IFunctionHandler *pH, const char *ammo, int amount);
virtual int AddInventoryAmmo(IFunctionHandler *pH, const char *ammo, int amount);
virtual int GetInventoryAmmo(IFunctionHandler *pH, const char *ammo);
virtual int SetHealth(IFunctionHandler *pH, float health);
virtual int SetMaxHealth(IFunctionHandler *pH, float health);
virtual int GetHealth(IFunctionHandler *pH);
virtual int GetMaxHealth(IFunctionHandler *pH);
virtual int GetArmor(IFunctionHandler *pH);
virtual int GetMaxArmor(IFunctionHandler *pH);
virtual int GetFrozenAmount(IFunctionHandler *pH);
virtual int AddFrost(IFunctionHandler *pH, float frost);
virtual int DamageInfo(IFunctionHandler *pH, ScriptHandle shooter, ScriptHandle target, ScriptHandle weapon, float damage, const char *damageType);
virtual int ActivateNanoSuit(IFunctionHandler *pH, int on);
virtual int SetNanoSuitMode(IFunctionHandler *pH, int mode);
virtual int GetNanoSuitMode(IFunctionHandler *pH);
virtual int GetNanoSuitEnergy(IFunctionHandler *pH);
virtual int SetNanoSuitEnergy(IFunctionHandler *pH, int energy);
virtual int PlayNanoSuitSound(IFunctionHandler *pH, int sound);
virtual int NanoSuitHit(IFunctionHandler *pH, int damage);
virtual int SetPhysicalizationProfile(IFunctionHandler *pH, const char *profile);
virtual int GetPhysicalizationProfile(IFunctionHandler *pH);
virtual int QueueAnimationState(IFunctionHandler *pH, const char *animationState);
virtual int ChangeAnimGraph(IFunctionHandler *pH, const char *graph, int layer);
virtual int CreateCodeEvent(IFunctionHandler *pH,SmartScriptTable params);
virtual int GetCurrentAnimationState(IFunctionHandler *pH);
virtual int SetAnimationInput( IFunctionHandler *pH, const char * inputID, const char * value );
virtual int TrackViewControlled( IFunctionHandler *pH, int characterSlot );
virtual int SetSpectatorMode(IFunctionHandler *pH, int mode, ScriptHandle targetId);
virtual int GetSpectatorMode(IFunctionHandler *pH);
virtual int GetSpectatorTarget(IFunctionHandler* pH);
virtual int Fall(IFunctionHandler *pH, Vec3 hitPos);
virtual int LooseHelmet(IFunctionHandler *pH, Vec3 hitDir, Vec3 hitPos);
virtual int GoLimp(IFunctionHandler *pH);
virtual int StandUp(IFunctionHandler *pH);
//------------------------------------------------------------------------
// ITEM STUFF
//------------------------------------------------------------------------
virtual int CheckInventoryRestrictions(IFunctionHandler *pH, const char *itemClassName);
virtual int CheckVirtualInventoryRestrictions(IFunctionHandler *pH, SmartScriptTable inventory, const char *itemClassName);
virtual int HolsterItem(IFunctionHandler *pH, bool holster);
virtual int DropItem(IFunctionHandler *pH, ScriptHandle itemId);
virtual int PickUpItem(IFunctionHandler *pH, ScriptHandle itemId);
virtual int SelectItemByName(IFunctionHandler *pH, const char *name);
virtual int SelectItem(IFunctionHandler *pH, ScriptHandle itemId);
virtual int SelectLastItem(IFunctionHandler *pH);
virtual int GetClosestAttachment(IFunctionHandler *pH, int characterSlot, Vec3 testPos, float maxDistance, const char* suffix);
virtual int AttachVulnerabilityEffect(IFunctionHandler *pH, int characterSlot, int partid, Vec3 hitPos, float radius, const char* effect, const char* attachmentIdentifier);
virtual int ResetVulnerabilityEffects(IFunctionHandler *pH, int characterSlot);
virtual int GetCloseColliderParts(IFunctionHandler *pH, int characterSlot, Vec3 hitPos, float radius);
virtual int CreateIKLimb( IFunctionHandler *pH, int slot, const char *limbName, const char *rootBone, const char *midBone, const char *endBone, int flags);
virtual int ResetScores(IFunctionHandler *pH);
virtual int RenderScore(IFunctionHandler *pH, ScriptHandle player, int kills, int deaths, int ping);
virtual int SetSearchBeam(IFunctionHandler *pH, Vec3 dir);
//misc
//virtual int MeleeEffect(IFunctionHandler *pH);
protected:
CActor *GetActor(IFunctionHandler *pH);
SmartScriptTable m_pParams;
ISystem *m_pSystem;
IGameFramework *m_pGameFW;
};
#endif //__SCRIPTBIND_ACTOR_H__
| [
"[email protected]",
"kkirst@c5e09591-5635-0410-80e3-0b71df3ecc31"
]
| [
[
[
1,
69
],
[
71,
86
],
[
89,
98
],
[
100,
112
],
[
114,
125
],
[
127,
144
],
[
148,
157
]
],
[
[
70,
70
],
[
87,
88
],
[
99,
99
],
[
113,
113
],
[
126,
126
],
[
145,
147
]
]
]
|
242faeb7fc12dee123ae3822cf1ca29a20f30560 | 9426ad6e612863451ad7aac2ad8c8dd100a37a98 | /ULLib/include/ULProfileReg.h | dfa575e9e3f19345e838b45551c1934638b1ec34 | []
| no_license | piroxiljin/ullib | 61f7bd176c6088d42fd5aa38a4ba5d4825becd35 | 7072af667b6d91a3afd2f64310c6e1f3f6a055b1 | refs/heads/master | 2020-12-28T19:46:57.920199 | 2010-02-17T01:43:44 | 2010-02-17T01:43:44 | 57,068,293 | 0 | 0 | null | 2016-04-25T19:05:41 | 2016-04-25T19:05:41 | null | WINDOWS-1251 | C++ | false | false | 5,627 | h | ///\file ULProfileReg.h
///\brief Заголовочный файл класса профиля приложения в реестре(17.08.2007)
#pragma once
#ifndef __UL_ULPROFILE_REG_H__
#define __UL_ULPROFILE_REG_H__
#include <windows.h>
namespace ULOther
{
///\class CULProfileReg
///\brief Класс профиля приложения в реестре(17.08.2007)
class CULProfileReg
{
protected:
///\brief Хендл ключа реестра приложения
HKEY m_hAppKey;
///\brief Флаг секции, если TRUE то заносятся все значения в HKEY_LOCAL_MACHINE
BOOL m_fAllUsers;
///\brief Функция для получения ключа реестра секции
///\param pcszSection - Имя секции
///\param возвращает: хендл секции
HKEY GetSectionKey(LPCTSTR pcszSection);
public:
///\brief Конструктор
CULProfileReg();
///\brief Деструктор
~CULProfileReg();
///\brief Функция для создания секции компании и подсекции приложения
///\param pcszCompanyName - Имя компании
///\param pcszAppName - Имя приложения
///\param fAllUsers - Использовать конфигурацию для всех пользователей
///\return возвращает: TRUE в случае успеха, иначе FALSE
BOOL SetRegistryKey(LPCTSTR pcszCompanyName,LPCTSTR pcszAppName,BOOL fAllUsers=FALSE);
///\brief Функция для записи строкового параметра в указанную секцию
///\param pcszSection - Имя секции
///\param pcszEntry - Имя параметра(строки)
///\param pcszValue - Значение(строки)
///\return возвращает: TRUE в случае успеха, иначе FALSE
BOOL WriteProfileString(LPCTSTR pcszSection,LPCTSTR pcszEntry,
LPCTSTR pcszValue);
///\brief Функция для записи числового параметра в указанную секцию
///\param pcszSection - Имя секции
///\param pcszEntry - Имя параметра(числа)
///\param nValue - Значение(числа)
///\return возвращает: TRUE в случае успеха, иначе FALSE
BOOL WriteProfileInt(LPCTSTR pcszSection, LPCTSTR pcszEntry,int nValue);
///\brief Функция для записи бинарного параметра в указанную секцию
///\param pcszSection - Имя секции
///\param pcszEntry - Имя параметра(строки)
///\param pValue - Значение
///\param dwSizeVal - размер размер данных в байтах
///\return возвращает: TRUE в случае успеха, иначе FALSE
BOOL WriteProfileBinary(LPCTSTR pcszSection,LPCTSTR pcszEntry,
void* pValue,DWORD dwSizeVal);
///\brief Функция для записи строкового параметра в указанную секцию
///\param pcszSection - Имя секции
///\param pcszEntry - Имя параметра(строки)
///\param pszValue - Указатель на возвращаемое значение(строки)
///\param lpdwValLen - размер pcszValue
///\return возвращает: TRUE в случае успеха, иначе FALSE
BOOL GetProfileString(LPCTSTR pcszSection, LPCTSTR pcszEntry,
LPTSTR pszValue,LPDWORD lpdwValLen);
///\brief Функция для чтения числового параметра в указанную секцию
///\param pcszSection - Имя секции
///\param pcszEntry - Имя параметра(числа)
///\param pdwValue - Указатель на возвращаемое значение(числа)
///\return возвращает: TRUE в случае успеха, иначе FALSE
BOOL GetProfileInt(LPCTSTR pcszSection, LPCTSTR pcszEntry,DWORD* pdwValue);
///\brief Функция для записи бинарного параметра в указанную секцию
///\param pcszSection - Имя секции
///\param pcszEntry - Имя параметра(строки)
///\param pValue - Указатель на возвращаемое значение
///\param lpdwValLen - размер pValue
///\return возвращает: TRUE в случае успеха, иначе FALSE
BOOL GetProfileBinary(LPCTSTR pcszSection, LPCTSTR pcszEntry,
void* pValue,DWORD* lpdwValLen);
///\brief Функция для добавления указанного пути в авторан
///\param pcszName - имя параметра
///\param pcszFilePath - путь к файлу(если NULL,то поле pcszName удалится)
///\return возвращает: TRUE в случае успеха, иначе FALSE
BOOL AddToAutoRun(LPCTSTR pcszName,LPCTSTR pcszFilePath);
///\brief Функция для проверки указанного поля в авторане
///\param pcszName - имя параметра
///\return возвращает: TRUE в случае успеха, иначе FALSE
BOOL IsAutoRun(LPCTSTR pcszName);
///\brief Закрывает сессию профиля
void Close();
///\brief отсоединяет класс от хендла
///\return хэндл
inline HKEY Detach()
{HKEY hRetKey=m_hAppKey;m_hAppKey=NULL;return hRetKey;}
};
}
#endif//__UL_ULPROFILE_REG_H__
| [
"UncleLab@a8b69a72-a546-0410-9fb4-5106a01aa11f"
]
| [
[
[
1,
93
]
]
]
|
b9c74c8fd8158c46e63c4f96c9f6d98addd06e0e | ce262ae496ab3eeebfcbb337da86d34eb689c07b | /SETools/SEToolsCommon/SECollada/SEColladaInstanceController.h | 4b643197c4376f2295c12d85691c0d7da2b5a48a | []
| no_license | pizibing/swingengine | d8d9208c00ec2944817e1aab51287a3c38103bea | e7109d7b3e28c4421c173712eaf872771550669e | refs/heads/master | 2021-01-16T18:29:10.689858 | 2011-06-23T04:27:46 | 2011-06-23T04:27:46 | 33,969,301 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,255 | h | // Swing Engine Version 1 Source Code
// Most of techniques in the engine are mainly based on David Eberly's
// Wild Magic 4 open-source code.The author of Swing Engine learned a lot
// from Eberly's experience of architecture and algorithm.
// Several sub-systems are totally new,and others are re-implimented or
// re-organized based on Wild Magic 4's sub-systems.
// Copyright (c) 2007-2010. All Rights Reserved
//
// Eberly's permission:
// Geometric Tools, Inc.
// http://www.geometrictools.com
// Copyright (c) 1998-2006. All Rights Reserved
//
// 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. The license is available for reading at
// the location:
// http://www.gnu.org/copyleft/lgpl.html
#ifndef Swing_ColladaInstanceController_H
#define Swing_ColladaInstanceController_H
#include "SEToolsCommonLIB.h"
#include "SEToolsUtility.h"
#include "SEObject.h"
#include "SENode.h"
namespace Swing
{
//----------------------------------------------------------------------------
// Description: A helper class.
// Author:Sun Che
// Date:20091013
//----------------------------------------------------------------------------
class SE_TOOLS_COMMON_API SEColladaInstanceController : public SEObject
{
SE_DECLARE_RTTI;
SE_DECLARE_NAME_ID;
public:
enum ControllerType
{
CT_SKIN,
CT_MORPH,
CT_UNKNOWN
};
SEColladaInstanceController(ControllerType eType, domController*
pController, domNode* pSkeletonRoot, SENode* pMeshRoot);
~SEColladaInstanceController(void);
// Member access.
ControllerType GetControllerType(void) const;
domController* GetController(void);
domNode* GetSkeletonRoot(void);
SENode* GetMeshRoot(void);
private:
SEColladaInstanceController(void);
ControllerType m_eControllerType;
domController* m_pController;
domNode* m_pSkeletonRoot;
SENode* m_pMeshRoot;
};
typedef SESmartPointer<SEColladaInstanceController>
SEColladaInstanceControllerPtr;
}
#endif | [
"[email protected]@876e9856-8d94-11de-b760-4d83c623b0ac"
]
| [
[
[
1,
74
]
]
]
|
b1587e09cc8cf6657bacf7b91b252b1fdd2bce44 | 95a3e8914ddc6be5098ff5bc380305f3c5bcecb2 | /src/FusionForever_lib/FadeInScene.h | 42da6bc5df07832cff7f70a8b6a1c8479e8218dc | []
| no_license | danishcake/FusionForever | 8fc3b1a33ac47177666e6ada9d9d19df9fc13784 | 186d1426fe6b3732a49dfc8b60eb946d62aa0e3b | refs/heads/master | 2016-09-05T16:16:02.040635 | 2010-04-24T11:05:10 | 2010-04-24T11:05:10 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 494 | h | #pragma once
#include "BaseScene.h"
/**
* The FadeInScene represents a fade in and should be push onto the scene vector after
* the item to be faded in.
*/
class FadeInScene :
public BaseScene
{
public:
FadeInScene();
virtual ~FadeInScene(void);
virtual void Tick(float _timespan, std::vector<BaseScene_ptr>& _new_scenes);
virtual void Draw();
virtual bool IsRoot();
virtual bool IsRemovable();
static const float FITime;
protected:
float timeleft_;
};
| [
"Edward Woolhouse@e6f1df29-e57c-d74d-9e6e-27e3b006b1a7"
]
| [
[
[
1,
23
]
]
]
|
86c0f7b2bfa5c6cabb85505d77e5d2cc1e8e3890 | 4275e8a25c389833c304317bdee5355ed85c7500 | /Netlib/cDataPacket.h | 83c5700fc45dd601e382fd12c8648000a90a4490 | []
| no_license | kumorikarasu/KylTek | 482692298ef8ff501fd0846b5f41e9e411afe686 | be6a09d20159d0a320abc4d947d4329f82d379b9 | refs/heads/master | 2021-01-10T07:57:40.134888 | 2010-07-26T12:10:09 | 2010-07-26T12:10:09 | 55,943,006 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,355 | h | /*******************************************************************
* Advanced 3D Game Programming with DirectX 10.0
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
*
* See license.txt for modification and distribution information
* copyright (c) 2007 by Peter Walsh, Wordware
******************************************************************/
// cDataPacket.h: interface for the cDataPacket class.
//
//////////////////////////////////////////////////////////////////////
#if !defined(AFX_CDATAPACKET_H__4A115C41_D1D4_11D3_AE4F_00E029031C67__INCLUDED_)
#define AFX_CDATAPACKET_H__4A115C41_D1D4_11D3_AE4F_00E029031C67__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#define WINDOWS_LEAN_AND_MEAN
#include <windows.h>
#define MAX_UDPBUFFERSIZE 4096
class cDataPacket
{
public:
char d_data[ MAX_UDPBUFFERSIZE ];
unsigned short d_length,
d_timesSent;
DWORD d_id,
d_firstTime,
d_lastTime;
cDataPacket();
virtual ~cDataPacket();
void Init( DWORD time, DWORD id, unsigned short len, char *pData );
cDataPacket &operator=( const cDataPacket &otherPacket );
};
#endif // !defined(AFX_CDATAPACKET_H__4A115C41_D1D4_11D3_AE4F_00E029031C67__INCLUDED_)
| [
"Sean Stacey@localhost"
]
| [
[
[
1,
48
]
]
]
|
67bad870a94f6f709661353b98287dda2207b340 | 74c8da5b29163992a08a376c7819785998afb588 | /NetAnimal/addons/pa/ParticleUniverse/src/ParticleAffectors/ParticleUniverseSphereColliderTokens.cpp | 29c3e1b5e96da2b66efae7295c63babfabbef908 | []
| no_license | dbabox/aomi | dbfb46c1c9417a8078ec9a516cc9c90fe3773b78 | 4cffc8e59368e82aed997fe0f4dcbd7df626d1d0 | refs/heads/master | 2021-01-13T14:05:10.813348 | 2011-06-07T09:36:41 | 2011-06-07T09:36:41 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,839 | cpp | /*
-----------------------------------------------------------------------------------------------
This source file is part of the Particle Universe product.
Copyright (c) 2010 Henry van Merode
Usage of this program is licensed under the terms of the Particle Universe Commercial License.
You can find a copy of the Commercial License in the Particle Universe package.
-----------------------------------------------------------------------------------------------
*/
#include "ParticleUniversePCH.h"
#ifndef PARTICLE_UNIVERSE_EXPORTS
#define PARTICLE_UNIVERSE_EXPORTS
#endif
#include "ParticleAffectors/ParticleUniverseSphereCollider.h"
#include "ParticleAffectors/ParticleUniverseSphereColliderTokens.h"
namespace ParticleUniverse
{
//-----------------------------------------------------------------------
bool SphereColliderTranslator::translateChildProperty(Ogre::ScriptCompiler* compiler, const Ogre::AbstractNodePtr &node)
{
Ogre::PropertyAbstractNode* prop = reinterpret_cast<Ogre::PropertyAbstractNode*>(node.get());
ParticleAffector* af = Ogre::any_cast<ParticleAffector*>(prop->parent->context);
SphereCollider* affector = static_cast<SphereCollider*>(af);
if (prop->name == token[TOKEN_RADIUS])
{
// Property: radius
if (passValidateProperty(compiler, prop, token[TOKEN_RADIUS], VAL_REAL))
{
Ogre::Real val = 0.0f;
if(getReal(prop->values.front(), &val))
{
affector->setRadius(val);
return true;
}
}
}
else if (prop->name == token[TOKEN_SPHERE_COLLIDER_RADIUS])
{
// Property: sphere_collider_radius (Deprecated; replaced by radius)
if (passValidateProperty(compiler, prop, token[TOKEN_SPHERE_COLLIDER_RADIUS], VAL_REAL))
{
Ogre::Real val = 0.0f;
if(getReal(prop->values.front(), &val))
{
affector->setRadius(val);
return true;
}
}
}
else if (prop->name == token[TOKEN_INNER_COLLISION])
{
// Property: inner_collision
if (passValidateProperty(compiler, prop, token[TOKEN_INNER_COLLISION], VAL_BOOL))
{
bool val;
if(getBoolean(prop->values.front(), &val))
{
affector->setInnerCollision(val);
return true;
}
}
}
else
{
// Parse the BaseCollider
BaseColliderTranslator baseColliderTranslator;
return baseColliderTranslator.translateChildProperty(compiler, node);
}
return false;
}
//-----------------------------------------------------------------------
bool SphereColliderTranslator::translateChildObject(Ogre::ScriptCompiler* compiler, const Ogre::AbstractNodePtr &node)
{
// No objects
return false;
}
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
void SphereColliderWriter::write(ParticleScriptSerializer* serializer, const IElement* element)
{
// Cast the element to a SphereCollider
const SphereCollider* affector = static_cast<const SphereCollider*>(element);
// Write the header of the SphereCollider
serializer->writeLine(token[TOKEN_AFFECTOR], affector->getAffectorType(), affector->getName(), 8);
serializer->writeLine("{", 8);
// Write base attributes
BaseColliderWriter::write(serializer, element);
// Write own attributes
if (affector->getRadius() != SphereCollider::DEFAULT_RADIUS) serializer->writeLine(
token[TOKEN_RADIUS], Ogre::StringConverter::toString(affector->getRadius()), 12);
if (affector->isInnerCollision() != false) serializer->writeLine(
token[TOKEN_INNER_COLLISION], Ogre::StringConverter::toString(affector->isInnerCollision()), 12);
// Write the close bracket
serializer->writeLine("}", 8);
}
}
| [
"[email protected]"
]
| [
[
[
1,
109
]
]
]
|
e2445b8f5afa5662ab2aa6b1b072ec1a5c817876 | 63d8291850783397b2149b4f38d0b1919bf87e5c | /PobotKey/Projects/Arduino/Tests Simples/Modif_Timer/MicroTimer2.h | 039062e311a523df42c43c1892d9c7be36a63272 | []
| no_license | JulienHoltzer/Pobot-Playground | 8d0cb50edc5846d7fe717f467d5a9f07ad7e7979 | a4a9c6af9c8b2fec8e5782be86427620843f38df | refs/heads/master | 2021-05-28T04:54:03.737479 | 2011-11-11T10:32:43 | 2011-11-11T10:32:43 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 381 | h | #ifndef MicroTimer2_h
#define MicroTimer2_h
#include <avr/interrupt.h>
namespace MicroTimer2 {
extern unsigned long msecs;
extern void (*func)();
extern volatile unsigned long count;
extern volatile char overflowing;
extern volatile unsigned int tcnt2;
void set(unsigned long ms, void (*f)());
void start();
void stop();
void _overflow();
}
#endif
| [
"julien.holtzer@c631b436-7905-11de-aab9-69570e6b7754"
]
| [
[
[
1,
19
]
]
]
|
c7a5674e82764fcd4eb254c83f19130c0a58e31d | 7b4c786d4258ce4421b1e7bcca9011d4eeb50083 | /_20090206_代码统计专用文件夹/C++Primer中文版(第4版)/第三章 标准库类型/20090117_习题3.8_连接多个string对象.cpp | 8c49d6ed7a8fcd6c0b33d9c178304cb2c687def5 | []
| 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 | UTF-8 | C++ | false | false | 315 | cpp | #include <iostream>
#include <string>
using namespace std;
int main()
{
string result_str,str;
cout << "Enter strings(Ctrl+Z to end):" << endl;
while(cin >> str)
result_str+=str;
cout << "String equal to the concatenation of these strings is:"
<< endl << result_str << endl;
return 0;
} | [
"baicaibang@70501136-4834-11de-8855-c187e5f49513"
]
| [
[
[
1,
17
]
]
]
|
d4470ac280e42e2187c858123ef589ee310a925d | c66499a43b01dc474b85e1b74f871870f0e8d5ed | /MSAOpenCL/examples/openFrameworks/MSAOpenCL example - hello world/src/testApp.cpp | 1181184d65585df62f74fbdac300fa064f25484f | []
| no_license | joshuajnoble/msalibs | c50e58530514dc750eb21c3ddb37289959a58d42 | d6da5bd33e90f22dec002a439540baa144bd5ee0 | refs/heads/master | 2021-01-16T23:02:09.205880 | 2011-08-06T09:42:21 | 2011-08-06T09:42:21 | 1,996,246 | 1 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 3,422 | cpp | #include "testApp.h"
#include "MSAOpenCL.h"
#include "MSATimer.h"
#define SIZE (2048*2048)
#define REPS 500
MSA::OpenCL openCL;
float buf[2][SIZE];
MSA::OpenCLBuffer clBuf[2];
float scalerMultipler;
float testBuffer[SIZE];
MSA::Timer timer;
//--------------------------------------------------------------
void testApp::setup(){
// dump everything to console
ofSetLogLevel(OF_LOG_VERBOSE);
// initialize input data
for(int i=0;i<SIZE; i++){
buf[0][i] = i+1;
}
// setup openCL, load program and init kernels
openCL.setup(CL_DEVICE_TYPE_GPU, 2);
openCL.loadProgramFromFile("MSAOpenCL/TestProgram.cl", false);
MSA::OpenCLKernel *kernelSquare = openCL.loadKernel("square");
MSA::OpenCLKernel *kernelInverse = openCL.loadKernel("inverse");
MSA::OpenCLKernel *kernelMultiplyScaler = openCL.loadKernel("multiplyScaler");
// create openCL buffers and upload initial data
printf("\nPlease wait while preparing buffers...");
timer.start();
clBuf[0].initBuffer(SIZE * sizeof(float), CL_MEM_READ_WRITE, buf[0]);
clBuf[1].initBuffer(SIZE * sizeof(float), CL_MEM_READ_WRITE);
kernelSquare->setArg(0, clBuf[0].getCLMem());
kernelSquare->setArg(1, clBuf[1].getCLMem());
kernelInverse->setArg(0, clBuf[1].getCLMem());
kernelInverse->setArg(1, clBuf[0].getCLMem());
kernelMultiplyScaler->setArg(0, clBuf[0].getCLMem());
kernelMultiplyScaler->setArg(1, scalerMultipler);
kernelMultiplyScaler->setArg(2, clBuf[1].getCLMem());
openCL.finish(); // not normally needed, but here for more precise time measurement
timer.stop();
printf("took %f seconds\n", timer.getSeconds());
// run kernels
printf("\nPlease wait while running kernels...");
timer.start();
size_t sizes[1] = { SIZE };
for(int r=0; r<REPS; r++) {
// run these kernels passing in a sizes array
kernelSquare->run(1, sizes);
kernelInverse->run(1, sizes);
// running this one with the run1D wrapper, just to show how it works
// actualy it does the same as the above run method (except it internally creates the array everytime its run)
kernelMultiplyScaler->run1D(SIZE);
}
openCL.finish(); // not normally needed, but here for more precise time measurement
timer.stop();
printf("took %f seconds\n", timer.getSeconds());
// read results back from openCL device
printf("\nPlease wait while reading back buffer...");
timer.start();
clBuf[0].read(buf[1], 0, SIZE * sizeof(float));
timer.stop();
printf("took %f seconds\n", timer.getSeconds());
// perform operation on CPU as well to compare results
printf("\nPlease wait while running on CPU for comparison...");
timer.start();
for(int r=0; r<REPS; r++) {
for(int i=0; i<SIZE; i++) testBuffer[i] = (buf[0][i] * buf[0][i]);
for(int i=0; i<SIZE; i++) testBuffer[i] = 1.0f/testBuffer[i];
for(int i=0; i<SIZE; i++) testBuffer[i] = testBuffer[i] * scalerMultipler;
}
openCL.finish(); // not normally needed, but here for more precise time measurement
timer.stop();
printf("took %f seconds\n", timer.getSeconds());
// compare results
float diffSum = 0;
for(int i=0; i<SIZE; i++) {
float diff = testBuffer[i] - buf[1][i];
// printf("input:%f outputCL:%f outputTest:%f diff:%f\n", buf[0][i], buf[1][i], testBuffer[i], diff);
}
printf("\n\noutput diffSum: %f\n\n", diffSum);
std::exit(0);
}
| [
"[email protected]"
]
| [
[
[
1,
111
]
]
]
|
998b3d796d5cc9de7571898c738e5a2416fde198 | faaac39c2cc373003406ab2ac4f5363de07a6aae | / zenithprime/inc/controller/Controler.h | 50530b5571526e8ef5510ea94f6d403a7eb632eb | []
| no_license | mgq812/zenithprime | 595625f2ec86879eb5d0df4613ba41a10e3158c0 | 3c8ff4a46fb8837e13773e45f23974943a467a6f | refs/heads/master | 2021-01-20T06:57:05.754430 | 2011-02-05T17:20:19 | 2011-02-05T17:20:19 | 32,297,284 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 221 | h | class Controler
{
public:
void RightMouseClick(int x, int y);
void LeftMouseClick(int x, int y);
void MouseHover(int x, int y);
void LeftMouseDrag(int xStart, int yStart, int xEnd, int yEnd);
private:
};
| [
"ElderGrimes@2c223db4-e1a0-a0c7-f360-d8b483a75394"
]
| [
[
[
1,
11
]
]
]
|
c1656cae5756fea3e2b06a72a61137f311a36ca6 | c3ae23286c2e8268355241f8f06cd1309922a8d6 | /rateracerlib/shapes/Shape.h | 8b97a2b2816eedd22573aad3131773856b6d6d12 | []
| no_license | BackupTheBerlios/rateracer-svn | 2f43f020ecdd8a3528880d474bec1c0464879597 | 838ad3f326962028ce8d493d2c06f6af6ea4664c | refs/heads/master | 2020-06-04T03:31:51.633612 | 2005-05-30T06:38:01 | 2005-05-30T06:38:01 | 40,800,078 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,082 | h | #pragma once
#include <windows.h>
#include <gl/GL.h>
#include <gl/GLU.h>
#include "mathlib.h"
#include "Ray.h"
#include "Material.h"
class Vec3;
class Grid;
// NOTE: Shape primitives should be convex for optimization assumptions to work!
// Maybe add: kDOP, metaballs
class Shape
{
public:
Shape()
{
material = &gDefaultMaterial;
}
virtual ~Shape() {}
virtual void calcBounds(Vec3& min, Vec3&max)
{
min.assign( FLT_MAX, FLT_MAX, FLT_MAX);
max.assign(-FLT_MAX,-FLT_MAX,-FLT_MAX);
}
virtual float collideRay(const Ray& r) = 0;
virtual Shape* getPrimitiveObject() { return this; }
virtual Vec3 getNormal(const Vec3& p) = 0;
virtual Vec3 getPrimitiveNormal(const Vec3& p) { return getNormal(p); }
virtual Vec3 getTangent(const Vec3& p)
{
return cross(getNormal(p), Vec3(0,1,0)).normalizeSafely();
}
virtual Vec2 getUV(const Vec3& p) { return Vec2(0,0); }
virtual void rasterize(Grid *grid) {}
virtual void drawBoundingBoxes() {}
virtual void drawPreview() = 0;
Material const *material;
};
| [
"gweronimo@afd64b18-8dda-0310-837d-b02fe5df315d"
]
| [
[
[
1,
53
]
]
]
|
facbee22c2da89896066e584d916aaa4048bf6a8 | b6a6fa4324540b94fb84ee68de3021a66f5efe43 | /SCS/Instruments/SynthBass1.h | 4b2bc5fc0ec72bc6a77f529071949f0cff2d1ce2 | []
| no_license | southor/duplo-scs | dbb54061704f8a2ec0514ad7d204178bfb5a290e | 403cc209039484b469d602b6752f66b9e7c811de | refs/heads/master | 2021-01-20T10:41:22.702098 | 2010-02-25T16:44:39 | 2010-02-25T16:44:39 | 34,623,992 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,258 | h | #ifndef _SYNTHBASS1_
#define _SYNTHBASS1_
#include "Standards.h"
//#include "Instrument.h"
#include "EnvelopeT.h"
#include "Curves.h"
class SynthBass1 : public StandardInstrument
{
public:
double Pos;
EnvelopeT *Envelope;
double Mod1; // controls decay and synthy sound
double ThinMod;
SynthBass1() : StandardInstrument()
{
Envelope = new EnvelopeT();
Envelope->Attack = 1.0/40.0;
Envelope->Hold = 0;
Envelope->Decay = 1.0/20.0;
Envelope->Sustain = 0.8;
Envelope->Release = 1.0/64.0;
ThinMod = 0.5;
Pos = 0;
Mod1 = 3.0;
}
void NoteOn()
{
StandardInstrument::NoteOn();
Envelope->NoteOn();
}
bool Run()
{
Playing = Envelope->Run();
PlayPos = PlayPos+PlayStep;
TimePos = TimePos+TimeStep;
//double Env = Shot(PlayPos*30);
//double Env = 1.0;
Pos = Pos+TimeStep*Fre;
double SlowDecayValue = Fall1(TimePos*Mod1);
double FastDecayValue = Fall1(TimePos*20.0);
Amp = BSine(Pos+Sine(Pos+0.34)*SlowDecayValue*0.3, Fall1(TimePos*FastDecayValue)*ThinMod);
Amp = Amp*Envelope->Amp;
return Playing;
}
void NoteOff()
{
Envelope->NoteOff();
}
void End()
{
}
};
#endif | [
"t.soderberg8@2b3d9118-3c8b-11de-9b50-8bb2048eb44c"
]
| [
[
[
1,
86
]
]
]
|
9751251705fec7bbc9daf10a584bf4856cc381dd | 62874cd4e97b2cfa74f4e507b798f6d5c7022d81 | /src/libMidi-Me/InputDevice.cpp | 7dcec2d915b26c52837a3736ffed3eb7e502d9b9 | []
| no_license | rjaramih/midi-me | 6a4047e5f390a5ec851cbdc1b7495b7fe80a4158 | 6dd6a1a0111645199871f9951f841e74de0fe438 | refs/heads/master | 2021-03-12T21:31:17.689628 | 2011-07-31T22:42:05 | 2011-07-31T22:42:05 | 36,944,802 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,929 | cpp | // Includes
#include "InputDevice.h"
#include "DeviceManager.h"
#include "Input.h"
#include "Output.h"
using namespace MidiMe;
/******************************
* Constructors and destructor *
******************************/
InputDevice::InputDevice(const string &name)
: m_name(name)
{
// Register this class in the device manager
DeviceManager::getInstance().registerDevice(this);
}
InputDevice::~InputDevice()
{
// Destroy the outputs
destroyOutputs();
// Unregister this class in the device manager
DeviceManager::getInstance().unregisterDevice(this);
}
/******************
* Other functions *
******************/
const OutputMap &InputDevice::getAllOutputs() const
{
return m_outputs;
}
unsigned int InputDevice::numOutputs() const
{
return m_outputs.size();
}
bool InputDevice::outputExists(unsigned int id) const
{
return m_outputs.find(id) != m_outputs.end();
}
Output *InputDevice::getOutput(unsigned int id) const
{
OutputMap::const_iterator it = m_outputs.find(id);
return (it == m_outputs.end()) ? 0 : it->second;
}
void InputDevice::addListener(Listener *pListener)
{
m_listeners.insert(pListener);
}
void InputDevice::removeListener(Listener *pListener)
{
m_listeners.erase(pListener);
}
/**********************
* Protected functions *
**********************/
bool InputDevice::sendValue(unsigned int id, real value)
{
Output *pOutput = getOutput(id);
if(!pOutput)
return false;
pOutput->sendValue(value);
fireValue(pOutput, value);
return true;
}
bool InputDevice::sendMinValue(unsigned int id)
{
Output *pOutput = getOutput(id);
if(!pOutput)
return false;
pOutput->sendMinValue();
fireMinValue(pOutput);
return true;
}
bool InputDevice::sendMaxValue(unsigned int id)
{
Output *pOutput = getOutput(id);
if(!pOutput)
return false;
pOutput->sendMaxValue();
fireMaxValue(pOutput);
return true;
}
Output *InputDevice::addOutput(unsigned int id, bool analog)
{
if(outputExists(id))
return 0;
Output *pOutput = new Output(analog);
m_outputs[id] = pOutput;
return pOutput;
}
void InputDevice::destroyOutputs()
{
OutputMap::iterator it;
for(it = m_outputs.begin(); it != m_outputs.end(); ++it)
delete it->second;
m_outputs.clear();
}
void InputDevice::fireValue(Output *pOutput, real value)
{
ListenerSet::iterator it;
for(it = m_listeners.begin(); it != m_listeners.end(); ++it)
(*it)->onValue(pOutput, value);
}
void InputDevice::fireMinValue(Output *pOutput)
{
real value = 0;
ListenerSet::iterator it;
for(it = m_listeners.begin(); it != m_listeners.end(); ++it)
(*it)->onValue(pOutput, value);
}
void InputDevice::fireMaxValue(Output *pOutput)
{
real value = 1;
ListenerSet::iterator it;
for(it = m_listeners.begin(); it != m_listeners.end(); ++it)
(*it)->onValue(pOutput, value);
}
| [
"Jeroen.Dierckx@d8a2fbcc-2753-0410-82a0-8bc2cd85795f"
]
| [
[
[
1,
146
]
]
]
|
5adf6c1b4322aa632a293dd584bf5ae3e8873835 | 91b964984762870246a2a71cb32187eb9e85d74e | /SRC/OFFI SRC!/_Interface/WndBlessingCancel.cpp | 5c4a5e3e73a56441958c1a6096d3dc2d48349165 | []
| no_license | 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 | UHC | C++ | false | false | 5,325 | cpp | #include "stdafx.h"
#include "resData.h"
#include "WndBlessingCancel.h"
#include "DPClient.h"
#include "defineText.h"
#include "randomoption.h"
#if __VER >= 11 // __SYS_IDENTIFY
extern CDPClient g_DPlay;
/****************************************************
WndId : APP_CALCEL_BLESSING - 아이템 각성
CtrlId : WIDC_CHANGE -
CtrlId : WIDC_DESC -
CtrlId : WIDC_START -
****************************************************/
CWndBlessingCancel::CWndBlessingCancel()
{
m_pItemElem = NULL;
m_pEItemProp = NULL;
m_pText = NULL;
m_pTexture = NULL;
}
CWndBlessingCancel::~CWndBlessingCancel()
{
}
void CWndBlessingCancel::OnDraw( C2DRender* p2DRender )
{
LPWNDCTRL wndCtrl = GetWndCtrl( WIDC_CHANGE );
if(m_pTexture != NULL)
m_pTexture->Render( p2DRender, CPoint( wndCtrl->rect.left, wndCtrl->rect.top ) );
}
void CWndBlessingCancel::OnInitialUpdate()
{
CWndNeuz::OnInitialUpdate();
// 여기에 코딩하세요
CWndButton* pButton = (CWndButton*)GetDlgItem(WIDC_START);
if(::GetLanguage() == LANG_FRE)
pButton->SetTexture(g_Neuz.m_pd3dDevice, MakePath( "Theme\\", ::GetLanguage(), _T( "ButOk2.bmp" ) ), TRUE);
pButton->EnableWindow(FALSE);
m_pText = (CWndText*)GetDlgItem( WIDC_DESC );
SetDescription();
// 윈도를 중앙으로 옮기는 부분.
CRect rectRoot = m_pWndRoot->GetLayoutRect();
CRect rectWindow = GetWindowRect();
CPoint point( rectRoot.right - rectWindow.Width(), 110 );
Move( point );
MoveParentCenter();
}
// 처음 이 함수를 부르면 윈도가 열린다.
BOOL CWndBlessingCancel::Initialize( CWndBase* pWndParent, DWORD /*dwWndId*/ )
{
// Daisy에서 설정한 리소스로 윈도를 연다.
return CWndNeuz::InitDialog( g_Neuz.GetSafeHwnd(), APP_CANCEL_BLESSING, 0, CPoint( 0, 0 ), pWndParent );
}
/*
직접 윈도를 열때 사용
BOOL CWndBlessingCancel::Initialize( CWndBase* pWndParent, DWORD dwWndId )
{
CRect rectWindow = m_pWndRoot->GetWindowRect();
CRect rect( 50 ,50, 300, 300 );
SetTitle( _T( "title" ) );
return CWndNeuz::Create( WBS_THICKFRAME | WBS_MOVE | WBS_SOUND | WBS_CAPTION, rect, pWndParent, dwWndId );
}
*/
void CWndBlessingCancel::OnDestroy()
{
if(m_pItemElem != NULL)
{
if( !g_pPlayer->m_vtInfo.IsTrading( m_pItemElem ) )
m_pItemElem->SetExtra(0);
}
}
BOOL CWndBlessingCancel::OnCommand( UINT nID, DWORD dwMessage, CWndBase* pWndBase )
{
return CWndNeuz::OnCommand( nID, dwMessage, pWndBase );
}
void CWndBlessingCancel::OnSize( UINT nType, int cx, int cy )
{
CWndNeuz::OnSize( nType, cx, cy );
}
void CWndBlessingCancel::OnLButtonUp( UINT nFlags, CPoint point )
{
}
void CWndBlessingCancel::OnLButtonDown( UINT nFlags, CPoint point )
{
}
BOOL CWndBlessingCancel::OnChildNotify( UINT message, UINT nID, LRESULT* pLResult )
{
if( nID == WIDC_START )
{
//서버로 시작을 알린다.
if(m_pItemElem != NULL)
{
CWndButton* pButton;
pButton = (CWndButton*)GetDlgItem( WIDC_START );
pButton->EnableWindow(FALSE);
// 서버에 처리 요청하는 함수 호출해야함
if(m_pItemElem)
{
g_DPlay.SendBlessednessCancel(m_pItemElem->m_dwObjId);
Destroy();
g_WndMng.PutString( prj.GetText(TID_GAME_BLESSEDNESS_CANCEL_INFO), NULL, 0xff0000ff );
}
}
}
return CWndNeuz::OnChildNotify( message, nID, pLResult );
}
void CWndBlessingCancel::OnLButtonDblClk( UINT nFlags, CPoint point )
{
if(!m_pItemElem) return;
CRect rect;
LPWNDCTRL wndCtrl = GetWndCtrl( WIDC_CHANGE );
rect = wndCtrl->rect;
if( rect.PtInRect( point ) )
{
m_pItemElem->SetExtra(0);
CWndButton* pButton = (CWndButton*)GetDlgItem(WIDC_START);
pButton->EnableWindow(FALSE);
m_pItemElem = NULL;
m_pEItemProp = NULL;
m_pTexture = NULL;
}
}
BOOL CWndBlessingCancel::OnDropIcon( LPSHORTCUT pShortcut, CPoint point )
{
CItemElem* pTempElem;
pTempElem = (CItemElem*)g_pPlayer->GetItemId( pShortcut->m_dwId );
if( g_xRandomOptionProperty->GetRandomOptionKind( pTempElem ) == CRandomOptionProperty::eBlessing
&& g_xRandomOptionProperty->GetRandomOptionSize( pTempElem->GetRandomOptItemId() ))
{
// 하락 상태가 된 아이템만 올릴 수 있다.
if(pTempElem != NULL)
{
if(m_pItemElem) m_pItemElem->SetExtra(0);
m_pItemElem = pTempElem;
m_pEItemProp = m_pItemElem->GetProp();
m_pItemElem->SetExtra(m_pItemElem->GetExtra()+1);
CWndButton* pButton = (CWndButton*)GetDlgItem(WIDC_START);
pButton->EnableWindow(TRUE);
LPWNDCTRL wndCtrl = GetWndCtrl( WIDC_CHANGE );
if(m_pEItemProp != NULL)
{
m_pTexture = CWndBase::m_textureMng.AddTexture( g_Neuz.m_pd3dDevice, MakePath( DIR_ITEM, m_pEItemProp->szIcon), 0xffff00ff );
}
}
}
else
{
g_WndMng.PutString( prj.GetText(TID_GAME_BLESSEDNESS_CANCEL), NULL, 0xffff0000 );
return FALSE;
}
return TRUE;
}
void CWndBlessingCancel::SetDescription()
{
CScript scanner;
BOOL checkflag;
CHAR* szChar;
checkflag = scanner.Load( MakePath( DIR_CLIENT, _T( "ItemBlessingCancel.inc" ) ));
szChar = scanner.m_pProg;
if(m_pText != NULL && checkflag)
{
m_pText->m_string.AddParsingString( szChar );
m_pText->ResetString();
}
}
#endif
| [
"[email protected]@e2c90bd7-ee55-cca0-76d2-bbf4e3699278"
]
| [
[
[
1,
198
]
]
]
|
6d2b5fe2e159a1480813b01da69a4148baabe79e | 69fa2399112f2f4eda3731eef1d783d25dd4c9ca | /src/bmp.cpp | eca336027838167a236da21dec84e148c3970401 | [
"ISC"
]
| permissive | OpenSourceCancer/lcp | 082f930bef5d7cd739509c7a7a23ed141567d851 | 2faaf7dab7597f8a1796e74aa651cfff3ca0777a | refs/heads/master | 2021-01-18T11:12:30.344747 | 2010-11-01T01:19:49 | 2010-11-01T01:19:49 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,486 | cpp | /*
* read/write access to 512x512 bitmaps.
*
* Copyright (c) 2009 Vedant Kumar <[email protected]>
*/
#include "image.hpp"
static Word bfType;
static DWord bfSize = 19778;
static Word bfReserved1 = 0;
static Word bfReserved2 = 0;
static DWord bfOffBits;
static DWord biSize;
static DWord biWidth = 512;
static DWord biHeight = 512;
static Word biPlanes = 1;
static Word biBitCount = 8;
static DWord biCompression = 0;
static DWord biSizeImage;
static DWord biXPelsPerMeter = 3780;
static DWord biYPelsPerMeter = 3780;
static DWord biClrUsed = 0;
static DWord biClrImportant = 0;
static rgbaPix temp;
img* bmp_read(FILE* fptr) {
img* dat;
try {
dat = new img;
} catch (bad_alloc& err) {
img_err("*bmp", "OOM");
return NULL;
}
s_fread((char*) &bfType, sizeof(Word), 1, fptr);
s_fread((char*) &bfSize, sizeof(DWord), 1, fptr);
s_fread((char*) &bfReserved1, sizeof(Word), 1, fptr);
s_fread((char*) &bfReserved2, sizeof(Word), 1, fptr);
s_fread((char*) &bfOffBits, sizeof(DWord), 1 , fptr);
s_fread((char*) &biSize, sizeof(DWord), 1, fptr);
s_fread((char*) &biWidth, sizeof(DWord), 1, fptr);
s_fread((char*) &biHeight, sizeof(DWord), 1, fptr);
s_fread((char*) &biPlanes, sizeof(Word), 1, fptr);
s_fread((char*) &biBitCount, sizeof(Word), 1, fptr);
s_fread((char*) &biCompression, sizeof(DWord), 1, fptr);
s_fread((char*) &biSizeImage, sizeof(DWord), 1, fptr);
s_fread((char*) &biXPelsPerMeter, sizeof(DWord), 1, fptr);
s_fread((char*) &biYPelsPerMeter, sizeof(DWord), 1, fptr);
s_fread((char*) &biClrUsed, sizeof(DWord), 1, fptr);
s_fread((char*) &biClrImportant, sizeof(DWord), 1, fptr);
if (biCompression >= 1 || biWidth != 512 || biHeight != 512 || (biBitCount != 8 && biBitCount != 24)) {
img_err("~*.bmp", "Unsupported BMP Binary.");
}
if (biBitCount < 16) {
for (ushort n=0; n < 256; ++n) {
s_fread((char*) &temp, 4, 1, fptr);
}
}
for (int j=511; j > -1; --j) {
if (biBitCount == 8) {
s_fread((char*) Buffer, 1, 512, fptr);
for (ushort i=0; i < 512; ++i) {
dat->pix[j][i] = Buffer[i];
// dat.hist[ Buffer[i] ] += 1;
}
} else if (biBitCount == 24) {
s_fread((char*) Buffer24, 1, (512 * 24) / 8, fptr);
for (ushort i=0; i < 512; ++i) {
memcpy((char*) &temp, Buffer24 + 3 * i, 3);
dat->pix[j][i] = temp.r;
// dat.hist[ dat.pix[j][i] ] += 1;
}
}
}
fclose(fptr);
return dat;
}
bool bmp_write(img* dat, FILE* fptr) {
fwrite((char*) &bfType, 2, 1, fptr);
fwrite((char*) &bfSize, 4, 1, fptr);
fwrite((char*) &bfReserved1, 2, 1, fptr);
fwrite((char*) &bfReserved2, 2, 1, fptr);
fwrite((char*) &bfOffBits, 4, 1, fptr);
fwrite((char*) &biSize, 4, 1, fptr);
fwrite((char*) &biWidth, 4, 1, fptr);
fwrite((char*) &biHeight, 4, 1, fptr);
fwrite((char*) &biPlanes, 2, 1, fptr);
fwrite((char*) &biBitCount, 2, 1, fptr);
fwrite((char*) &biCompression, 4, 1, fptr);
fwrite((char*) &biSizeImage, 4, 1, fptr);
fwrite((char*) &biXPelsPerMeter, 4, 1, fptr);
fwrite((char*) &biYPelsPerMeter, 4, 1, fptr);
fwrite((char*) &biClrUsed, 4, 1, fptr);
fwrite((char*) &biClrImportant, 4, 1, fptr);
for (ushort n=0; n < 256; ++n) {
temp = numToRGBA(n);
fwrite((char*) &temp, 4, 1, fptr);
}
for (int j=511; j > -1; --j) {
for (ushort i=0; i < 512; ++i) {
Buffer[i] = dat->pix[j][i];
}
fwrite((char*) Buffer, 1, 512, fptr);
}
fclose(fptr);
return true;
}
| [
"[email protected]"
]
| [
[
[
1,
119
]
]
]
|
f37876102df0cec8d45ea0f56f0ce1bc87a6b69e | 8a816dc2da5158e8d4f2081e6086575346869a16 | /RenderCSM/RenderCSMMFC/RenderCSMMFC.h | eaf8d95a0070ab4db5b4c8cae74663f79f10a8b3 | []
| 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 | UTF-8 | C++ | false | false | 609 | h | // RenderCSMMFC.h : main header file for the RenderCSMMFC application
//
#pragma once
#ifndef __AFXWIN_H__
#error "include 'stdafx.h' before including this file for PCH"
#endif
#include "resource.h" // main symbols
// CRenderCSMMFCApp:
// See RenderCSMMFC.cpp for the implementation of this class
//
class CRenderCSMMFCApp : public CWinApp
{
public:
CRenderCSMMFCApp();
// Overrides
public:
virtual BOOL InitInstance();
// Implementation
afx_msg void OnAppAbout();
DECLARE_MESSAGE_MAP()
virtual BOOL OnIdle( LONG lCount );
};
extern CRenderCSMMFCApp theApp; | [
"[email protected]@4008efc8-90d6-34c1-d252-cb7169c873e6"
]
| [
[
[
1,
32
]
]
]
|
70627c4b9b4f29242b48776762296aebdf66ef2f | ffb363eadafafb4b656355b881395f8d59270f55 | /my/test/test_matrix_slice_2.cpp | fd49c88d766b830002d110b26a0492e56b7d304e | [
"MIT"
]
| permissive | hanji/matrix | 1c28830eb4fdb7eefe21b2f415a9ec354e18f168 | 9f3424628ab182d249c62aeaf4beb4fb2d073518 | refs/heads/master | 2023-08-08T07:36:26.581667 | 2009-12-03T06:25:24 | 2009-12-03T06:25:24 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,306 | cpp | #include <iostream>
#include <cstdlib>
#include <complex>
#include "static_if.hpp"
#include "countof.hpp"
#include "my/real_traits.hpp"
#include "my/vector.hpp"
#include "my/matrix.hpp"
template <typename T, size_t M, size_t N>
void foo(T(&a)[M][N])
{
std::size_t s[] = {1,2,3,0}, t[] = {0,1,2};
std::size_t u[] = {0,1,2,3}, v[] = {0,1,2};
my::matrix<T,M,N> m( (const T(&)[M][N]) a[0][0] );
// explicit usage of matrix_slice objects
// is for testing purpose only
// use 'matrix-name(row-indices, col-indices)' for client code
my::matrix_slice<T,M,N,countof(s),countof(t)> ms(m, s, t);
my::matrix_slice<T,M,N,countof(u),countof(v)> ms1(m, u, my_range(0,3,1));
std::cout << my_range(0,10,1) << std::endl;
std::cout << " m = \n" << m << std::endl;
std::cout << " ms = \n" << ms << std::endl;
std::cout << " ms1 = \n" << ms1 << std::endl;
ms = m;
std::cout << " m = \n" << m << std::endl;
std::cout << " ms = \n" << ms << std::endl;
ms += m;
std::cout << " m = \n" << m << std::endl;
std::cout << " ms = \n" << ms << std::endl;
ms -= m;
std::cout << " m = \n" << m << std::endl;
std::cout << " ms = \n" << ms << std::endl;
m = ms;
std::cout << " m = \n" << m << std::endl;
std::cout << " ms = \n" << ms << std::endl;
m += ms;
std::cout << " m = \n" << m << std::endl;
std::cout << " ms = \n" << ms << std::endl;
m -= ms;
std::cout << " m = \n" << m << std::endl;
std::cout << " ms = \n" << ms << std::endl;
ms = ms1;
std::cout << " m = \n" << m << std::endl;
std::cout << " ms = \n" << ms << std::endl;
std::cout << " ms1 = \n" << ms1 << std::endl;
ms += ms1;
std::cout << " m = \n" << m << std::endl;
std::cout << " ms = \n" << ms << std::endl;
std::cout << " ms1 = \n" << ms1 << std::endl;
ms -= ms1;
std::cout << " m = \n" << m << std::endl;
std::cout << " ms = \n" << ms << std::endl;
std::cout << " ms1 = \n" << ms1 << std::endl;
}
template <typename T, typename U>
void test2()
{
T b[][3] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 };
foo(b);
}
int main()
{
test2<double,double>();
return 0;
}
| [
"hanji1984@2159fae2-c2cd-11de-acfc-b766374499fb"
]
| [
[
[
1,
95
]
]
]
|
cbcbf39699d04f912d030b6297ccba20d9896da9 | b7c505dcef43c0675fd89d428e45f3c2850b124f | /Src/SimulatorQt/Util/qt/Win32/include/Qt/qcolumnview.h | 57681f9e8c2b9ad5002e741157c3b7f05d72c554 | [
"BSD-2-Clause"
]
| permissive | pranet/bhuman2009fork | 14e473bd6e5d30af9f1745311d689723bfc5cfdb | 82c1bd4485ae24043aa720a3aa7cb3e605b1a329 | refs/heads/master | 2021-01-15T17:55:37.058289 | 2010-02-28T13:52:56 | 2010-02-28T13:52:56 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 4,503 | h | /****************************************************************************
**
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
** Contact: Qt Software Information ([email protected])
**
** This file is part of the QtGui module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** Commercial Usage
** Licensees holding valid Qt Commercial licenses may use this file in
** accordance with the Qt Commercial License Agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Nokia.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Nokia gives you certain
** additional rights. These rights are described in the Nokia Qt LGPL
** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
** package.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3.0 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU General Public License version 3.0 requirements will be
** met: http://www.gnu.org/copyleft/gpl.html.
**
** If you are unsure which license is appropriate for your use, please
** contact the sales department at [email protected].
** $QT_END_LICENSE$
**
****************************************************************************/
#ifndef QCOLUMNVIEW_H
#define QCOLUMNVIEW_H
#include <QtGui/qabstractitemview.h>
QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
QT_MODULE(Gui)
#ifndef QT_NO_COLUMNVIEW
class QColumnViewPrivate;
class Q_GUI_EXPORT QColumnView : public QAbstractItemView {
Q_OBJECT
Q_PROPERTY(bool resizeGripsVisible READ resizeGripsVisible WRITE setResizeGripsVisible)
Q_SIGNALS:
void updatePreviewWidget(const QModelIndex &index);
public:
explicit QColumnView(QWidget *parent = 0);
~QColumnView();
// QAbstractItemView overloads
QModelIndex indexAt(const QPoint &point) const;
void scrollTo(const QModelIndex &index, ScrollHint hint = EnsureVisible);
QSize sizeHint() const;
QRect visualRect(const QModelIndex &index) const;
void setModel(QAbstractItemModel *model);
void setSelectionModel(QItemSelectionModel * selectionModel);
void setRootIndex(const QModelIndex &index);
void selectAll();
// QColumnView functions
void setResizeGripsVisible(bool visible);
bool resizeGripsVisible() const;
QWidget *previewWidget() const;
void setPreviewWidget(QWidget *widget);
void setColumnWidths(const QList<int> &list);
QList<int> columnWidths() const;
protected:
QColumnView(QColumnViewPrivate &dd, QWidget *parent = 0);
// QAbstractItemView overloads
bool isIndexHidden(const QModelIndex &index) const;
QModelIndex moveCursor(CursorAction cursorAction, Qt::KeyboardModifiers modifiers);
void resizeEvent(QResizeEvent *event);
void setSelection(const QRect & rect, QItemSelectionModel::SelectionFlags command);
QRegion visualRegionForSelection(const QItemSelection &selection) const;
int horizontalOffset() const;
int verticalOffset() const;
void scrollContentsBy(int dx, int dy);
// QColumnView functions
virtual QAbstractItemView* createColumn(const QModelIndex &rootIndex);
void initializeColumn(QAbstractItemView *column) const;
protected Q_SLOTS:
// QAbstractItemView overloads
void currentChanged(const QModelIndex ¤t, const QModelIndex &previous);
private:
Q_DECLARE_PRIVATE(QColumnView)
Q_DISABLE_COPY(QColumnView)
Q_PRIVATE_SLOT(d_func(), void _q_gripMoved(int))
Q_PRIVATE_SLOT(d_func(), void _q_changeCurrentColumn())
Q_PRIVATE_SLOT(d_func(), void _q_clicked(const QModelIndex &))
};
#endif // QT_NO_COLUMNVIEW
QT_END_NAMESPACE
QT_END_HEADER
#endif // QCOLUMNVIEW_H
| [
"alon@rogue.(none)"
]
| [
[
[
1,
125
]
]
]
|
f1753beb2060bfa4d3d3e8ce1cbd4378bb8bbd11 | 2403c4aa6404b44881e6bff3eb78d1386b2f82ee | / gogo-dolo --username [email protected]/DoloPocoCN.h | c91d34b49da153025f2c65caa685e300dd2d11f6 | []
| no_license | duwu/gogo-dolo | 8ee505bb07b3cffbfb9e1f5be301b3becc3919f6 | a15cbfa5a725a0ed20cba2e76115dc9ab4f6f7bc | refs/heads/master | 2016-09-12T17:36:16.027532 | 2011-05-24T07:30:27 | 2011-05-24T07:30:27 | 57,050,398 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 210 | h | #pragma once
#include "dolo.h"
class CDoloPocoCN :
public CDolo
{
public:
CDoloPocoCN(void);
~CDoloPocoCN(void);
bool SearchLayer1(CString &str_url);
bool SearchLayer3(CString &str_url);
};
| [
"[email protected]"
]
| [
[
[
1,
13
]
]
]
|
7bb2d8091151ed48ad5808ddb50c533f81504c6b | cdd3d4c40db6a0eee7ad679f57adc2b5d1159349 | /src/graffitiControlPanel.cpp | fe1ee739f074c41cefb697e0ffbfd7737b772b0b | []
| no_license | golanlevin/GMLStenciler | 4227fc348f6a1de4c3c4a651ab5caa68bbfe4934 | dfac16a260b71da0c4cb01c1b12547dbe5fedfd7 | refs/heads/master | 2021-01-01T16:50:16.519166 | 2010-07-04T22:19:39 | 2010-07-04T22:19:39 | 752,227 | 6 | 1 | null | 2014-03-02T20:39:14 | 2010-07-01T20:57:49 | C++ | UTF-8 | C++ | false | false | 3,880 | cpp | #include "graffitiControlPanel.h"
graffitiControlPanel::graffitiControlPanel(vars *v) {
myVars = v;
}
void graffitiControlPanel::startGUI() {
files.listDirWithExtension(".", ".gml");
//files.listDir(".");//our GMLs should be in data by default anyway. Add user input later
gui = new ofxControlPanel();
gui->notify();
gui->setup("GMLStenciler", ofGetWidth() - myVars->controlWidth - 4, 4, myVars->controlWidth, myVars->controlHeight);
string instructionString = " INSTRUCTIONS:\n";
instructionString += " [All in/out files are in 'data' folder]\n";
instructionString += " Load a .gml file from list below;\n";
instructionString += " Scale drawing using scale slider;\n";
instructionString += " Enable & adjust thickness;\n";
instructionString += " Enable bridges & select bridge type;\n";
instructionString += " Adjust bridge thickness if desired;\n";
instructionString += " Export with 'SAVE EPS' button.\n";
gui->addPanel(instructionString, 2, false);
gui->setWhichPanel(0);
//----------------------------
gui->setWhichColumn(0);
gui->addSlider("Thickness","THICKNESS",myVars->thickness,1,12,false);
gui->addSlider("Hole threshold","THRESHOLD",myVars->threshold,0,5000,false);
gui->addSlider("Bridge thickness","CONTOUR_THICKNESS", myVars->contourThickness, 1,20,false);
gui->addSlider("Scale factor","SCALE_FACTOR", myVars->scaleFactor, 1, 1000,false);
gui->addFileLister("Loadable GML files",&files,180,100);
gui->addToggle("SAVE EPS!","SAVE",false);
//----------------------------
gui->setWhichColumn(1);
gui->addToggle("Enable Thickness","THICKEN?",false);
gui->addToggle("Show holes","SHOW_HOLES?",false);
gui->addToggle("Enable bridges","CONTOURS?",false);
gui->addToggle("-- Bridge Close","CBRIDGE",false);
gui->addToggle("-- Bridge High" ,"HBRIDGE",false);
gui->addToggle("-- Bridge Low" ,"BBRIDGE",false);
gui->addToggle("-- Bridge Left" ,"LBRIDGE",false);
gui->addToggle("-- Bridge Right","RBRIDGE",false);
}
void graffitiControlPanel::updateGUI() {
myVars->thickness = gui->getValueF("THICKNESS");
myVars->contourThickness = gui->getValueF("CONTOUR_THICKNESS");
myVars->threshold = gui->getValueF("THRESHOLD");
myVars->scaleFactor = gui->getValueF("SCALE_FACTOR");
myVars->thickenOn = gui->getValueB("THICKEN?");
myVars->contoursOn = gui->getValueB("CONTOURS?");
myVars->showHoles = gui->getValueB("SHOW_HOLES?");
myVars->findClosestBridge = gui->getValueB("CBRIDGE");
myVars->highestBridge = gui->getValueB("HBRIDGE");
myVars->lowestBridge = gui->getValueB("BBRIDGE");
myVars->leftMostBridge = gui->getValueB("LBRIDGE");
myVars->rightMostBridge = gui->getValueB("RBRIDGE");
myVars->save = gui->getValueB("SAVE");
if(files.selectedHasChanged()) {
char *a = new char[files.getSelectedPath().size()+1];
a[files.getSelectedPath().size()] = 0;
memcpy(a,files.getSelectedPath().c_str(),files.getSelectedPath().size());
myVars->fileName = a;
myVars->fileChanged = true;
//all the values get reset when you load a new image in order to make it faster to load
gui->setValueB("THICKEN?",false);
gui->setValueB("CONTOURS?",false);
gui->setValueB("SHOW_HOLES?",false);
gui->setValueB("CBRIDGE",false);
gui->setValueB("HBRIDGE",false);
gui->setValueB("BBRIDGE",false);
gui->setValueB("LBRIDGE",false);
gui->setValueB("RBRIDGE",false);
}
gui->setValueB("SAVE",false);
gui->update();
files.clearChangedFlag();
}
void graffitiControlPanel::drawGUI() {
gui->draw();
}
void graffitiControlPanel::mouseDragged(int x, int y, int button) {
gui->mouseDragged(x,y,button);
}
void graffitiControlPanel::mousePressed(int x, int y, int button) {
gui->mousePressed(x,y,button);
}
void graffitiControlPanel::mouseReleased() {
gui->mouseReleased();
} | [
"[email protected]"
]
| [
[
[
1,
105
]
]
]
|
6f843ed6380d9e653f161c04f5982ee8e131458c | dda0d7bb4153bcd98ad5e32e4eac22dc974b8c9d | /reporting/crashrpttest/crash_thread.cpp | 839a6d1687920b8f4ebdbfcd729fe4a2a377e712 | [
"BSD-3-Clause"
]
| permissive | systembugtj/crash-report | abd45ceedc08419a3465414ad9b3b6a5d6c6729a | 205b087e79eb8ed7a9b6a7c9f4ac580707e9cb7e | refs/heads/master | 2021-01-19T07:08:04.878028 | 2011-04-05T04:03:54 | 2011-04-05T04:03:54 | 35,228,814 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,624 | cpp | /*************************************************************************************
This file is a part of CrashRpt library.
Copyright (c) 2003, Michael Carruth
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 author 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 COPYRIGHT HOLDERS AND CONTRIBUTORS "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 COPYRIGHT HOLDER OR CONTRIBUTORS 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 "stdafx.h"
#include "crash_thread.h"
#include <exception>
#include <signal.h>
#include <assert.h>
// Tests crExceptionFilter
void TestSEH() {
__try
{
int nResult = crEmulateCrash(CR_NONCONTINUABLE_EXCEPTION);
if(nResult!=0)
{
MessageBox(NULL, _T("Error raising noncontinuable exception!"), _T("Error"), 0);
}
}
__except(crExceptionFilter(GetExceptionCode(), GetExceptionInformation()))
{
// Terminate program
ExitProcess(1);
}
}
// Tests crGenerateErrorReport
void TestGenerateReport() {
CR_EXCEPTION_INFO ei;
memset(&ei, 0, sizeof(CR_EXCEPTION_INFO));
ei.cb = sizeof(CR_EXCEPTION_INFO);
ei.exctype = CR_SEH_EXCEPTION;
ei.code = 0x1234;
ei.pexcptrs = NULL;
ei.bManual = TRUE; // Signal the report is being generated manually.
int nResult = crGenerateErrorReport(&ei);
if (nResult != 0) {
TCHAR szErrorMsg[256];
CString sError = _T("Error generating error report!\nErrorMsg:");
crGetLastErrorMsg(szErrorMsg, 256);
sError += szErrorMsg;
MessageBox(NULL, sError, 0, 0);
}
}
DWORD WINAPI CrashThread(LPVOID pParam) {
CrashThreadInfo* pInfo = (CrashThreadInfo*) pParam;
crash_report::CrThreadAutoInstallHelper cr_install_helper(0);
for (;;) {
WaitForSingleObject(pInfo->m_hWakeUpEvent, INFINITE);
if (pInfo->m_bStop)
break;
if (pInfo->m_ExceptionType == 128) {
TestGenerateReport();
} else if (pInfo->m_ExceptionType == CR_NONCONTINUABLE_EXCEPTION) {
TestSEH();
} else if (crEmulateCrash(pInfo->m_ExceptionType) != 0) {
TCHAR szErrorMsg[256];
CString sError = _T("Error creating exception situation!\nErrorMsg:");
crGetLastErrorMsg(szErrorMsg, 256);
sError += szErrorMsg;
MessageBox(NULL, sError, _T("Error"), 0);
}
}
return 0;
}
| [
"[email protected]@9307afbf-8b4c-5d34-949b-c69a0924eb0b"
]
| [
[
[
1,
100
]
]
]
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.