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
8f2daf0d35ee61736056b89c3d69b4977b7f85d4
acf0e8a6d8589532d5585b28ec61b44b722bf213
/mod_eval_panfilter/profiling.cpp
a6ef8be54b3ee60fb5dff5faee82b7a6bf09f861
[]
no_license
mchouza/ngpd
0f0e987a95db874b3cde4146364bf1d69cf677cb
5cca5726910bfc97844689f1f40c94b27e0fb9f9
refs/heads/master
2016-09-06T02:09:32.007855
2008-04-06T14:17:55
2008-04-06T14:17:55
35,064,755
0
0
null
null
null
null
UTF-8
C++
false
false
1,983
cpp
// // Copyright (c) 2008, Mariano M. Chouza // 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. // // * The names of the contributors 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 COPYRIGHT OWNER 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. // //============================================================================= // profiling.cpp //----------------------------------------------------------------------------- // Creado por Mariano M. Chouza | Agregado a NGPD el 6 de abril de 2008 //============================================================================= #define MY_PROFILER_STORAGE #include "profiling.h"
[ "mchouza@b858013c-4649-0410-a850-dde43e08a396" ]
[ [ [ 1, 39 ] ] ]
4dc434d3323e2194aef444523db53b517637fa61
160e08f968425ae7b8e83f7381c617906b4e9f18
/TimeServices.Engine.Cpu/EngineXAdd.cpp
34400053f755d0b3382f9e17466719a67eca1159
[]
no_license
m3skine/timeservices
0f6a938a25a49a0cad884e2ae9fb1fff4a8a08fe
1efca945a2121cd7f45c05387503ea8ef66541e6
refs/heads/master
2020-04-10T20:06:24.326180
2010-04-21T01:12:44
2010-04-21T01:12:44
33,272,683
0
0
null
null
null
null
UTF-8
C++
false
false
2,345
cpp
#include "Engine.h" namespace TimeServices { namespace Engine { void Engine::AddValue(LinkKind* value, unsigned long time) { //Console::WriteLine(L"Timeline: Add {" + time.ToString() + L"}"); unsigned long slice = (time >> TimePrecision::TimePrecisionBits); unsigned long fraction = (time & TimePrecision::TimePrecisionMask); if (slice < EngineSettings::MaxTimeslices) { // time is fractional only // enhance: could check for existance in hash if ((slice == 0) && (fraction < _maxWorkingFraction)) _rebuildWorkingFractions = true; // roll timeslice for index slice += _sliceIndex; if (slice >= EngineSettings::MaxTimeslices) slice -= EngineSettings::MaxTimeslices; SliceFractions* fractions = &_slices[slice].Fractions; // add to list SliceNode* node = nullptr; if (!fractions->TryGetValue(fraction, node)) { value->NextLink = nullptr; fractions->Add(fraction, value); } else LinkKind::AddFirst(node->Chain, value); return; } HibernateValue(value, time); } void Engine::AddValue(ListKind* value, unsigned long time) { //Console::WriteLine(L"Timeline: Add {" + time.ToString() + L"}"); unsigned long slice = (time >> TimePrecision::TimePrecisionBits); unsigned long fraction = (time & TimePrecision::TimePrecisionMask); if (slice < EngineSettings::MaxTimeslices) { // time is fractional only // enhance: could check for existance in hash if ((slice == 0) && (fraction < _maxWorkingFraction)) _rebuildWorkingFractions = true; // roll timeslice for index slice += _sliceIndex; if (slice >= EngineSettings::MaxTimeslices) slice -= EngineSettings::MaxTimeslices; SliceFractions* fractions = &_slices[slice].Fractions; // add to list SliceNode* node = nullptr; if (!fractions->TryGetValue(fraction, node)) fractions->Add(fraction, value); else { ListKind::List* list = node->List; if (list == nullptr) list = node->List = new ListKind::List(); list->Add(value); } return; } HibernateValue(value, time); } }}
[ "Moreys@localhost" ]
[ [ [ 1, 64 ] ] ]
d832293b264ee2dfe08a17ff7245fca4502d5831
0dba4a3016f3ad5aa22b194137a72efbc92ab19e
/a2e/src/xml.h
8bf089475603403a734e3f61087fc011926c38c7
[]
no_license
BackupTheBerlios/albion2
11e89586c3a2d93821b6a0d3332c1a7ef1af6abf
bc3d9ba9cf7b8f7579a58bc190a4abb32b30c716
refs/heads/master
2020-12-30T10:23:18.448750
2007-01-26T23:58:42
2007-01-26T23:58:42
39,515,887
0
0
null
null
null
null
UTF-8
C++
false
false
1,907
h
/* * 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 Library 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. */ #ifndef __XML_H__ #define __XML_H__ #ifdef WIN32 #include <windows.h> #include <winnt.h> #endif #include <iostream> #include <string> #include <cmath> #include <libxml/encoding.h> #include <libxml/xmlreader.h> #include <libxml/xmlwriter.h> #include "msg.h" #include "core.h" #include "win_dll_export.h" using namespace std; /*! @class xml * @brief xml functions * @author flo * * some functions for parsing xml files, etc. ... */ class A2E_API xml { public: xml(msg* m); ~xml(); // for reading bool open(char* filename); void close(); bool process(); void end(int ret); char* get_node_name(); int get_attribute_count(); const char* get_attribute(char* att_name); char* get_nattribute(unsigned int num); // for writing bool open_write(char* filename); void close_write(); void start_element(const char* name); void end_element(); void write_attribute(const char* attribute, const char* value); protected: msg* m; core* c; xmlTextReaderPtr* reader; xmlTextWriterPtr* writer; char* fname; char* fname_write; unsigned int inner_loop; }; #endif
[ [ [ 1, 81 ] ] ]
db9818ba64f3ecc1635b82f4cc1899d6efa13d0d
6dac9369d44799e368d866638433fbd17873dcf7
/testsuite/trunk/Network/FusionChat/FusionChat.h
e055d42f8f7efecae772ed349ff3cc8aa8d3c2b4
[]
no_license
christhomas/fusionengine
286b33f2c6a7df785398ffbe7eea1c367e512b8d
95422685027bb19986ba64c612049faa5899690e
refs/heads/master
2020-04-05T22:52:07.491706
2006-10-24T11:21:28
2006-10-24T11:21:28
null
0
0
null
null
null
null
UTF-8
C++
false
false
3,796
h
#ifndef _FUSIONCHAT_H_ #define _FUSIONCHAT_H_ #include <Fusion.h> // GTK+ headers #include <gtk/gtk.h> #include <gdk/gdk.h> #include <glib.h> #include <glade/glade.h> // STL Headers #include <string> #include <sstream> #include <iostream> #include <map> // EXPORT define, for win32 and unix platforms #ifdef _WIN32 #define EXPORT extern "C" __declspec(dllexport) #else #define EXPORT extern "C" #endif const unsigned int msgMaxLen = 8912; struct ChatPacket{ // The length of the packet, when fully downloaded unsigned int length; // The length of data currently downloaded (always < length) unsigned int curlen; // The buffer to be downloaded into char buffer[msgMaxLen]; }; struct ChatSocket{ // Socket used to communicate with client/server IClientSocket *socket; // The send packet ChatPacket send; // The recv packet ChatPacket recv; // The username associated with this socket std::string userName; }; typedef std::vector<ChatSocket> chatsocket_t; struct FCState{ IServerSocket *server; ChatSocket client; chatsocket_t remote; bool enableClient; bool enableServer; bool connected; unsigned int port; std::string username; std::string id; unsigned int dconnect; bool quit; }; extern FCState state; extern unsigned int netLatency; // User Interface functions void initGTK(int argc, char **argv); void runGTK(GSourceFunc func); void setupApp(void); void setupOutput(void); void setupUsers(void); void insertMessage(std::string user, std::string message); bool addUser(std::string user, std::string id); bool removeUser(std::string user); bool renameUser(std::string oldUser, std::string newUser, std::string data); bool findUser(std::string user); bool findUser(std::string user, GtkTreeIter *iter); void emptyUsers(void); std::string getUserlist(void); void updateUsername(void); void updateUsername(std::string name); void setConnected(void); void setDisconnected(void); void requestConnect(void); void requestDisconnect(void); // Exported glade callbacks EXPORT void on_connect_clicked(GtkWidget *widget, gpointer data); EXPORT void on_appMode_clicked(GtkWidget *widget, gpointer data); EXPORT void on_message_activate(GtkWidget *widget, gpointer data); EXPORT void on_send_clicked(GtkWidget *widget, gpointer data); EXPORT void on_username_clicked(GtkWidget *widget, gpointer data); EXPORT void on_username_entry_focus(GtkWidget *widget, gpointer data); EXPORT void on_username_entry_activate(GtkWidget *widget, gpointer data); EXPORT void on_username_update_clicked(GtkWidget *widget, gpointer data); EXPORT void on_quit_clicked(GtkWidget *widget, gpointer data); // Network functions ChatPacket * makePacket(std::string text); void sendData(ChatPacket *packet, ChatSocket *dst, bool wait=false); void castData(ChatPacket *packet, ChatSocket *ignore); void receiveData(void); void receiveData(ChatSocket &chatSocket); std::string idstring(void *socket); void startServer(void); void stopServer(void); void addClient(IClientSocket *socket); void disconnectClient(void); void disconnectClient(ChatSocket *chatSocket); bool processNetwork(void *); // Command Functions // Breaks a string of text into components void decodeMessage(std::string text, std::string &command, std::string &option, std::string &data); // acts upon a command message sent either locally or remotely void commandMessage(std::string text, ChatSocket *socket = NULL); // sends a remote computer a command message void remoteMessage(std::string text, ChatSocket *socket = NULL, bool wait=false); // broadcasts a message to remote computers void broadcastMessage(std::string text, ChatSocket *ignore = NULL); #endif // #ifndef _FUSIONCHAT_H_
[ "chris_a_thomas@1bf15c89-c11e-0410-aefd-b6ca7aeaabe7" ]
[ [ [ 1, 126 ] ] ]
0e1c4c380a62c9f6657cf9e42447341e44acb9aa
880e5a47c23523c8e5ba1602144ea1c48c8c8f9a
/enginesrc/math/quaternion.hpp
4b05c3696edd262a6fec5fa4621c41abb963b15a
[]
no_license
kfazi/Engine
050cb76826d5bb55595ecdce39df8ffb2d5547f8
0cedfb3e1a9a80fd49679142be33e17186322290
refs/heads/master
2020-05-20T10:02:29.050190
2010-02-11T17:45:42
2010-02-11T17:45:42
null
0
0
null
null
null
null
UTF-8
C++
false
false
8,205
hpp
#ifndef ENGINE_QUATERNION_HPP #define ENGINE_QUATERNION_HPP #include "matrix4.hpp" namespace engine { class DLLEXPORTIMPORT CQuaternion { public: double W; double X; double Y; double Z; static const CQuaternion ZERO; /**< A zero quaternion. */ static const CQuaternion IDENTITY; /**< An identity quaternion. */ inline CVector3 GetVector() const { return CVector3(X, Y, Z); } //! constructors CQuaternion() { *this = IDENTITY; } CQuaternion(const double fW, const double fX, const double fY, const double fZ) { W = fW; X = fX; Y = fY; Z = fZ; } CQuaternion(const double fReal, const CVector3 &cVector) { W = fReal; X = cVector.X; Y = cVector.Y; Z = cVector.Z; } //! from 3 euler angles CQuaternion(const double fThetaZ, const double fThetaY, const double fThetaX) { FromEulerAngles(fThetaZ, fThetaY, fThetaX); } //! from 3 euler angles CQuaternion(const CVector3 &cAngles) { FromEulerAngles(cAngles); } //! from a normalized axis - angle pair rotation CQuaternion(const CVector3 &cAxis, double fAngle) { double fSinAngle = sin(fAngle / 2.0); W = cos(fAngle / 2.0); X = cAxis.X * fSinAngle; Y = cAxis.Y * fSinAngle; Z = cAxis.Z * fSinAngle; } //! basic operations CQuaternion &operator = (const CQuaternion &cQuaternion) { W = cQuaternion.W; X = cQuaternion.X; Y = cQuaternion.Y; Z = cQuaternion.Z; return *this; } /** * Quaternion negation. */ inline CQuaternion operator - () const { return CQuaternion(-W, -X, -Y, -Z); } const CQuaternion &operator += (const CQuaternion &cQuaternion) { W += cQuaternion.W; X += cQuaternion.X; Y += cQuaternion.Y; Z += cQuaternion.Z; return *this; } const CQuaternion &operator -= (const CQuaternion &cQuaternion) { W -= cQuaternion.W; X -= cQuaternion.X; Y -= cQuaternion.Y; Z -= cQuaternion.Z; return *this; } const CQuaternion &operator *= (const CQuaternion &cQuaternion) { double newW = W * cQuaternion.W - X * cQuaternion.X - Y * cQuaternion.Y - Z * cQuaternion.Z; double newX = W * cQuaternion.X + X * cQuaternion.W + Y * cQuaternion.Z - Z * cQuaternion.Y; double newY = W * cQuaternion.Y + Y * cQuaternion.W + Z * cQuaternion.X - X * cQuaternion.Z; double newZ = W * cQuaternion.Z + Z * cQuaternion.W + X * cQuaternion.Y - Y * cQuaternion.X; W = newW; X = newX; Y = newY; Z = newZ; return *this; } template<typename TType> CQuaternion &operator *= (TType tScalar) { W *= tScalar; X *= tScalar; Y *= tScalar; Z *= tScalar; return *this; } template<typename TType> CQuaternion &operator /= (TType tScalar) { W /= tScalar; X /= tScalar; Y /= tScalar; Z /= tScalar; return *this; } inline friend const CQuaternion operator + (const CQuaternion &cQuaternion1, const CQuaternion &cQuaternion2) { return CQuaternion(cQuaternion1) += cQuaternion2; } inline friend const CQuaternion operator - (const CQuaternion &cQuaternion1, const CQuaternion &cQuaternion2) { return CQuaternion(cQuaternion1) -= cQuaternion2; } inline friend const CQuaternion operator * (const CQuaternion &cQuaternion1, const CQuaternion &cQuaternion2) { return CQuaternion(cQuaternion1) *= cQuaternion2; } /** * Quaternion multiplication by a scalar. */ template<typename TType> friend CQuaternion operator * (TType tScalar, const CQuaternion &cQuaternion) { return CQuaternion(cQuaternion) *= tScalar; } /** * Quaternion multiplication by a scalar. */ template<typename TType> friend CQuaternion operator * (const CQuaternion &cQuaternion, TType tScalar) { return CQuaternion(cQuaternion) *= tScalar; } /** * Quaternion division by a scalar. */ template<typename TType> friend CQuaternion operator / (TType tScalar, const CQuaternion &cQuaternion) { return CQuaternion(cQuaternion) /= tScalar; } /** * Quaternion division by a scalar. */ template<typename TType> friend CQuaternion operator / (const CQuaternion &cQuaternion, TType tScalar) { return CQuaternion(cQuaternion) /= tScalar; } /** * Returns a length of a quaternion. */ inline double GetLength() const { return std::sqrt(W * W + X * X + Y * Y + Z * Z); } /** * Returns a length of a quaternion. */ inline double GetLengthSquared() const { return W * W + X * X + Y * Y + Z * Z; } /** * Normalizes a quaternion. */ inline void Normalize() { double fLength = GetLength(); if (fLength == 1.0 || fLength < std::numeric_limits<double>::epsilon()) return; W /= fLength; X /= fLength; Y /= fLength; Z /= fLength; } inline CQuaternion GetNormalized() const { CQuaternion cQuaternion(*this); cQuaternion.Normalize(); return cQuaternion; } void FromEulerAngles(const double fThetaZ, const double fThetaY, const double fThetaX) { double fCosZ2 = cos(0.5 * fThetaZ); double fCosY2 = cos(0.5 * fThetaY); double fCosX2 = cos(0.5 * fThetaX); double fSinZ2 = sin(0.5 * fThetaZ); double fSinY2 = sin(0.5 * fThetaY); double fSinX2 = sin(0.5 * fThetaX); // and now compute quaternion W = fCosZ2 * fCosY2 * fCosX2 + fSinZ2 * fSinY2 * fSinX2; X = fCosZ2 * fCosY2 * fSinX2 - fSinZ2 * fSinY2 * fCosX2; Y = fCosZ2 * fSinY2 * fCosX2 + fSinZ2 * fCosY2 * fSinX2; Z = fSinZ2 * fCosY2 * fCosX2 - fCosZ2 * fSinY2 * fSinX2; } void FromEulerAngles(const CVector3 &cAngles) { FromEulerAngles(cAngles.Z, cAngles.Y, cAngles.X); } //! computes the conjugate of this quaternion void Conjugate() { X = -X; Y = -Y; Z = -Z; } //! inverts this quaternion void Invert() { Conjugate(); *this /= GetLengthSquared(); } #if 0 //! returns the logarithm of a quaternion = v*a where q = [cos(a),v*sin(a)] CQuaternion Log() const { double fA = std::acos(GetW()); double fSinA = std::sin(fA); CQuaternion cResult; cResult.SetW(0); if (fSinA > 0) { cResult.SetX(fA * GetX() / fSinA); cResult.SetY(fA * GetY() / fSinA); cResult.SetZ(fA * GetZ() / fSinA); } else { cResult.SetX(0); cResult.SetY(0); cResult.SetZ(0); } return cResult; } //! returns e^quaternion = exp(v*a) = [cos(a),vsin(a)] quaternion exp() const { float a = (float)v.length(); float sina = (float)sin(a); float cosa = (float)cos(a); quaternion ret; ret.s = cosa; if (a > 0) { ret.v.x = sina * v.x / a; ret.v.y = sina * v.y / a; ret.v.z = sina * v.z / a; } else { ret.v.x = ret.v.y = ret.v.z = 0; } return ret; } #endif //! casting to a 4x4 isomorphic matrix for right multiplication with vector CMatrix4 ToMatrix4() const { return CMatrix4(W, -X, -Y, -Z, X, W, -Z, Y, Y, Z, W, -X, Z, -Y, X, W); } //! returns the axis and angle of this unit quaternion void ToAxisAngle(CVector3 &cAxis, double &fAngle) const { fAngle = acos(W); // pre-compute to save time double fSinThetaInv = 1.0 / sin(fAngle); // now the vector cAxis.X *= fSinThetaInv; cAxis.Y *= fSinThetaInv; cAxis.Z *= fSinThetaInv; // multiply by 2 fAngle *= 2.0; } //! returns the euler angles from a rotation quaternion CVector3 GetEulerAngles() const { double fSquaredW = W * W; double fSquaredX = X * X; double fSquaredY = Y * Y; double fSquaredZ = Z * Z; CVector3 cEuler; cEuler.X = atan2(2.0 * (X * Y + Z * W), fSquaredX - fSquaredY - fSquaredZ + fSquaredW); cEuler.Y = asin(-2.0 * (X * Z - Y * W)); cEuler.Z = atan2(2.0 * (Y * Z + X * W), -fSquaredX - fSquaredY + fSquaredZ + fSquaredW); return cEuler; } }; } #endif /* ENGINE_QUATERNION_HPP */ /* EOF */
[ [ [ 1, 351 ] ] ]
951c77f5066b57f1d4c37ad384d06872df2b372b
d9f1cc8e697ae4d1c74261ae6377063edd1c53f8
/src/misc/Queue.h
c4343643da9fa7684e5e254ba85f3e50c5e04bb1
[]
no_license
commel/opencombat2005
344b3c00aaa7d1ec4af817e5ef9b5b036f2e4022
d72fc2b0be12367af34d13c47064f31d55b7a8e0
refs/heads/master
2023-05-19T05:18:54.728752
2005-12-01T05:11:44
2005-12-01T05:11:44
375,630,282
0
0
null
null
null
null
UTF-8
C++
false
false
682
h
#pragma once #include <stdlib.h> #include <misc\Array.h> template <class T> class Queue { public: Queue() { } virtual ~Queue() { } void Enqueue(T *c) { _array.Add(c); } T *Dequeue() { if(_array.Count > 0) { T *rv = _array.Items[0]; _array.RemoveAt(0); return rv; } return NULL; } T *Peek() { if(_array.Count > 0) { T *rv = _array.Items[0]; return rv; } return NULL; } void Insert(T *t, int i) { _array.AddAt(t, i); } void Clear() { while(_array.Count > 0) { _array.RemoveAt(0); } } int Count() { return _array.Count; } private: Array<T> _array; };
[ "opencombat" ]
[ [ [ 1, 60 ] ] ]
3220398ed368123c83575fb2e83adea8ac350adf
def1c36bf3ce2de2d644f88d2ce60c0d72ecb146
/libs/mpt/src/faceobject.cpp
9529742b750a09c5d8f44d2fc94b859a5aabdeb3
[]
no_license
kinpro/ofxMPT
3e0ca3d6d2aa82035bbcb8bc44ff7716f7ffe3b9
f8c9126b5ee9fad3408c6361f3718859c9cb9094
refs/heads/master
2020-07-13T05:27:20.110695
2011-10-10T12:45:18
2011-10-10T12:45:18
null
0
0
null
null
null
null
UTF-8
C++
false
false
11,928
cpp
/* * FACEOBJECT.cpp * * Created by Bret Fortenberry on Aug 27, 2003. * Fixes: * * Copyright (c) 2003 Machine Perception Laboratory * University of California San Diego. * * Please read the disclaimer and notes about redistribution * at the end of this file. * */ #include "faceobject.h" #include <iostream> FaceObject::FaceObject(){ feature = e_face; leftEyes.reserve(EYEMEMSIZE); rightEyes.reserve(EYEMEMSIZE); } FaceObject::FaceObject(float x_in, float y_in, float xSize_in, float ySize_in, float scale_in){ x = x_in; y = y_in; xSize = xSize_in; ySize = ySize_in; scale = scale_in; feature = e_face; leftEyes.reserve(EYEMEMSIZE); rightEyes.reserve(EYEMEMSIZE); } FaceObject::FaceObject(FaceObject &thelist) { objects = thelist.objects; x = thelist.x; y = thelist.y; xSize = thelist.xSize; ySize = thelist.ySize; scale = thelist.scale; eyes = thelist.eyes; leftEyes = thelist.leftEyes; rightEyes = thelist.rightEyes; feature = thelist.feature; activation = thelist.activation; } FaceObject::FaceObject(TSquare<float> &square) { x = square.x; y = square.y; xSize = square.size; ySize = square.size; scale = square.scale; leftEyes.reserve(EYEMEMSIZE); rightEyes.reserve(EYEMEMSIZE); feature = e_face; } FaceObject::FaceObject(list<Square>::iterator face) { x = face->x; y = face->y; xSize = face->size; ySize = face->size; scale = face->scale; feature = e_face; } FaceObject::~FaceObject() { clear(); } void FaceObject::clear(){ if(objects.size()) { list< VisualObject* >::iterator it = objects.begin(); for(; it != objects.end(); ++it) { (*it)->clear(); } objects.clear(); } leftEyes.clear(); rightEyes.clear(); } void FaceObject::findMax() { double max = -1000000; if(leftEyes.size()){ //cout << "finding max left eye" << endl; eyes.leftEye = true; vector< EyeObject >::iterator it = leftEyes.begin(); for(; it != leftEyes.end(); ++it){ if(max < it->activation){ max = it->activation; //cout << "max: " << max; eyes.xLeft = it->x; eyes.yLeft = it->y; eyes.leftScale = it->scale; //cout << " at (" << it->x << "," << it->y << ")" << endl; } } } max = -1000000; if(rightEyes.size()){ eyes.rightEye = true; vector< EyeObject >::iterator it = rightEyes.begin(); for(; it != rightEyes.end(); ++it){ if(max < it->activation){ max = it->activation; eyes.xRight = it->x; eyes.yRight = it->y; eyes.rightScale = it->scale; } } } } void FaceObject::posterior(combine_mode mode) { switch(mode){ double maxAct; case mean_shift: case mpi_search: case maximum: // not currently used break; case face_only: eyes.xLeft = x + (xSize*0.7077f); eyes.yLeft = y + (xSize*0.3099f); eyes.leftScale = scale; eyes.xRight = x + (xSize*0.3149f); eyes.yRight = y + (xSize*0.3136f); eyes.rightScale = scale; break; case wt_max: case none: maxAct = -1000000; if(leftEyes.size()){ eyes.leftEye = true; vector< EyeObject >::iterator it = leftEyes.begin(); for(; it != leftEyes.end(); ++it){ if(maxAct < it->activation){ maxAct = it->activation; eyes.xLeft = it->x; eyes.yLeft = it->y; eyes.leftScale = it->scale; } } } maxAct = -1000000; if(rightEyes.size()){ eyes.rightEye = true; vector< EyeObject >::iterator it = rightEyes.begin(); for(; it != rightEyes.end(); ++it){ if(maxAct < it->activation){ maxAct = it->activation; eyes.xRight = it->x; eyes.yRight = it->y; eyes.rightScale = it->scale; } } } break; case wt_avg: case average: float xWt; float yWt; float scaleWt; float totalAct; vector< vector< float > > meanSub; vector< vector< float > > wtMeanSub; vector< vector< float > > invMtx; vector< vector< float > > covMtx; vector< EyeObject > *EyesPtr = 0; //cout << "leftEyes size = " << leftEyes.size() << endl; for(int cur_eye = 0; cur_eye < 2; cur_eye++){ bool run = false; if(leftEyes.size() && cur_eye == 0){ EyesPtr = &leftEyes; run = true; } else if(rightEyes.size() && cur_eye == 1){ EyesPtr = &rightEyes; run = true; } else cur_eye++; if (run){ vector< EyeObject > Eyes = *EyesPtr; float expo; bool outlier = true; float mean3d[3]; float determ; while(outlier){ totalAct = 0.0f; xWt = 0.0f; yWt = 0.0f; scaleWt = 0.0f; for (unsigned int i = 0; i < Eyes.size(); i++){ expo = exp(Eyes[i].activation); xWt += (expo * Eyes[i].x); yWt += (expo * Eyes[i].y); scaleWt += (expo * Eyes[i].scale); totalAct += expo; } mean3d[0] = xWt/totalAct; mean3d[1] = yWt/totalAct; mean3d[2] = scaleWt/totalAct; for(unsigned int pos = 0; pos < Eyes.size(); ++pos){ vector< float > v; vector< float > wt; expo = exp(Eyes[pos].activation); v.push_back(Eyes[pos].x - mean3d[0]); wt.push_back(v[0] * expo); v.push_back(Eyes[pos].y - mean3d[1]); wt.push_back(v[1] * expo); v.push_back(Eyes[pos].scale - mean3d[2]); wt.push_back(v[2] * expo); meanSub.push_back(v); wtMeanSub.push_back(wt); } float divTotAct = 1.0f/totalAct; if(mtxMult_2T(meanSub, wtMeanSub, covMtx, divTotAct) != 9){ meanSub.clear(); wtMeanSub.clear(); invMtx.clear(); covMtx.clear(); break; } if((determ = det3(covMtx))){ TransCof3(covMtx, invMtx, determ); } else { //later implement psudo inverse page 192 meanSub.clear(); wtMeanSub.clear(); invMtx.clear(); covMtx.clear(); break; //exit while loop } outlier = findOutliers(meanSub, invMtx, Eyes); meanSub.clear(); wtMeanSub.clear(); invMtx.clear(); covMtx.clear(); }//while loop if(mean3d[0] > x && mean3d[0] < (x+xSize) && mean3d[1] > y && mean3d[1] < (y+ySize)){ if(cur_eye == 0){ eyes.xLeft = mean3d[0]; eyes.yLeft = mean3d[1]; eyes.leftScale = mean3d[2]; eyes.leftEye = true; } if(cur_eye == 1){ eyes.xRight = mean3d[0]; eyes.yRight = mean3d[1]; eyes.rightScale = mean3d[2]; eyes.rightEye = true; } } } } break; }; } void FaceObject::TransCof3(vector< vector< float > > &inMtx, vector< vector< float > > &rtnMtx, float det){ float divDet = 1/det; vector< float > v; v.push_back((inMtx[1][1]*inMtx[2][2]-inMtx[1][2]*inMtx[2][1])*divDet); v.push_back(-(inMtx[0][1]*inMtx[2][2]-inMtx[0][2]*inMtx[2][1])*divDet); v.push_back((inMtx[0][1]*inMtx[1][2]-inMtx[0][2]*inMtx[1][1])*divDet); rtnMtx.push_back(v); vector< float > v2; v2.push_back(-(inMtx[1][0]*inMtx[2][2]-inMtx[1][2]*inMtx[2][0])*divDet); v2.push_back((inMtx[0][0]*inMtx[2][2]-inMtx[0][2]*inMtx[2][0])*divDet); v2.push_back(-(inMtx[0][0]*inMtx[1][2]-inMtx[0][2]*inMtx[1][0])*divDet); rtnMtx.push_back(v2); vector< float > v3; v3.push_back((inMtx[1][0]*inMtx[2][1]-inMtx[1][1]*inMtx[2][0])*divDet); v3.push_back(-(inMtx[0][0]*inMtx[2][1]-inMtx[0][1]*inMtx[2][0])*divDet); v3.push_back((inMtx[0][0]*inMtx[1][1]-inMtx[0][1]*inMtx[1][0])*divDet); rtnMtx.push_back(v3); } //http://astronomy.swin.edu.au/~pbourke/analysis/inverse/ float FaceObject::det3(vector< vector< float > > &matrix){ if ((matrix.size() != 3) || (matrix[0].size() != 3)) return (0.0f); return ((matrix[0][0] * (matrix[1][1]*matrix[2][2] - matrix[1][2]*matrix[2][1])) - (matrix[0][1] * (matrix[1][0]*matrix[2][2] - matrix[1][2]*matrix[2][0])) + (matrix[0][2] * (matrix[1][0]*matrix[2][1] - matrix[1][1]*matrix[2][0]))); } //http://www.mathworks.com/access/helpdesk/help/toolbox/aeroblks/determinantof3x3matrix.shtml int FaceObject::mtxMult(vector< vector< float > > &matrix1, vector< vector< float > > &matrix2, vector< vector< float > > &rtnMtx){ if(matrix1[0].size() != matrix2.size()){ return 0; } rtnMtx.clear(); float comb; int size = 0; for(unsigned int cur_row = 0; cur_row < matrix1.size(); ++cur_row){ vector< float > v; for(unsigned int cur_col = 0; cur_col < matrix2[0].size(); ++cur_col){ comb = 0; for(unsigned int cur_pos = 0; cur_pos < matrix1[0].size(); ++cur_pos){ comb += matrix1[cur_row][cur_pos] * matrix2[cur_pos][cur_col]; } v.push_back(comb); size++; } rtnMtx.push_back(v); } return size; } int FaceObject::mtxMult_2T(vector< vector< float > > &matrix1, vector< vector< float > > &matrix2, vector< vector< float > > &rtnMtx, float mult){ if(matrix1.size() != matrix2.size()) return 0; rtnMtx.clear(); float comb; int size = 0; for(unsigned int cur_row = 0; cur_row < matrix1[0].size(); ++cur_row){ vector< float > v; for(unsigned int cur_col = 0; cur_col < matrix2[0].size(); ++cur_col){ comb = 0; for(unsigned int cur_pos = 0; cur_pos < matrix1.size(); ++cur_pos){ comb += matrix1[cur_pos][cur_row] * matrix2[cur_pos][cur_col]; } v.push_back(comb*mult); size++; } rtnMtx.push_back(v); } return size; } bool FaceObject::findOutliers(vector< vector< float > > &meanSub, vector< vector< float > > &invMtx, vector< EyeObject > &Eyes){ vector< vector< float > > mnSubMtx; vector< vector< float > > tempMtx; vector< vector< float > > di; bool rtn = false; for (int i = (meanSub.size() - 1); i >= 0; --i){ mnSubMtx.push_back(meanSub[i]); mtxMult(mnSubMtx, invMtx, tempMtx); mtxMult_2T(tempMtx, mnSubMtx, di); //cout << "outlier di = " << di[0][0] << endl; if (di[0][0] > 1.0f){ //cout << "outlier di !!!!!!!= " << di[0][0] << endl; rtn = true; Eyes.erase(Eyes.begin() + i); } mnSubMtx.clear(); tempMtx.clear(); di.clear(); } return rtn; } #ifndef WIN32 int FaceObject::prtMtx(vector< vector< float > > &matrix){ for(unsigned int cur_row = 0; cur_row < matrix.size(); ++cur_row){ cout << "("; for(unsigned int cur_col = 0; cur_col < matrix[0].size(); ++cur_col){ cout << matrix[cur_row][cur_col] << ", "; } cout << ")\n"; } cout << endl; return 1; } #endif /* * * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * */
[ [ [ 1, 400 ] ] ]
0548ede27445be921eaea8bc03f1eb8213903e56
c5534a6df16a89e0ae8f53bcd49a6417e8d44409
/trunk/Dependencies/Xerces/include/xercesc/util/Transcoders/Uniconv390/XMLASCIITranscoder390.cpp
25535f45a08a6e79cd925bb38ce5df46e0ef417e
[]
no_license
svn2github/ngene
b2cddacf7ec035aa681d5b8989feab3383dac012
61850134a354816161859fe86c2907c8e73dc113
refs/heads/master
2023-09-03T12:34:18.944872
2011-07-27T19:26:04
2011-07-27T19:26:04
78,163,390
2
0
null
null
null
null
UTF-8
C++
false
false
8,670
cpp
/* * Copyright 2004,2004 The Apache Software Foundation. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ /* * $Id: XMLASCIITranscoder390.cpp 191054 2005-06-17 02:56:35Z jberry $ */ // --------------------------------------------------------------------------- // Includes // --------------------------------------------------------------------------- #include <xercesc/util/XMLUniDefs.hpp> #include <xercesc/util/Transcoders/Uniconv390/XMLASCIITranscoder390.hpp> #include <xercesc/util/XMLString.hpp> #include <xercesc/util/TranscodingException.hpp> #include <string.h> XERCES_CPP_NAMESPACE_BEGIN extern "OS" void TROTASC(const XMLByte * input, XMLCh * output, unsigned int * count, XMLCh *table, int STOP, int * FLAG ); //Add a long double in front of the table, the compiler will set the //table starting address on a double word boundary struct temp{ long double pad; XMLCh gFromTable[256]; }; static struct temp padding_temp={ 0, 0x0000, 0x0001, 0x0002, 0x0003, 0x0004, 0x0005, 0x0006, 0x0007 , 0x0008, 0x0009, 0x000A, 0x000B, 0x000C, 0x000D, 0x000E, 0x000F , 0x0010, 0x0011, 0x0012, 0x0013, 0x0014, 0x0015, 0x0016, 0x0017 , 0x0018, 0x0019, 0x001A, 0x001B, 0x001C, 0x001D, 0x001E, 0x001F , 0x0020, 0x0021, 0x0022, 0x0023, 0x0024, 0x0025, 0x0026, 0x0027 , 0x0028, 0x0029, 0x002A, 0x002B, 0x002C, 0x002D, 0x002E, 0x002F , 0x0030, 0x0031, 0x0032, 0x0033, 0x0034, 0x0035, 0x0036, 0x0037 , 0x0038, 0x0039, 0x003A, 0x003B, 0x003C, 0x003D, 0x003E, 0x003F , 0x0040, 0x0041, 0x0042, 0x0043, 0x0044, 0x0045, 0x0046, 0x0047 , 0x0048, 0x0049, 0x004A, 0x004B, 0x004C, 0x004D, 0x004E, 0x004F , 0x0050, 0x0051, 0x0052, 0x0053, 0x0054, 0x0055, 0x0056, 0x0057 , 0x0058, 0x0059, 0x005A, 0x005B, 0x005C, 0x005D, 0x005E, 0x005F , 0x0060, 0x0061, 0x0062, 0x0063, 0x0064, 0x0065, 0x0066, 0x0067 , 0x0068, 0x0069, 0x006A, 0x006B, 0x006C, 0x006D, 0x006E, 0x006F , 0x0070, 0x0071, 0x0072, 0x0073, 0x0074, 0x0075, 0x0076, 0x0077 , 0x0078, 0x0079, 0x007A, 0x007B, 0x007C, 0x007D, 0x007E, 0x007F , 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF , 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF , 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF , 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF , 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF , 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF , 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF , 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF , 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF , 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF , 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF , 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF , 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF , 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF , 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF , 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF }; // --------------------------------------------------------------------------- // XMLASCIITranscoder390: Constructors and Destructor // --------------------------------------------------------------------------- XMLASCIITranscoder390::XMLASCIITranscoder390( const XMLCh* const encodingName , const unsigned int blockSize , MemoryManager* const manager) : XMLTranscoder(encodingName, blockSize, manager) { } XMLASCIITranscoder390::~XMLASCIITranscoder390() { } // --------------------------------------------------------------------------- // XMLASCIITranscoder390: Implementation of the transcoder API // --------------------------------------------------------------------------- unsigned int XMLASCIITranscoder390::transcodeFrom( const XMLByte* const srcData , const unsigned int srcCount , XMLCh* const toFill , const unsigned int maxChars , unsigned int& bytesEaten , unsigned char* const charSizes) { // If debugging, make sure that the block size is legal #if defined(XERCES_DEBUG) checkBlockSize(maxChars); #endif // // Calculate the max chars we can do here. Its the lesser of the // max output chars and the source byte count. // const unsigned int countToDo = srcCount < maxChars ? srcCount : maxChars; // // Now loop through that many source chars and just cast each one // over to the XMLCh format. Check each source that its really a // valid ASCI char. // const XMLByte* srcPtr = srcData; XMLCh* outPtr = toFill; unsigned int countDone = countToDo; int flag = 0; // if flag is set to 1, an non-ASCII character is encountered TROTASC(srcPtr, toFill, &countDone, padding_temp.gFromTable, 0xFFFF, &flag); if (flag == 1 && countDone < 32){ XMLCh tmpBuf[17]; XMLString::binToText((unsigned int)*srcPtr, tmpBuf, 16, 16, getMemoryManager()); ThrowXMLwithMemMgr2 ( TranscodingException , XMLExcepts::Trans_Unrepresentable , tmpBuf , getEncodingName() , getMemoryManager() ); }//end if // Set the bytes we ate bytesEaten = countDone; // Set the char sizes to the fixed size memset(charSizes, 1, countDone); // Return the chars we transcoded return countDone; } unsigned int XMLASCIITranscoder390::transcodeTo(const XMLCh* const srcData , const unsigned int srcCount , XMLByte* const toFill , const unsigned int maxBytes , unsigned int& charsEaten , const UnRepOpts options) { // If debugging, make sure that the block size is legal #if defined(XERCES_DEBUG) checkBlockSize(maxBytes); #endif // // Calculate the max chars we can do here. Its the lesser of the // max output chars and the source byte count. // const unsigned int countToDo = srcCount < maxBytes ? srcCount : maxBytes; const XMLCh* srcPtr = srcData; XMLByte* outPtr = toFill; for (unsigned int index = 0; index < countToDo; index++) { // If its legal, do it and jump back to the top if (*srcPtr < 0x80) { *outPtr++ = XMLByte(*srcPtr++); continue; } // // Its not representable so use a replacement char. According to // the options, either throw or use the replacement. // if (options == UnRep_Throw) { XMLCh tmpBuf[17]; XMLString::binToText((unsigned int)*srcPtr, tmpBuf, 16, 16, getMemoryManager()); ThrowXMLwithMemMgr2 ( TranscodingException , XMLExcepts::Trans_Unrepresentable , tmpBuf , getEncodingName() , getMemoryManager() ); } // Use the replacement char *outPtr++ = 0x1A; srcPtr++; } // Set the chars we ate charsEaten = countToDo; // Return the byte we transcoded return countToDo; } bool XMLASCIITranscoder390::canTranscodeTo(const unsigned int toCheck) const { return (toCheck < 0x80); } XERCES_CPP_NAMESPACE_END
[ "Riddlemaster@fdc6060e-f348-4335-9a41-9933a8eecd57" ]
[ [ [ 1, 227 ] ] ]
ba553ff116ab6b0ba9999fb52498723bc693640b
0bc5c80df63cb5b5f085a8487a43015c568e8174
/Project1/GraphicsLib/Math/Vector2d.cpp
6ea3af4d3f4b8d592b0767abf992909047e4dc3f
[]
no_license
KarthikKombrenje/GraphicsClass
8683778a563bc3a5051c69a7bfae7ce34843731a
afd988ead29549e2865054814f18fca64429c54c
refs/heads/master
2022-05-09T08:31:56.599988
2010-12-10T07:34:10
2010-12-10T07:34:10
null
0
0
null
null
null
null
UTF-8
C++
false
false
2,918
cpp
//---------------------------------------------------------------------- // Best if viewed with tabs set every 4 columns. //---------------------------------------------------------------------- // File: Vector2d.cpp // Description: 2-dimensional point // Programmer: Dave Mount // For: CMSC 427 - Computer Graphics // Date: Fall 2010 //---------------------------------------------------------------------- #include "GraphicsLib/Math/Vector2d.h" // constructors Vector2d::Vector2d() : x(0), y(0) { } Vector2d::Vector2d(Scalar _x, Scalar _y) : x(_x), y(_y) { } Vector2d::Vector2d(const Vector2d& v) : x(v.x), y(v.y) { } // assignment ops Vector2d& Vector2d::operator=(const Vector2d& v) { x = v.x; y = v.y; return *this; } Vector2d& Vector2d::operator+=(const Vector2d& v) { x += v.x; y += v.y; return *this; } Vector2d& Vector2d::operator-=(const Vector2d& v) { x -= v.x; y -= v.y; return *this; } Vector2d& Vector2d::operator*=(Scalar s) { x *= s; y *= s; return *this; } Vector2d& Vector2d::operator/=(Scalar s) { x /= s; y /= s; return *this; } // arithmetic ops Vector2d Vector2d::operator+(const Vector2d& v) const { return Vector2d(x + v.x, y + v.y); } Vector2d Vector2d::operator-(const Vector2d& v) const { return Vector2d(x - v.x, y -v.y); } Vector2d Vector2d::operator*(Scalar s) const { return Vector2d(s*x, s*y); } Vector2d Vector2d::operator/(Scalar s) const { return Vector2d(x/s, y/s); } Vector2d Vector2d::operator-() const { return Vector2d(-x, -y); } Scalar Vector2d::length() const { return sqrt(x*x + y*y); } void Vector2d::normalize() { // normalize to unit length Scalar w = length(); if (w == 0) { x = 1; y = 0; } // too short! else { x /= w; y /= w; } // scale by 1/length } Vector2d Vector2d::normalize(const Vector2d& v) { Vector2d tmp = v; tmp.normalize(); return tmp; } // dot product Scalar Vector2d::dot(const Vector2d& v, const Vector2d& w) { return v.x * w.x + v.y * w.y; } // project v parallel to w Vector2d Vector2d::parProject(const Vector2d& v, const Vector2d& w) { return w * (dot(v,w) / dot(w,w)); } // project v orthogonal to w Vector2d Vector2d::orthProject(const Vector2d& v, const Vector2d& w) { return v - parProject(v, w); } // output operator std::ostream& operator<<(std::ostream& out, const Vector2d& p) { out << "(" << p.x << ", " << p.y << ")"; return out; }
[ [ [ 1, 81 ] ] ]
7691c628f814932e6ba39007ca2865b57c348a92
205069c97095da8f15e45cede1525f384ba6efd2
/Casino/Code/Server/ServerModule/CenterServer/VideoServerPathDlg.h
d5326c1c7f1859fcbe146062f670cd8d14616552
[]
no_license
m0o0m/01technology
1a3a5a48a88bec57f6a2d2b5a54a3ce2508de5ea
5e04cbfa79b7e3cf6d07121273b3272f441c2a99
refs/heads/master
2021-01-17T22:12:26.467196
2010-01-05T06:39:11
2010-01-05T06:39:11
null
0
0
null
null
null
null
GB18030
C++
false
false
471
h
#pragma once // CVideoServerPathDlg 对话框 class CVideoServerPathDlg : public CDialog { DECLARE_DYNAMIC(CVideoServerPathDlg) public: CVideoServerPathDlg(CWnd* pParent = NULL); // 标准构造函数 virtual ~CVideoServerPathDlg(); // 对话框数据 enum { IDD = IDD_VIDEOSERVERPATH }; protected: virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV 支持 DECLARE_MESSAGE_MAP() public: CString m_strVideoServerPath; };
[ [ [ 1, 23 ] ] ]
a13f6af774693a87318a02187a4a56f2d4e5ff66
c82d009662b7b3da2707a577a3143066d128093a
/ftor/i_object_function.h
c970a6f15f6164d6b77a5852669166756aa52d34
[]
no_license
canilao/cpp_framework
01a2c0787440d9fca64dbb0fb10c1175a4f7d198
da5c612e8f15f6987be0c925f46e854b2e703d73
refs/heads/master
2021-01-10T13:26:39.376268
2011-02-04T16:26:26
2011-02-04T16:26:26
49,291,836
1
0
null
null
null
null
UTF-8
C++
false
false
6,715
h
/******************************************************************************/ // /*! \file i_object_function.h \brief Header file for the interface class for all object function containers. \note C Anilao 11/26/2008 Created *******************************************************************************/ #ifndef I_OBJECT_FUNCTION_H #define I_OBJECT_FUNCTION_H // Standard library dependencies. #include <vector> #include <algorithm> /******************************************************************************/ // /*! \namespace Ftor \brief Namespace containing the object function library. *******************************************************************************/ namespace Ftor { // Forward class declarations. class ObjectFunctionOwner; /******************************************************************************/ // /*! \class IObjectFunction \brief Abstract interface for all object functions. *******************************************************************************/ class IObjectFunction { // ObjectFunctionOwner needs to operate on protected functions. friend class ObjectFunctionOwner; public: // Default constructor. IObjectFunction() : pOwner(NULL) {} // Constructor. IObjectFunction(ObjectFunctionOwner * pNewOwner); // Copy constructor. IObjectFunction(const IObjectFunction & origObj); // Destructor. virtual ~IObjectFunction() {} // Checks to see if a function is valid. virtual bool IsValid() const = 0; protected: // Invalidate with the owner. void InvalidateInOwner(); // Invalidates the function this object owns. virtual void InvalidateFunction() = 0; // Copies another IObject data locally. void CopyData(const IObjectFunction * pOrigObjectFunc); private: // Save the function object owner. ObjectFunctionOwner * pOwner; }; /******************************************************************************/ // /*! \class \brief *******************************************************************************/ class ObjectFunctionOwner { // IObject needs to operate on protected functions. friend class IObjectFunction; public: // Constructor. ObjectFunctionOwner() {} // Destructor. virtual ~ObjectFunctionOwner(); protected: // Vector type for the list of function pointers. typedef std::vector<IObjectFunction *> TFuncVector; protected: // Add function object. void AddFunctionObject(IObjectFunction * pClassFunction); // Remove function object. void InvalidateFunctionObject(const IObjectFunction * pClassFunction); private: // Constructor. ObjectFunctionOwner(const ObjectFunctionOwner &); private: // Vector of function object pointers. std::vector<IObjectFunction *> functionObjVector; }; /******************************************************************************/ // /*! \brief \history *******************************************************************************/ inline IObjectFunction::IObjectFunction(ObjectFunctionOwner * pNewOwner) : pOwner(pNewOwner) { pOwner->AddFunctionObject(this); } /******************************************************************************/ // /*! \brief \history *******************************************************************************/ inline IObjectFunction::IObjectFunction(const IObjectFunction & origObj) : pOwner(origObj.pOwner) { pOwner->AddFunctionObject(this); } /******************************************************************************/ // /*! \brief \history *******************************************************************************/ inline void IObjectFunction::InvalidateInOwner() { // If we are valid, then we do not have to tell the owner we are deleting. if(IsValid() && (pOwner != NULL)) { // We are being deleted, need to make sure the function that knows this. pOwner->InvalidateFunctionObject(this); } } /******************************************************************************/ // /*! \brief \history *******************************************************************************/ inline void IObjectFunction::CopyData(const IObjectFunction * pOrigObjectFunc) { // First invalidate with our current owner. InvalidateInOwner(); pOwner = pOrigObjectFunc->pOwner; // Do not allow bad owners to be referenced. if(pOwner != NULL) { // Let the new owner know of us. pOwner->AddFunctionObject(this); } } /******************************************************************************/ // /*! \brief \history *******************************************************************************/ inline ObjectFunctionOwner::~ObjectFunctionOwner() { // For all of the function objects, we need to clear out the funcs. for(TFuncVector::iterator iter = functionObjVector.begin() ; iter != functionObjVector.end() ; ++iter) { (*iter)->InvalidateFunction(); } } /******************************************************************************/ // /*! \brief \history *******************************************************************************/ inline void ObjectFunctionOwner::AddFunctionObject(IObjectFunction * pClassFunction) { // Locate pointer if it exists, we do not want to double add elements. TFuncVector::iterator iterLoc = find(functionObjVector.begin(), functionObjVector.end(), pClassFunction); // Add the pointer if it does exist. if(iterLoc == functionObjVector.end()) { functionObjVector.push_back(pClassFunction); } } /******************************************************************************/ // /*! \brief \history *******************************************************************************/ inline void ObjectFunctionOwner::InvalidateFunctionObject( const IObjectFunction * pClassFunction) { // Locate the pointer if it exists. TFuncVector::iterator iterLoc = find(functionObjVector.begin(), functionObjVector.end(), pClassFunction); // Remove the pointer if it does exist. if(iterLoc != functionObjVector.end()) { functionObjVector.erase(iterLoc); } } } #endif
[ "canilao@55e5c601-11dd-bd4b-a960-93a593583956", "Chris@55e5c601-11dd-bd4b-a960-93a593583956" ]
[ [ [ 1, 9 ], [ 18, 24 ], [ 30, 36 ], [ 76, 82 ], [ 120, 126 ], [ 134, 140 ], [ 147, 153 ], [ 164, 170 ], [ 187, 193 ], [ 205, 211 ], [ 227, 233 ] ], [ [ 10, 17 ], [ 25, 29 ], [ 37, 75 ], [ 83, 119 ], [ 127, 133 ], [ 141, 146 ], [ 154, 163 ], [ 171, 186 ], [ 194, 204 ], [ 212, 226 ], [ 234, 250 ] ] ]
41a4f90ee0a8f1ff1735d4adcbf56f8efafff532
5ac13fa1746046451f1989b5b8734f40d6445322
/minimangalore/Nebula2/code/mangalore/audio/waveresource.cc
fe1d839b73b2626b2944bb057c05e05ee02613f7
[]
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
1,187
cc
//------------------------------------------------------------------------------ // audio/waveresource.cc // (C) 2003 RadonLabs GmbH //------------------------------------------------------------------------------ #include "audio/waveresource.h" namespace Audio { ImplementRtti(Audio::WaveResource, Foundation::RefCounted); ImplementFactory(Audio::WaveResource); //------------------------------------------------------------------------------ /** */ WaveResource::WaveResource() : volume(1.0f) { // empty } //------------------------------------------------------------------------------ /** */ WaveResource::~WaveResource() { int num = this->sounds.Size(); for (int i = 0; i < num; i++) { this->sounds[i]->Release(); this->sounds[i].invalidate(); } } //------------------------------------------------------------------------------ /** */ bool WaveResource::IsPlaying() const { int num = this->sounds.Size(); for (int i = 0; i < num; i++) { if (this->sounds[i]->IsPlaying()) { return true; } } return false; } } // namespace Audio
[ "BawooiT@d1c0eb94-fc07-11dd-a7be-4b3ef3b0700c" ]
[ [ [ 1, 51 ] ] ]
b436598b7258551e1900642d7b461a62ba374ef2
74c8da5b29163992a08a376c7819785998afb588
/NetAnimal/Game/Hunter/NewGame/SanUnitTest/include/OgreEntityComponentUnitTest.h
61f913dd93b037e694e5ab9d9af5f0a7c06601ae
[]
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
2,190
h
#ifndef __Orz_UnitTest_OgreEntityComponentUnitTest__ #define __Orz_UnitTest_OgreEntityComponentUnitTest__ #include "SanUnitTestConfig.h" #include <orz/Toolkit_Component_Task/Component/ComponentFactories.h> #include "OgreEntityComponent.h" #include "COgreEntityInterface.h" #include "COgreAnimationInterface.h" #include "COgreResourceInterface.h" #include <OGRE/Ogre.h> /* #include "Engine.h" #include "KeyToMessage.h" #include "SingleChipToMessage.h"*/ BOOST_AUTO_TEST_CASE(OgreEntityComponentUnitTest) { using namespace Orz; ComponentPtr res = ComponentFactories::getInstance().create("OgreResource"); /*COgreResourceInterface * f = res->queryInterface<COgreResourceInterface>(); f->createGroup("ZhugeLiang"); f->addLocation("../../media/san/ZhugeLiang", "FileSystem"); f->init();*/ ComponentPtr comp = ComponentFactories::getInstance().create("OgreEntity"); COgreEntityInterface * face = comp->queryInterface<COgreEntityInterface>(); BOOST_CHECK(face); Ogre::SceneManager * sm = Orz::OgreGraphicsManager::getSingleton().getSceneManager(); Ogre::SceneNode *root = sm->getRootSceneNode()->createChildSceneNode(); face->load("ms_01_4.mesh", "ms_01_4.mesh", root); //face->play(""); Ogre::SceneNode * sn = face->getSceneNode(); sn->scale(0.1f, 0.1f, 0.1f); face->printAllAnimation(); BOOST_CHECK(sn->getParentSceneNode() == root); COgreAnimationInterface * animation = comp->queryInterface< COgreAnimationInterface >(); BOOST_CHECK(animation->isExist("first")); BOOST_CHECK(animation->enable("first", 1)); while(animation->update(0.015f)) { UnitTestEnvironmen::system->run(); } UnitTestEnvironmen::system->run(); UnitTestEnvironmen::system->run(); // //face-> /*COgreResourceInterface * face = comp->queryInterface<COgreResourceInterface>(); BOOST_CHECK(face->initResourceGroup("testRG")); BOOST_CHECK(face->load(".", "FileSystem")); BOOST_CHECK_EQUAL(face->getResourceGroup(), "testRG");*/ /*using namespace Orz; BlackBoardSystem::getInstance().write<int>("key", 123); int i = BlackBoardSystem::getInstance().read<int>("key"); ORZ_LOG_NOTIFICATION<<i;*/ } #endif
[ [ [ 1, 70 ] ] ]
4d620763c240787ec00df751eaf2dc147980d784
b73f27ba54ad98fa4314a79f2afbaee638cf13f0
/RegisterUtility/SoftwareEncrypt/stdafx.cpp
6107c8028133a56b4a9db6127c7ad3d986dea4c7
[]
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
GB18030
C++
false
false
274
cpp
// stdafx.cpp : 只包括标准包含文件的源文件 // SoftwareEncrypt.pch 将成为预编译头 // stdafx.obj 将包含预编译类型信息 #include "stdafx.h" // TODO: 在 STDAFX.H 中 //引用任何所需的附加头文件,而不是在此文件中引用
[ [ [ 1, 8 ] ] ]
6b42ebce8be822e1735f86f32243608b59131395
bd89d3607e32d7ebb8898f5e2d3445d524010850
/adaptationlayer/tsy/nokiatsy_dll/inc/cmmphonebookstoreoperationlist.h
194e949d75ab5a5bcc06bd326c6f01dedca4fda0
[]
no_license
wannaphong/symbian-incubation-projects.fcl-modemadaptation
9b9c61ba714ca8a786db01afda8f5a066420c0db
0e6894da14b3b096cffe0182cedecc9b6dac7b8d
refs/heads/master
2021-05-30T05:09:10.980036
2010-10-19T10:16:20
2010-10-19T10:16:20
null
0
0
null
null
null
null
UTF-8
C++
false
false
4,150
h
/* * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). * All rights reserved. * This component and the accompanying materials are made available * under the terms of 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: * */ #ifndef CMMPHONEBOOKOPERATIONLIST_H #define CMMPHONEBOOKOPERATIONLIST_H // INCLUDES #include <ctsy/pluginapi/cmmdatapackage.h> #include <e32base.h> #include "cmmphonebookstoreoperationbase.h" //UICC #include "muiccoperationbase.h" #include "cmmuiccmesshandler.h" // CONSTANTS //none // MACROS // none // DATA TYPES //none // EXTERNAL DATA STRUCTURES // FUNCTION PROTOTYPES //none // FORWARD DECLARATIONS //none // CLASS DECLARATION class CMmMessageManager; class CMmPhoneBookStoreMessHandler; //class CMmUiccMessHandler; /** * CMmPhoneBookStoreOperationList is used to keep list of different request(s) * (operation(s)) */ class CMmPhoneBookStoreOperationList : public CBase { public: // Constructors and destructor /** * Two-phased constructor. */ static CMmPhoneBookStoreOperationList* NewL( CMmPhoneBookStoreMessHandler* aMmPhoneBookStoreMessHandler, CMmUiccMessHandler* aMmUiccMessHandler); /** * Destructor. */ ~CMmPhoneBookStoreOperationList(); /** * Addoperation to operation list * * @param aTransId Transaction for index to be filled with operation * @param aOperation operation to be updated in operation list * @return None */ void AddOperation( TUint8 aTransId, CMmPhoneBookStoreOperationBase* aOperation ); /** * Get pointer to correct operation uing identify number. * * @param aTrans Identify number of request. * @param aSearchFrom pointer to entry to start search from * @return Pointer to operation. */ CMmPhoneBookStoreOperationBase* Find( TUint8 aTrans ); /** * Remove correct operation from operation list. * * @param aTrans Transaction Id * @return None */ void RemoveOperationFromList( TUint8 aTrans ); /** * Remove correct operation from operation list. * * @param aTrans Transaction Id * @return None */ void RemoveCacheOperationFromList( TUint8 aTrans ); /** * Remove correct operation from operation list. * * @param aTrans Transaction Id * @return None */ TInt RemoveLastOperationFromList(); /** * Check for empty Index * @param aInd empty index * @return TInt KErrNone or KErrNotFound */ TInt FindEmptyIndexTransId(); /** * Cancel all operation with same phonebook name * @param aPhoneBook phoenbook name for operation */ void CancelOperation( TName &aPhoneBook); private: /** * By default Symbian OS constructor is private. */ CMmPhoneBookStoreOperationList(); /** * Class attributes are created in ConstructL. */ void ConstructL(); public: // Data // none protected: // Data // none private: //data // Pointer to CMmPhoneBookStoreMessHandler. CMmPhoneBookStoreMessHandler* iMmPhoneBookStoreMessHandler; // Pointer to CMmUiccMessHandler CMmUiccMessHandler* iUiccMessHandler; // new Array for Storing Operation TFixedArray<CMmPhoneBookStoreOperationBase*, KMaxPbTrIdCount> iPtrOperationArrayNew; }; #endif // CMMPHONEBOOKOPERATIONLIST_H // End of file.
[ "dalarub@localhost", "[email protected]" ]
[ [ [ 1, 35 ], [ 37, 73 ], [ 75, 75 ], [ 77, 77 ], [ 81, 81 ], [ 85, 93 ], [ 95, 104 ], [ 117, 120 ], [ 124, 124 ], [ 133, 157 ], [ 160, 164 ] ], [ [ 36, 36 ], [ 74, 74 ], [ 76, 76 ], [ 78, 80 ], [ 82, 84 ], [ 94, 94 ], [ 105, 116 ], [ 121, 123 ], [ 125, 132 ], [ 158, 159 ] ] ]
d9d5d1c24611cbb94a26383260b06564a91622fe
f54dca64cbc02f9c0ebdfe57333fe4f63bed7fa1
/libneural/LinearFunction.h
c324b054eb6df543650bd1df0223bd838974e152
[]
no_license
tom3q/cowiek-maupa
f67b590e500d417e16277a979d063d0969808e3e
6ce9330ce3252f0ed6961ec09dd9a0dcb83e4c18
refs/heads/master
2019-01-02T08:48:26.605680
2011-12-11T18:08:47
2011-12-11T18:08:47
32,119,555
0
0
null
null
null
null
UTF-8
C++
false
false
251
h
#ifndef LINEAR_FUNCTION_H #define LINEAR_FUNCTION_H #include "ActivationFunction.h" class LinearFunction : public ActivationFunction { protected: virtual float calcValue(float sum); virtual float calcDerivative(float arg); }; #endif
[ [ [ 1, 13 ] ] ]
244426bf36493190c5872335e846dc0b044e0d79
b14d5833a79518a40d302e5eb40ed5da193cf1b2
/cpp/extern/crypto++/5.2.1/cast.cpp
67c2d85ab7b688d41931f64a01dd5673dcd3479f
[ "LicenseRef-scancode-public-domain", "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-cryptopp" ]
permissive
andyburke/bitflood
dcb3fb62dad7fa5e20cf9f1d58aaa94be30e82bf
fca6c0b635d07da4e6c7fbfa032921c827a981d6
refs/heads/master
2016-09-10T02:14:35.564530
2011-11-17T09:51:49
2011-11-17T09:51:49
2,794,411
1
0
null
null
null
null
UTF-8
C++
false
false
11,277
cpp
// cast.cpp - written and placed in the public domain by Wei Dai and Leonard Janke // based on Steve Reid's public domain cast.c #include "pch.h" #include "cast.h" #include "misc.h" NAMESPACE_BEGIN(CryptoPP) /* Macros to access 8-bit bytes out of a 32-bit word */ #define U8a(x) GETBYTE(x,3) #define U8b(x) GETBYTE(x,2) #define U8c(x) GETBYTE(x,1) #define U8d(x) GETBYTE(x,0) /* CAST uses three different round functions */ #define f1(l, r, km, kr) \ t = rotlVariable(km + r, kr); \ l ^= ((S[0][U8a(t)] ^ S[1][U8b(t)]) - \ S[2][U8c(t)]) + S[3][U8d(t)]; #define f2(l, r, km, kr) \ t = rotlVariable(km ^ r, kr); \ l ^= ((S[0][U8a(t)] - S[1][U8b(t)]) + \ S[2][U8c(t)]) ^ S[3][U8d(t)]; #define f3(l, r, km, kr) \ t = rotlVariable(km - r, kr); \ l ^= ((S[0][U8a(t)] + S[1][U8b(t)]) ^ \ S[2][U8c(t)]) - S[3][U8d(t)]; #define F1(l, r, i, j) f1(l, r, K[i], K[i+j]) #define F2(l, r, i, j) f2(l, r, K[i], K[i+j]) #define F3(l, r, i, j) f3(l, r, K[i], K[i+j]) typedef BlockGetAndPut<word32, BigEndian> Block; void CAST128::Enc::ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, byte *outBlock) const { word32 t, l, r; /* Get inblock into l,r */ Block::Get(inBlock)(l)(r); /* Do the work */ F1(l, r, 0, 16); F2(r, l, 1, 16); F3(l, r, 2, 16); F1(r, l, 3, 16); F2(l, r, 4, 16); F3(r, l, 5, 16); F1(l, r, 6, 16); F2(r, l, 7, 16); F3(l, r, 8, 16); F1(r, l, 9, 16); F2(l, r, 10, 16); F3(r, l, 11, 16); /* Only do full 16 rounds if key length > 80 bits */ if (!reduced) { F1(l, r, 12, 16); F2(r, l, 13, 16); F3(l, r, 14, 16); F1(r, l, 15, 16); } /* Put l,r into outblock */ Block::Put(xorBlock, outBlock)(r)(l); } void CAST128::Dec::ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, byte *outBlock) const { word32 t, l, r; /* Get inblock into l,r */ Block::Get(inBlock)(r)(l); /* Only do full 16 rounds if key length > 80 bits */ if (!reduced) { F1(r, l, 15, 16); F3(l, r, 14, 16); F2(r, l, 13, 16); F1(l, r, 12, 16); } F3(r, l, 11, 16); F2(l, r, 10, 16); F1(r, l, 9, 16); F3(l, r, 8, 16); F2(r, l, 7, 16); F1(l, r, 6, 16); F3(r, l, 5, 16); F2(l, r, 4, 16); F1(r, l, 3, 16); F3(l, r, 2, 16); F2(r, l, 1, 16); F1(l, r, 0, 16); /* Put l,r into outblock */ Block::Put(xorBlock, outBlock)(l)(r); /* Wipe clean */ t = l = r = 0; } void CAST128::Base::UncheckedSetKey(CipherDir dir, const byte *userKey, unsigned int keylength) { AssertValidKeyLength(keylength); reduced = (keylength <= 10); word32 X[4], Z[4]; GetUserKey(BIG_ENDIAN_ORDER, X, 4, userKey, keylength); #define x(i) GETBYTE(X[i/4], 3-i%4) #define z(i) GETBYTE(Z[i/4], 3-i%4) unsigned int i; for (i=0; i<=16; i+=16) { // this part is copied directly from RFC 2144 (with some search and replace) by Wei Dai Z[0] = X[0] ^ S[4][x(0xD)] ^ S[5][x(0xF)] ^ S[6][x(0xC)] ^ S[7][x(0xE)] ^ S[6][x(0x8)]; Z[1] = X[2] ^ S[4][z(0x0)] ^ S[5][z(0x2)] ^ S[6][z(0x1)] ^ S[7][z(0x3)] ^ S[7][x(0xA)]; Z[2] = X[3] ^ S[4][z(0x7)] ^ S[5][z(0x6)] ^ S[6][z(0x5)] ^ S[7][z(0x4)] ^ S[4][x(0x9)]; Z[3] = X[1] ^ S[4][z(0xA)] ^ S[5][z(0x9)] ^ S[6][z(0xB)] ^ S[7][z(0x8)] ^ S[5][x(0xB)]; K[i+0] = S[4][z(0x8)] ^ S[5][z(0x9)] ^ S[6][z(0x7)] ^ S[7][z(0x6)] ^ S[4][z(0x2)]; K[i+1] = S[4][z(0xA)] ^ S[5][z(0xB)] ^ S[6][z(0x5)] ^ S[7][z(0x4)] ^ S[5][z(0x6)]; K[i+2] = S[4][z(0xC)] ^ S[5][z(0xD)] ^ S[6][z(0x3)] ^ S[7][z(0x2)] ^ S[6][z(0x9)]; K[i+3] = S[4][z(0xE)] ^ S[5][z(0xF)] ^ S[6][z(0x1)] ^ S[7][z(0x0)] ^ S[7][z(0xC)]; X[0] = Z[2] ^ S[4][z(0x5)] ^ S[5][z(0x7)] ^ S[6][z(0x4)] ^ S[7][z(0x6)] ^ S[6][z(0x0)]; X[1] = Z[0] ^ S[4][x(0x0)] ^ S[5][x(0x2)] ^ S[6][x(0x1)] ^ S[7][x(0x3)] ^ S[7][z(0x2)]; X[2] = Z[1] ^ S[4][x(0x7)] ^ S[5][x(0x6)] ^ S[6][x(0x5)] ^ S[7][x(0x4)] ^ S[4][z(0x1)]; X[3] = Z[3] ^ S[4][x(0xA)] ^ S[5][x(0x9)] ^ S[6][x(0xB)] ^ S[7][x(0x8)] ^ S[5][z(0x3)]; K[i+4] = S[4][x(0x3)] ^ S[5][x(0x2)] ^ S[6][x(0xC)] ^ S[7][x(0xD)] ^ S[4][x(0x8)]; K[i+5] = S[4][x(0x1)] ^ S[5][x(0x0)] ^ S[6][x(0xE)] ^ S[7][x(0xF)] ^ S[5][x(0xD)]; K[i+6] = S[4][x(0x7)] ^ S[5][x(0x6)] ^ S[6][x(0x8)] ^ S[7][x(0x9)] ^ S[6][x(0x3)]; K[i+7] = S[4][x(0x5)] ^ S[5][x(0x4)] ^ S[6][x(0xA)] ^ S[7][x(0xB)] ^ S[7][x(0x7)]; Z[0] = X[0] ^ S[4][x(0xD)] ^ S[5][x(0xF)] ^ S[6][x(0xC)] ^ S[7][x(0xE)] ^ S[6][x(0x8)]; Z[1] = X[2] ^ S[4][z(0x0)] ^ S[5][z(0x2)] ^ S[6][z(0x1)] ^ S[7][z(0x3)] ^ S[7][x(0xA)]; Z[2] = X[3] ^ S[4][z(0x7)] ^ S[5][z(0x6)] ^ S[6][z(0x5)] ^ S[7][z(0x4)] ^ S[4][x(0x9)]; Z[3] = X[1] ^ S[4][z(0xA)] ^ S[5][z(0x9)] ^ S[6][z(0xB)] ^ S[7][z(0x8)] ^ S[5][x(0xB)]; K[i+8] = S[4][z(0x3)] ^ S[5][z(0x2)] ^ S[6][z(0xC)] ^ S[7][z(0xD)] ^ S[4][z(0x9)]; K[i+9] = S[4][z(0x1)] ^ S[5][z(0x0)] ^ S[6][z(0xE)] ^ S[7][z(0xF)] ^ S[5][z(0xC)]; K[i+10] = S[4][z(0x7)] ^ S[5][z(0x6)] ^ S[6][z(0x8)] ^ S[7][z(0x9)] ^ S[6][z(0x2)]; K[i+11] = S[4][z(0x5)] ^ S[5][z(0x4)] ^ S[6][z(0xA)] ^ S[7][z(0xB)] ^ S[7][z(0x6)]; X[0] = Z[2] ^ S[4][z(0x5)] ^ S[5][z(0x7)] ^ S[6][z(0x4)] ^ S[7][z(0x6)] ^ S[6][z(0x0)]; X[1] = Z[0] ^ S[4][x(0x0)] ^ S[5][x(0x2)] ^ S[6][x(0x1)] ^ S[7][x(0x3)] ^ S[7][z(0x2)]; X[2] = Z[1] ^ S[4][x(0x7)] ^ S[5][x(0x6)] ^ S[6][x(0x5)] ^ S[7][x(0x4)] ^ S[4][z(0x1)]; X[3] = Z[3] ^ S[4][x(0xA)] ^ S[5][x(0x9)] ^ S[6][x(0xB)] ^ S[7][x(0x8)] ^ S[5][z(0x3)]; K[i+12] = S[4][x(0x8)] ^ S[5][x(0x9)] ^ S[6][x(0x7)] ^ S[7][x(0x6)] ^ S[4][x(0x3)]; K[i+13] = S[4][x(0xA)] ^ S[5][x(0xB)] ^ S[6][x(0x5)] ^ S[7][x(0x4)] ^ S[5][x(0x7)]; K[i+14] = S[4][x(0xC)] ^ S[5][x(0xD)] ^ S[6][x(0x3)] ^ S[7][x(0x2)] ^ S[6][x(0x8)]; K[i+15] = S[4][x(0xE)] ^ S[5][x(0xF)] ^ S[6][x(0x1)] ^ S[7][x(0x0)] ^ S[7][x(0xD)]; } for (i=16; i<32; i++) K[i] &= 0x1f; } // The following CAST-256 implementation was contributed by Leonard Janke const word32 CAST256::Base::t_m[8][24]={ { 0x5a827999, 0xd151d6a1, 0x482133a9, 0xbef090b1, 0x35bfedb9, 0xac8f4ac1, 0x235ea7c9, 0x9a2e04d1, 0x10fd61d9, 0x87ccbee1, 0xfe9c1be9, 0x756b78f1, 0xec3ad5f9, 0x630a3301, 0xd9d99009, 0x50a8ed11, 0xc7784a19, 0x3e47a721, 0xb5170429, 0x2be66131, 0xa2b5be39, 0x19851b41, 0x90547849, 0x0723d551}, { 0xc95c653a, 0x402bc242, 0xb6fb1f4a, 0x2dca7c52, 0xa499d95a, 0x1b693662, 0x9238936a, 0x0907f072, 0x7fd74d7a, 0xf6a6aa82, 0x6d76078a, 0xe4456492, 0x5b14c19a, 0xd1e41ea2, 0x48b37baa, 0xbf82d8b2, 0x365235ba, 0xad2192c2, 0x23f0efca, 0x9ac04cd2, 0x118fa9da, 0x885f06e2, 0xff2e63ea, 0x75fdc0f2}, { 0x383650db, 0xaf05ade3, 0x25d50aeb, 0x9ca467f3, 0x1373c4fb, 0x8a432203, 0x01127f0b, 0x77e1dc13, 0xeeb1391b, 0x65809623, 0xdc4ff32b, 0x531f5033, 0xc9eead3b, 0x40be0a43, 0xb78d674b, 0x2e5cc453, 0xa52c215b, 0x1bfb7e63, 0x92cadb6b, 0x099a3873, 0x8069957b, 0xf738f283, 0x6e084f8b, 0xe4d7ac93}, { 0xa7103c7c, 0x1ddf9984, 0x94aef68c, 0x0b7e5394, 0x824db09c, 0xf91d0da4, 0x6fec6aac, 0xe6bbc7b4, 0x5d8b24bc, 0xd45a81c4, 0x4b29decc, 0xc1f93bd4, 0x38c898dc, 0xaf97f5e4, 0x266752ec, 0x9d36aff4, 0x14060cfc, 0x8ad56a04, 0x01a4c70c, 0x78742414, 0xef43811c, 0x6612de24, 0xdce23b2c, 0x53b19834}, { 0x15ea281d, 0x8cb98525, 0x0388e22d, 0x7a583f35, 0xf1279c3d, 0x67f6f945, 0xdec6564d, 0x5595b355, 0xcc65105d, 0x43346d65, 0xba03ca6d, 0x30d32775, 0xa7a2847d, 0x1e71e185, 0x95413e8d, 0x0c109b95, 0x82dff89d, 0xf9af55a5, 0x707eb2ad, 0xe74e0fb5, 0x5e1d6cbd, 0xd4ecc9c5, 0x4bbc26cd, 0xc28b83d5}, { 0x84c413be, 0xfb9370c6, 0x7262cdce, 0xe9322ad6, 0x600187de, 0xd6d0e4e6, 0x4da041ee, 0xc46f9ef6, 0x3b3efbfe, 0xb20e5906, 0x28ddb60e, 0x9fad1316, 0x167c701e, 0x8d4bcd26, 0x041b2a2e, 0x7aea8736, 0xf1b9e43e, 0x68894146, 0xdf589e4e, 0x5627fb56, 0xccf7585e, 0x43c6b566, 0xba96126e, 0x31656f76}, { 0xf39dff5f, 0x6a6d5c67, 0xe13cb96f, 0x580c1677, 0xcedb737f, 0x45aad087, 0xbc7a2d8f, 0x33498a97, 0xaa18e79f, 0x20e844a7, 0x97b7a1af, 0x0e86feb7, 0x85565bbf, 0xfc25b8c7, 0x72f515cf, 0xe9c472d7, 0x6093cfdf, 0xd7632ce7, 0x4e3289ef, 0xc501e6f7, 0x3bd143ff, 0xb2a0a107, 0x296ffe0f, 0xa03f5b17}, { 0x6277eb00, 0xd9474808, 0x5016a510, 0xc6e60218, 0x3db55f20, 0xb484bc28, 0x2b541930, 0xa2237638, 0x18f2d340, 0x8fc23048, 0x06918d50, 0x7d60ea58, 0xf4304760, 0x6affa468, 0xe1cf0170, 0x589e5e78, 0xcf6dbb80, 0x463d1888, 0xbd0c7590, 0x33dbd298, 0xaaab2fa0, 0x217a8ca8, 0x9849e9b0, 0x0f1946b8} }; const unsigned int CAST256::Base::t_r[8][24]={ {19, 27, 3, 11, 19, 27, 3, 11, 19, 27, 3, 11, 19, 27, 3, 11, 19, 27, 3, 11, 19, 27, 3, 11}, {4, 12, 20, 28, 4, 12, 20, 28, 4, 12, 20, 28, 4, 12, 20, 28, 4, 12, 20, 28, 4, 12, 20, 28}, {21, 29, 5, 13, 21, 29, 5, 13, 21, 29, 5, 13, 21, 29, 5, 13, 21, 29, 5, 13, 21, 29, 5, 13}, {6, 14, 22, 30, 6, 14, 22, 30, 6, 14, 22, 30, 6, 14, 22, 30, 6, 14, 22, 30, 6, 14, 22, 30}, {23, 31, 7, 15, 23, 31, 7, 15, 23, 31, 7, 15, 23, 31, 7, 15, 23, 31, 7, 15, 23, 31, 7, 15}, {8, 16, 24, 0, 8, 16, 24, 0, 8, 16, 24, 0, 8, 16, 24, 0, 8, 16, 24, 0, 8, 16, 24, 0}, {25, 1, 9, 17, 25, 1, 9, 17, 25, 1, 9, 17, 25, 1, 9, 17, 25, 1, 9, 17, 25, 1, 9, 17}, {10, 18, 26, 2, 10, 18, 26, 2, 10, 18, 26, 2, 10, 18, 26, 2, 10, 18, 26, 2, 10, 18, 26, 2} }; #define Q(i) \ F1(block[2],block[3],8*i+4,-4); \ F2(block[1],block[2],8*i+5,-4); \ F3(block[0],block[1],8*i+6,-4); \ F1(block[3],block[0],8*i+7,-4); #define QBar(i) \ F1(block[3],block[0],8*i+7,-4); \ F3(block[0],block[1],8*i+6,-4); \ F2(block[1],block[2],8*i+5,-4); \ F1(block[2],block[3],8*i+4,-4); /* CAST256's encrypt/decrypt functions are identical except for the order that the keys are used */ void CAST256::Base::ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, byte *outBlock) const { word32 t, block[4]; Block::Get(inBlock)(block[0])(block[1])(block[2])(block[3]); // Perform 6 forward quad rounds Q(0); Q(1); Q(2); Q(3); Q(4); Q(5); // Perform 6 reverse quad rounds QBar(6); QBar(7); QBar(8); QBar(9); QBar(10); QBar(11); Block::Put(xorBlock, outBlock)(block[0])(block[1])(block[2])(block[3]); } /* Set up a CAST-256 key */ void CAST256::Base::Omega(int i, word32 kappa[8]) { word32 t; f1(kappa[6],kappa[7],t_m[0][i],t_r[0][i]); f2(kappa[5],kappa[6],t_m[1][i],t_r[1][i]); f3(kappa[4],kappa[5],t_m[2][i],t_r[2][i]); f1(kappa[3],kappa[4],t_m[3][i],t_r[3][i]); f2(kappa[2],kappa[3],t_m[4][i],t_r[4][i]); f3(kappa[1],kappa[2],t_m[5][i],t_r[5][i]); f1(kappa[0],kappa[1],t_m[6][i],t_r[6][i]); f2(kappa[7],kappa[0],t_m[7][i],t_r[7][i]); } void CAST256::Base::UncheckedSetKey(CipherDir dir, const byte *userKey, unsigned int keylength) { AssertValidKeyLength(keylength); word32 kappa[8]; GetUserKey(BIG_ENDIAN_ORDER, kappa, 8, userKey, keylength); for(int i=0; i<12; ++i) { Omega(2*i,kappa); Omega(2*i+1,kappa); K[8*i]=kappa[0] & 31; K[8*i+1]=kappa[2] & 31; K[8*i+2]=kappa[4] & 31; K[8*i+3]=kappa[6] & 31; K[8*i+4]=kappa[7]; K[8*i+5]=kappa[5]; K[8*i+6]=kappa[3]; K[8*i+7]=kappa[1]; } if (dir == DECRYPTION) { for(int j=0; j<6; ++j) { for(int i=0; i<4; ++i) { int i1=8*j+i; int i2=8*(11-j)+i; assert(i1<i2); std::swap(K[i1],K[i2]); std::swap(K[i1+4],K[i2+4]); } } } memset(kappa, 0, sizeof(kappa)); } NAMESPACE_END
[ [ [ 1, 296 ] ] ]
45293493f7291619503e03f08a512bf63dcb1989
188058ec6dbe8b1a74bf584ecfa7843be560d2e5
/FLVGServer/XDLTheme.h
f6fdce7660856875f0586732c643858af4bd1c5c
[]
no_license
mason105/red5cpp
636e82c660942e2b39c4bfebc63175c8539f7df0
fcf1152cb0a31560af397f24a46b8402e854536e
refs/heads/master
2021-01-10T07:21:31.412996
2007-08-23T06:29:17
2007-08-23T06:29:17
36,223,621
0
0
null
null
null
null
UTF-8
C++
false
false
1,945
h
// XDLTheme.h: interface for the CXDLTheme class. // ////////////////////////////////////////////////////////////////////// #if !defined(AFX_XDLTHEME_H__8B039169_50B4_43B7_81F7_DA6D3AACD60E__INCLUDED_) #define AFX_XDLTHEME_H__8B039169_50B4_43B7_81F7_DA6D3AACD60E__INCLUDED_ #if _MSC_VER > 1000 #pragma once #endif // _MSC_VER > 1000 #define XDLCOLOR_3DFACE RGB(230, 230, 230) #define XDLCOLOR_3DSHADOW RGB(153, 153, 153) #define XDLCOLOR_BTNHIGHLIGHT RGB(255, 255, 255) class CXDLTheme : public CXTPDefaultTheme { public: CXDLTheme(); virtual ~CXDLTheme(); virtual void FillStatusBar(CDC* pDC, CXTPStatusBar* pBar); virtual void FillDockBar(CDC* pDC, CXTPDockBar* pBar); virtual void DrawStatusBarGripper(CDC* pDC, CRect rcClient); virtual void DrawStatusBarPane(CDC* pDC, CRect& rc, DWORD dwStyle, CString str); virtual void FillCommandBarEntry(CDC* pDC, CXTPCommandBar* pBar); CSize DrawCommandBarGripper(CDC* pDC, CXTPCommandBar* pBar, BOOL bDraw); CSize DrawCommandBarSeparator(CDC* pDC, CXTPCommandBar* pBar, CXTPControl* pControl, BOOL bDraw); void DrawRectangle(CDC* pDC, CRect rc, BOOL bSelected, BOOL bPressed, BOOL bEnabled, BOOL bChecked, BOOL bPopuped, BOOL bToolBar, XTPBarPosition barPosition = xtpBarPopup); void AdjustExcludeRect(CRect& rc, CXTPControl* pControl); }; class CXDLDockingTheme: public CXTPDockingPaneOffice2003Theme { public : CXDLDockingTheme(); virtual ~CXDLDockingTheme(); virtual void DrawPane(CDC& dc, CXTPDockingPaneTabbedContainer* pPane, CRect rc); virtual void DrawCaption(CDC& dc, CXTPDockingPaneTabbedContainer* pPane, CRect rc); protected: virtual void DrawCaptionPart(CDC& dc, CXTPDockingPaneBase* pPane, CRect rcCaption, CString strTitle, BOOL bActive); virtual void DrawSplitter(CDC& dc, CXTPDockingPaneSplitterWnd* pSplitter); }; #endif // !defined(AFX_XDLTHEME_H__8B039169_50B4_43B7_81F7_DA6D3AACD60E__INCLUDED_)
[ "soaris@46205fef-a337-0410-8429-7db05d171fc8" ]
[ [ [ 1, 49 ] ] ]
c7c79656391ca076df63474506b714f6a4c200e2
daef491056b6a9e227eef3e3b820e7ee7b0af6b6
/Tags/0.2.6/code/toolkit/platform/msw/msw_window.cpp
57cbbe6c96f15f4fd371069fa27df8214c7a83f9
[ "BSD-3-Clause" ]
permissive
BackupTheBerlios/gut-svn
de9952b8b3e62cedbcfeb7ccba0b4d267771dd95
0981d3b37ccfc1ff36cd79000f6c6be481ea4546
refs/heads/master
2021-03-12T22:40:32.685049
2006-07-07T02:18:38
2006-07-07T02:18:38
40,725,529
0
0
null
null
null
null
UTF-8
C++
false
false
4,089
cpp
/********************************************************************** * GameGut - msw_window.cpp * Copyright (c) 1999-2005 Jason Perkins. * All rights reserved. * * This library is free software; you can redistribute it and/or * modify it under the terms of the BSD-style license that is * included with this library in the file LICENSE.txt. * * 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 * files LICENSE.txt for more details. **********************************************************************/ #include "core/core.h" #include "msw_platform.h" /* A Windows specific version of the utWindow object */ struct utxWindow : utxWindowBase { HWND hWnd; }; /**************************************************************************** * Called by utCreateWindow() in ut_window.cpp; the MS Windows specific * window creation code. ****************************************************************************/ utWindow utxCreateWindow(const char* title, int width, int height) { HINSTANCE hInstance = GetModuleHandle(NULL); /* Standard Win32 setup...register a window class */ WNDCLASS wc; wc.style = CS_HREDRAW | CS_VREDRAW; wc.lpfnWndProc = utx_msw_WndProc; wc.cbClsExtra = 0; wc.cbWndExtra = 0; wc.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH); wc.hCursor = LoadCursor(NULL, IDC_ARROW); wc.hIcon = NULL; wc.hInstance = hInstance; wc.lpszClassName = "utgfxwnd"; wc.lpszMenuName = NULL; RegisterClass(&wc); /* Make the window bigger to account for borders, caption, etc. */ DWORD style = WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU | WS_THICKFRAME | WS_MINIMIZEBOX | WS_MAXIMIZEBOX | WS_VISIBLE; RECT rect; SetRect(&rect, 0, 0, width, height); AdjustWindowRect(&rect, style, FALSE); width = rect.right - rect.left; height = rect.bottom - rect.top; /* Now create the window */ HWND hWnd; hWnd = CreateWindowEx(0, "utgfxwnd", title, style, CW_USEDEFAULT, CW_USEDEFAULT, width, height, NULL, NULL, hInstance, NULL); if (hWnd == NULL) { utxLogError("CreateWindowEx", GetLastError()); return NULL; } /* Create a Toolkit window object */ utWindow window = utALLOCT(utxWindow); window->handle = (void*)hWnd; window->hWnd = hWnd; /* Attach my object to the window for the event handler */ #if defined(GWLP_USERDATA) SetWindowLongPtr(hWnd, GWLP_USERDATA, (LONG)window); #else SetWindowLong(hWnd, GWL_USERDATA, (LONG)window); #endif /* Display the window */ ShowWindow(hWnd, SW_SHOWNORMAL); // UpdateWindow(hWnd); return window; } /**************************************************************************** * Called by utDestroyWindow() in ut_window.cpp; the MS Windows specific * window teardown code. ****************************************************************************/ int utxDestroyWindow(utWindow window) { if (window != NULL) { if (window->hWnd != NULL && IsWindow(window->hWnd)) DestroyWindow(window->hWnd); utFREE(window); } return true; } int utGetWindowHeight(utWindow window) { RECT rect; GetClientRect(window->hWnd, &rect); return (rect.bottom - rect.top); } int utGetWindowWidth(utWindow window) { RECT rect; GetClientRect(window->hWnd, &rect); return (rect.right - rect.left); } int utResizeWindow(utWindow window, int width, int height) { /* Get the current size of the window */ RECT rect; GetClientRect(window->hWnd, &rect); int clientWidth = rect.right - rect.left; int clientHeight = rect.bottom - rect.top; GetWindowRect(window->hWnd, &rect); int frameWidth = rect.right - rect.left; int frameHeight = rect.bottom - rect.top; /* Adjust it to the new client size, taking into account borders, etc. */ frameWidth += width - clientWidth; frameHeight += height - clientHeight; MoveWindow(window->hWnd, rect.left, rect.top, frameWidth, frameHeight, TRUE); return true; }
[ "starkos@5eb1f239-c603-0410-9f17-9cbfe04d0a06" ]
[ [ [ 1, 141 ] ] ]
20985734bf0ae47602ab0d5862425b84e0d1816b
cf579692f2e289563160b6a218fa5f1b6335d813
/xbflashlib/cryptlib/crypt/rc4_enc.cpp
6d768f416eee59c00495a5e9e93842c4ac1ab089
[]
no_license
opcow/XBtool
a7451971de3296e1ce5632b0c9d95430f6d3b223
718a7fbf87e08c12c0c829dd2e2c0d6cee967cbe
refs/heads/master
2021-01-16T21:02:17.759102
2011-03-09T23:36:54
2011-03-09T23:36:54
1,461,420
8
2
null
null
null
null
UTF-8
C++
false
false
4,871
cpp
/* crypto/rc4/rc4_enc.org */ /* Copyright (C) 1995-1997 Eric Young ([email protected]) * All rights reserved. * * This package is an SSL implementation written * by Eric Young ([email protected]). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson ([email protected]). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young ([email protected])" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson ([email protected])" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR 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. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ #include "stdafx.h" #include "rc4.h" #include "rc4_locl.h" /* RC4 as implemented from a posting from * Newsgroups: sci.crypt * From: [email protected] (David Sterndark) * Subject: RC4 Algorithm revealed. * Message-ID: <[email protected]> * Date: Wed, 14 Sep 1994 06:35:31 GMT */ void RC4(RC4_KEY *key, unsigned long len, unsigned char *indata, unsigned char *outdata) { register RC4_INT *d; register RC4_INT x,y,tx,ty; int i; x=key->x; y=key->y; d=key->data; #define LOOP(in,out) \ x=((x+1)&0xff); \ tx=d[x]; \ y=(tx+y)&0xff; \ d[x]=ty=d[y]; \ d[y]=tx; \ (out) = d[(tx+ty)&0xff]^ (in); #ifndef RC4_INDEX #define RC4_LOOP(a,b,i) LOOP(*((a)++),*((b)++)) #else #define RC4_LOOP(a,b,i) LOOP(a[i],b[i]) #endif i= -(int)len; i=(int)(len>>3L); if (i) { for (;;) { RC4_LOOP(indata,outdata,0); RC4_LOOP(indata,outdata,1); RC4_LOOP(indata,outdata,2); RC4_LOOP(indata,outdata,3); RC4_LOOP(indata,outdata,4); RC4_LOOP(indata,outdata,5); RC4_LOOP(indata,outdata,6); RC4_LOOP(indata,outdata,7); #ifdef RC4_INDEX indata+=8; outdata+=8; #endif if (--i == 0) break; } } i=(int)len&0x07; if (i) { for (;;) { RC4_LOOP(indata,outdata,0); if (--i == 0) break; RC4_LOOP(indata,outdata,1); if (--i == 0) break; RC4_LOOP(indata,outdata,2); if (--i == 0) break; RC4_LOOP(indata,outdata,3); if (--i == 0) break; RC4_LOOP(indata,outdata,4); if (--i == 0) break; RC4_LOOP(indata,outdata,5); if (--i == 0) break; RC4_LOOP(indata,outdata,6); if (--i == 0) break; } } key->x=x; key->y=y; }
[ [ [ 1, 132 ] ] ]
91d92aa7fbd41216c7fc93d7f5dc2379f5efaf4f
40d96e109f1725d1e8d35b6fe2847e6c6a9f7dd6
/src/stdafx.cpp
5eb4a40ec5c05c7d4eff6242891d3f35bdfadfac
[]
no_license
bs-eagle/arithmetic
795167c611a81b6c86d41f9f698af1edcad9ddcc
ff2b2845afcd1858312f7305f282a937cfad1a76
refs/heads/master
2021-01-19T08:24:20.802930
2009-12-14T06:57:14
2009-12-14T06:57:14
null
0
0
null
null
null
null
UTF-8
C++
false
false
302
cpp
// stdafx.cpp : source file that includes just the standard includes // bs_arch.pch will be the pre-compiled header // stdafx.obj will contain the pre-compiled type information #include "bs_arch_stdafx.h" // TODO: reference any additional headers you need in STDAFX.H // and not in this file
[ [ [ 1, 8 ] ] ]
dc0b2380e99fcf2fc02e119c9af6d8074b92c259
de98f880e307627d5ce93dcad1397bd4813751dd
/Sls/SlsDlg.h
d7486d73ab1c218abc077ad51d8d9e8378a7bec4
[]
no_license
weimingtom/sls
7d44391bc0c6ae66f83ddcb6381db9ae97ee0dd8
d0d1de9c05ecf8bb6e4eda8a260c7a2f711615dd
refs/heads/master
2021-01-10T22:20:55.638757
2011-03-19T06:23:49
2011-03-19T06:23:49
44,464,621
2
0
null
null
null
null
UTF-8
C++
false
false
1,742
h
// SlsDlg.h : header file // #if !defined(AFX_SLSDLG_H__78F77400_D8A1_4A7F_83B9_CA297EFA6584__INCLUDED_) #define AFX_SLSDLG_H__78F77400_D8A1_4A7F_83B9_CA297EFA6584__INCLUDED_ #if _MSC_VER > 1000 #pragma once #endif // _MSC_VER > 1000 ///////////////////////////////////////////////////////////////////////////// // CSlsDlg dialog #include <OXBackgroundPainter.h> #include <OXDIB.h> #include "OXBitmapButton.h" class CSlsDlg : public CDialog { // Construction public: CSlsDlg(CWnd* pParent = NULL); // standard constructor // Dialog Data //{{AFX_DATA(CSlsDlg) enum { IDD = IDD_SLS_DIALOG }; CStatic m_RightPanel; COXBitmapButton m_WifiBtn; COXBitmapButton m_VideoBtn; COXBitmapButton m_PlayBtn; COXBitmapButton m_PictureBtn; COXBitmapButton m_PhotoBtn; COXBitmapButton m_CloseBtn; //}}AFX_DATA // ClassWizard generated virtual function overrides //{{AFX_VIRTUAL(CSlsDlg) protected: virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support //}}AFX_VIRTUAL // Implementation protected: HICON m_hIcon; void InitPage(); void InitButtonRect(int bitmapWidth, int bitmapHeight); // Generated message map functions //{{AFX_MSG(CSlsDlg) virtual BOOL OnInitDialog(); afx_msg void OnPaint(); afx_msg HCURSOR OnQueryDragIcon(); //}}AFX_MSG DECLARE_MESSAGE_MAP() private: COXBackgroundPainterOrganizer m_backPainterOrganizer; COXBackgroundPainterOrganizer m_RightbackPainterOrganizer; COXDIB *m_backgroup; COXDIB *m_rightbackgroup; }; //{{AFX_INSERT_LOCATION}} // Microsoft Visual C++ will insert additional declarations immediately before the previous line. #endif // !defined(AFX_SLSDLG_H__78F77400_D8A1_4A7F_83B9_CA297EFA6584__INCLUDED_)
[ "[email protected]", "shiRocket@e83c5d84-83d2-d322-9ac2-7a58409dc7bd" ]
[ [ [ 1, 14 ], [ 17, 25 ], [ 33, 44 ], [ 47, 55 ], [ 57, 57 ], [ 60, 64 ] ], [ [ 15, 16 ], [ 26, 32 ], [ 45, 46 ], [ 56, 56 ], [ 58, 59 ] ] ]
41468a5c69469d55da4db5b57c8b7095f2e39313
57574cc7192ea8564bd630dbc2a1f1c4806e4e69
/Poker/Comun/XmlParserEstadoDentroTag.cpp
f6744c2124348051e21f72ca08e446967bb1a8eb
[]
no_license
natlehmann/taller-2010-2c-poker
3c6821faacccd5afa526b36026b2b153a2e471f9
d07384873b3705d1cd37448a65b04b4105060f19
refs/heads/master
2016-09-05T23:43:54.272182
2010-11-17T11:48:00
2010-11-17T11:48:00
32,321,142
0
0
null
null
null
null
UTF-8
C++
false
false
2,394
cpp
#include "XmlParserEstadoDentroTag.h" #include "XmlParserEstadoInicial.h" XmlParserEstadoDentroTag::XmlParserEstadoDentroTag(deque<string*>* nodosProcesados) : XmlParserEstado(nodosProcesados) { this->procesandoTexto = NULL; this->cerrandoTag = NULL; this->inicial = NULL; } XmlParserEstadoDentroTag::XmlParserEstadoDentroTag( deque<string*>* nodosProcesados, XmlParserEstadoInicial* inicial, XmlParserEstadoProcesandoTxt* procesandoTexto, XmlParserEstadoCerrandoTag* cerrandoTag) : XmlParserEstado(nodosProcesados) { this->procesandoTexto = procesandoTexto; this->cerrandoTag = cerrandoTag; this->inicial = inicial; } XmlParserEstadoDentroTag::~XmlParserEstadoDentroTag(void) { } XmlParserEstado* XmlParserEstadoDentroTag::procesarFragmento() { XmlParserEstado* siguienteEstado = this->getProcesandoTexto(); if (!this->terminado()) { unsigned int indAnyChar = this->getTextoAProcesar().find_first_not_of( " ", this->getInicioTexto()); unsigned int indOpen = this->getTextoAProcesar().find( XML_OPEN, this->getInicioTexto()); unsigned int indCloseTag = this->getTextoAProcesar().find( XML_CLOSE_TAG, this->getInicioTexto()); if ((indOpen < indCloseTag) && (indOpen <= indAnyChar) && (indOpen < this->getTextoAProcesar().size())) { siguienteEstado = this->getInicial(); } else { // si son iguales los indices, gana indCloseTag (<=) if ((indCloseTag <= indOpen) && (indCloseTag <= indAnyChar) && (indCloseTag < this->getTextoAProcesar().size())) { siguienteEstado = this->getCerrandoTag(); this->setInicioTexto(indCloseTag + string(XML_CLOSE_TAG).size()); } } } else { // si se acabo la linea, continuo en el mismo estado siguienteEstado = this; } siguienteEstado->setElementoActual(this->getElementoActual()); siguienteEstado->setTextoAProcesar(this->getTextoAProcesar()); siguienteEstado->setNumeroLinea(this->getNumeroLinea()); siguienteEstado->setInicioTexto(this->getInicioTexto()); return siguienteEstado; } XmlParserEstadoInicial* XmlParserEstadoDentroTag::getInicial() { return this->inicial; } XmlParserEstadoCerrandoTag* XmlParserEstadoDentroTag::getCerrandoTag() { return this->cerrandoTag; } XmlParserEstadoProcesandoTxt* XmlParserEstadoDentroTag::getProcesandoTexto() { return this->procesandoTexto; }
[ "natlehmann@a9434d28-8610-e991-b0d0-89a272e3a296" ]
[ [ [ 1, 79 ] ] ]
5dcc56ccde2c71eb1e0c551f980ececa1f27b1a7
0b55a33f4df7593378f58b60faff6bac01ec27f3
/Konstruct/Client/Dimensions/PlayerPet.cpp
862855e36c8b121028f2d0b227ed0a7d9d6b98cc
[]
no_license
RonOHara-GG/dimgame
8d149ffac1b1176432a3cae4643ba2d07011dd8e
bbde89435683244133dca9743d652dabb9edf1a4
refs/heads/master
2021-01-10T21:05:40.480392
2010-09-01T20:46:40
2010-09-01T20:46:40
32,113,739
1
0
null
null
null
null
UTF-8
C++
false
false
1,499
cpp
#include "StdAfx.h" #include "PlayerPet.h" #include "PlayerPetAI.h" #include "Enemy.h" PlayerPet::PlayerPet(PlayerCharacter* pOwner, int iLevel) { m_pOwner = pOwner; m_iLevel = iLevel; m_pAIBehavior = new PlayerPetAI(this); } PlayerPet::PlayerPet(Enemy* pConvert, PlayerCharacter* pOwner) { PlayerPet(pOwner, pConvert->GetLevel()); //copy all stats m_iStr = pConvert->GetStr(); m_iAgi = pConvert->GetAgi(); m_iInt = pConvert->GetInt(); m_iConst = pConvert->GetConst(); m_iMaxHealth = pConvert->GetMaxHealth(); m_iCurrentHealth = pConvert->GetCurrentHealth(); m_iMaxMental = pConvert->GetMaxMental(); m_iCurrentMental = pConvert->GetCurrentMental(); m_iCrushRes = pConvert->GetResist(eDT_Crushing); m_iSlashRes = pConvert->GetResist(eDT_Slashing); m_iPierceRes = pConvert->GetResist(eDT_Piercing); m_iMentalRes = pConvert->GetResist(eDT_Mental); m_iHeatRes = pConvert->GetResist(eDT_Heat); m_iColdRes = pConvert->GetResist(eDT_Cold); m_iElectRes = pConvert->GetResist(eDT_Electrical); m_iWaterRes = pConvert->GetResist(eDT_Water); m_iAcidRes = pConvert->GetResist(eDT_Acid); m_iViralRes = pConvert->GetResist(eDT_Viral); m_iHolyRes = pConvert->GetResist(eDT_Holy); m_iDeathRes = pConvert->GetResist(eDT_Death); m_pModel = pConvert->GetModel(); m_vHeading = pConvert->GetHeading(); m_fBaseSpeed = pConvert->GetSpeed(); SetLocation(pConvert->GetLocation()); } PlayerPet::~PlayerPet(void) { }
[ "bflassing@0c57dbdb-4d19-7b8c-568b-3fe73d88484e" ]
[ [ [ 1, 48 ] ] ]
4d6525526665d78d96a98bc5371e165b1b3e877a
1ff9f78a9352b12ad34790a8fe521593f60b9d4f
/Template/EnemyBullet.h
bf4fdf5e030244a0e54c569bddf8c6c5d011e25e
[]
no_license
SamOatesUniversity/Year-2---Game-Engine-Construction---Sams-Super-Space-Shooter
33bd39b4d9bf43532a3a3a2386cef96f67132e1e
46022bc40cee89be1c733d28f8bda9fac3fcad9b
refs/heads/master
2021-01-20T08:48:41.912143
2011-01-19T23:52:25
2011-01-19T23:52:25
41,169,993
0
0
null
null
null
null
UTF-8
C++
false
false
275
h
#pragma once #include "worldentity.h" class CEnemyBullet : public CWorldEntity { public: CEnemyBullet(void); ~CEnemyBullet(void); void init( void ); virtual void update( void ); virtual void kill( void ); void fire( const int x, const int y ); };
[ [ [ 1, 17 ] ] ]
d0d79ee0f73d3577b9d5ffc81e943b65531c981f
02c2e62bcb9a54738bfbd95693978b8709e88fdb
/opencv/cvcornersubpix.cpp
ac1b23b989e6f504ae3368f0d56a62825f4704a8
[]
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
8,841
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 "_cv.h" CV_IMPL void cvFindCornerSubPix( const void* srcarr, CvPoint2D32f* corners, int count, CvSize win, CvSize zeroZone, CvTermCriteria criteria ) { float* buffer = 0; CV_FUNCNAME( "cvFindCornerSubPix" ); __BEGIN__; const int MAX_ITERS = 100; const float drv_x[] = { -1.f, 0.f, 1.f }; const float drv_y[] = { 0.f, 0.5f, 0.f }; float *maskX; float *maskY; float *mask; float *src_buffer; float *gx_buffer; float *gy_buffer; int win_w = win.width * 2 + 1, win_h = win.height * 2 + 1; int win_rect_size = (win_w + 4) * (win_h + 4); double coeff; CvSize size, src_buf_size; int i, j, k, pt_i; int max_iters, buffer_size; double eps; CvMat stub, *src = (CvMat*)srcarr; CV_CALL( src = cvGetMat( srcarr, &stub )); if( CV_MAT_TYPE( src->type ) != CV_8UC1 ) CV_ERROR( CV_StsBadMask, "" ); if( !corners ) CV_ERROR( CV_StsNullPtr, "" ); if( count <= 0 ) CV_ERROR( CV_StsBadSize, "" ); if( win.width <= 0 || win.height <= 0 ) CV_ERROR( CV_StsBadSize, "" ); size = cvGetMatSize( src ); if( size.width < win_w + 4 || size.height < win_h + 4 ) CV_ERROR( CV_StsBadSize, "" ); /* initialize variables, controlling loop termination */ switch( criteria.type ) { case CV_TERMCRIT_ITER: eps = 0.f; max_iters = criteria.max_iter; break; case CV_TERMCRIT_EPS: eps = criteria.epsilon; max_iters = MAX_ITERS; break; case CV_TERMCRIT_ITER | CV_TERMCRIT_EPS: eps = criteria.epsilon; max_iters = criteria.max_iter; break; default: assert( 0 ); CV_ERROR( CV_StsBadFlag, "" ); } eps = MAX( eps, 0 ); eps *= eps; /* use square of error in comparsion operations. */ max_iters = MAX( max_iters, 1 ); max_iters = MIN( max_iters, MAX_ITERS ); /* setup buffer */ buffer_size = (win_rect_size * 5 + win_w + win_h + 32) * sizeof(float); buffer = (float*)cvAlloc( buffer_size ); /* assign pointers */ maskX = buffer; maskY = maskX + win_w + 4; mask = maskY + win_h + 4; src_buffer = mask + win_w * win_h; gx_buffer = src_buffer + win_rect_size; gy_buffer = gx_buffer + win_rect_size; coeff = 1. / (win.width * win.width); /* calculate mask */ for( i = -win.width, k = 0; i <= win.width; i++, k++ ) { maskX[k] = (float)exp( -i * i * coeff ); } if( win.width == win.height ) { maskY = maskX; } else { coeff = 1. / (win.height * win.height); for( i = -win.height, k = 0; i <= win.height; i++, k++ ) { maskY[k] = (float) exp( -i * i * coeff ); } } for( i = 0; i < win_h; i++ ) { for( j = 0; j < win_w; j++ ) { mask[i * win_w + j] = maskX[j] * maskY[i]; } } /* make zero_zone */ if( zeroZone.width >= 0 && zeroZone.height >= 0 && zeroZone.width * 2 + 1 < win_w && zeroZone.height * 2 + 1 < win_h ) { for( i = win.height - zeroZone.height; i <= win.height + zeroZone.height; i++ ) { for( j = win.width - zeroZone.width; j <= win.width + zeroZone.width; j++ ) { mask[i * win_w + j] = 0; } } } /* set sizes of image rectangles, used in convolutions */ src_buf_size.width = win_w + 2; src_buf_size.height = win_h + 2; /* do optimization loop for all the points */ for( pt_i = 0; pt_i < count; pt_i++ ) { CvPoint2D32f cT = corners[pt_i], cI = cT; int iter = 0; double err; do { CvPoint2D32f cI2; double a, b, c, bb1, bb2; IPPI_CALL( icvGetRectSubPix_8u32f_C1R( (uchar*)src->data.ptr, src->step, size, src_buffer, (win_w + 2) * sizeof( src_buffer[0] ), cvSize( win_w + 2, win_h + 2 ), cI )); /* calc derivatives */ icvSepConvSmall3_32f( src_buffer, src_buf_size.width * sizeof(src_buffer[0]), gx_buffer, win_w * sizeof(gx_buffer[0]), src_buf_size, drv_x, drv_y, buffer ); icvSepConvSmall3_32f( src_buffer, src_buf_size.width * sizeof(src_buffer[0]), gy_buffer, win_w * sizeof(gy_buffer[0]), src_buf_size, drv_y, drv_x, buffer ); a = b = c = bb1 = bb2 = 0; /* process gradient */ for( i = 0, k = 0; i < win_h; i++ ) { double py = i - win.height; for( j = 0; j < win_w; j++, k++ ) { double m = mask[k]; double tgx = gx_buffer[k]; double tgy = gy_buffer[k]; double gxx = tgx * tgx * m; double gxy = tgx * tgy * m; double gyy = tgy * tgy * m; double px = j - win.width; a += gxx; b += gxy; c += gyy; bb1 += gxx * px + gxy * py; bb2 += gxy * px + gyy * py; } } { double A[4]; double InvA[4]; CvMat matA, matInvA; A[0] = a; A[1] = A[2] = b; A[3] = c; cvInitMatHeader( &matA, 2, 2, CV_64F, A ); cvInitMatHeader( &matInvA, 2, 2, CV_64FC1, InvA ); cvInvert( &matA, &matInvA, CV_SVD ); cI2.x = (float)(cI.x + InvA[0]*bb1 + InvA[1]*bb2); cI2.y = (float)(cI.y + InvA[2]*bb1 + InvA[3]*bb2); } err = (cI2.x - cI.x) * (cI2.x - cI.x) + (cI2.y - cI.y) * (cI2.y - cI.y); cI = cI2; } while( ++iter < max_iters && err > eps ); /* if new point is too far from initial, it means poor convergence. leave initial point as the result */ if( fabs( cI.x - cT.x ) > win.width || fabs( cI.y - cT.y ) > win.height ) { cI = cT; } corners[pt_i] = cI; /* store result */ } __CLEANUP__; __END__; cvFree( (void**)&buffer ); } /* End of file. */
[ [ [ 1, 265 ] ] ]
6fa5829955540ba52adeecf7d53e63df9b02b007
6e563096253fe45a51956dde69e96c73c5ed3c18
/dhnetsdk/dvr/dvrdevice/dvrsnapchannel.h
74dca085c195a4ce4cbb92227fb997d3a87edbc4
[]
no_license
15831944/phoebemail
0931b76a5c52324669f902176c8477e3bd69f9b1
e10140c36153aa00d0251f94bde576c16cab61bd
refs/heads/master
2023-03-16T00:47:40.484758
2010-10-11T02:31:02
2010-10-11T02:31:02
null
0
0
null
null
null
null
GB18030
C++
false
false
1,373
h
/* * Copyright (c) 2009, 浙江亿蛙技术股份有限公司 * All rights reserved. * * 类名称:抓图功能交互类 * 摘 要:抓图功能数据交互。 * */ ////////////////////////////////////////////////////////////////////////// #ifndef _DVRSNAPCHANNEL_H_ #define _DVRSNAPCHANNEL_H_ #include "dvrchannel.h" class CDvrDevice; #define MAX_SNAPBUFFER_LEN 1048576 //1M bytes class CDvrSnapChannel : public CDvrChannel { public: CDvrSnapChannel(CDvrDevice *pDvrDevice, int nMainCommand, void *pParam); virtual ~CDvrSnapChannel(); public: /* 关闭通道 */ virtual BOOL channel_close(); /* 暂停通道 */ virtual BOOL channel_pause(BOOL pause); /* 获取信息 */ virtual int channel_get_info(int type, void *parm); /* 设置信息 */ virtual int channel_set_info(int type, void *parm); /* 处理命令 */ virtual int OnRespond(unsigned char *pBuf, int nLen); public: int GetChannelIndex() { return m_snap_channel_parm.no; } int GetChannelSubtype() { return m_snap_channel_parm.subtype; } protected: unsigned char m_SnapPicBytes[MAX_SNAPBUFFER_LEN]; // 抓图返回数据缓存 afk_snap_channel_param_s m_snap_channel_parm; BOOL m_bWorking; LONG m_Pos; // 图片暂存缓存位置 }; #endif // _DVRSNAPCHANNEL_H_
[ "guoqiao@a83c37f4-16cc-5f24-7598-dca3a346d5dd" ]
[ [ [ 1, 57 ] ] ]
af209fcab701ed28f04655b8e4f44973b0a9c640
b23a27888195014aa5bc123d7910515e9a75959c
/Main/commonlib/stringstext.cpp
b9ea844f32822c21e467570853bd26f394462a35
[]
no_license
fostrock/connectspot
c54bb5484538e8dd7c96b76d3096dad011279774
1197a196d9762942c0d61e2438c4a3bca513c4c8
refs/heads/master
2021-01-10T11:39:56.096336
2010-08-17T05:46:51
2010-08-17T05:46:51
50,015,788
1
0
null
null
null
null
GB18030
C++
false
false
2,075
cpp
//------------------------------------------------------------------------------------------ // File: <stringstext.cpp> // Purpose: implement <string and text manipulating lib> // // @author <Yun Hua> // @version 1.0 2010/03/04 // // Copyright (C) 2010, Yun Hua //-----------------------------------------------------------------------------------------// #include "stdafx.h" #include "stringstext.h" #include <string> #include <iostream> #include <algorithm> #include <cctype> #include <cwctype> using namespace std; namespace CommonLib { bool StringsText::CaseInsCompare(const string& s1, const string& s2) { return((s1.size( ) == s2.size( )) && equal(s1.begin( ), s1.end( ), s2.begin( ), CaseInsCharCompareN)); } bool StringsText::CaseInsCompare(const wstring& s1, const wstring& s2) { return((s1.size( ) == s2.size( )) && equal(s1.begin( ), s1.end( ), s2.begin( ), CaseInsCharCompareW)); } LPWSTR StringsText::StrToWChar(LPCSTR pMultiByteStr, unsigned codePage) { int nLenOfWideCharStr; LPWSTR pWideCharStr; // 计算宽字符占的char空间 nLenOfWideCharStr = MultiByteToWideChar(codePage, 0, pMultiByteStr, -1, NULL, 0); // 从堆中分配空间 pWideCharStr = (LPWSTR)HeapAlloc(GetProcessHeap(), 0, nLenOfWideCharStr * sizeof(WCHAR)); // 转换 MultiByteToWideChar(codePage, 0, pMultiByteStr, -1, pWideCharStr, nLenOfWideCharStr); return pWideCharStr; } // wchar_t to multi byte string using the code page bool StringsText::WCharToStr(LPCWSTR pWideCharStr, LPSTR* pMultiByteStr, unsigned codePage) { int nLenOfMultiByteStr; bool fOk = false; nLenOfMultiByteStr = ::WideCharToMultiByte(codePage, 0, pWideCharStr, -1, NULL, 0, NULL, NULL); *pMultiByteStr = (char*)HeapAlloc(GetProcessHeap(), 0, nLenOfMultiByteStr * sizeof(CHAR)); if (*pMultiByteStr == NULL) { return(fOk); } ::WideCharToMultiByte(codePage, 0, pWideCharStr, -1, *pMultiByteStr, nLenOfMultiByteStr, NULL, NULL); fOk = true; return fOk; } }
[ [ [ 1, 70 ] ] ]
5efb8ad27a6d8e114cd359b9e30d0f7001321493
6b99c157ea698e70fca17073c680638f8e516d08
/globals.cpp
4d2fc80b34ded5f39a7f7aff36600f1d6253f55d
[]
no_license
melagabri/sendelf
3aef89b2e3e7d0424e738fbe87701672d6026fbf
beb17f02ceef3f71cf9e13cae545abe77c282764
refs/heads/master
2021-01-10T06:30:37.130626
2009-10-10T16:39:39
2009-10-10T16:39:39
54,057,363
0
0
null
null
null
null
UTF-8
C++
false
false
201
cpp
#include "stdafx.h" #include "SendElf.h" TCHAR portString[12]; TCHAR ipString[17]; TCHAR filename[260]; TCHAR args[MAX_ARGS_LEN+1]; DWORD protocol; HWND hMainDialog; HINSTANCE hInstGecko;
[ [ [ 1, 11 ] ] ]
67c2de9c7e2674d2bc722d922daa221c454cd209
fd4f996b64c1994c5e6d8c8ff78a2549255aacb7
/ nicolinorochetaller --username adrianachelotti/trunk/tp3/ClienteUno/Textura.cpp
4865097d457bbb45e5e13c95370ff6bbab2a0a06
[]
no_license
adrianachelotti/nicolinorochetaller
026f32476e41cdc5ac5c621c483d70af7b397fb0
d3215dfdfa70b6226b3616c78121f36606135a5f
refs/heads/master
2021-01-10T19:45:15.378823
2009-08-05T14:54:42
2009-08-05T14:54:42
32,193,619
0
0
null
null
null
null
UTF-8
C++
false
false
787
cpp
// Textura.cpp: implementation of the Textura class. // ////////////////////////////////////////////////////////////////////// #include "Textura.h" Textura::Textura() { } Textura::~Textura() { } Textura::Textura(string id,string path) { this->id = id; this->path = path; this->imagen = NULL; } void Textura::setId(string id) { this->id = id; } string Textura::getId() { return this->id; } void Textura::setPath(string path) { this->path = path; } string Textura::getPath() { return this->path; } SDL_Surface* Textura::getImagen() { if(this->imagen==NULL) { this->imagen = SDL_LoadBMP(path.c_str()); } return this->imagen; } void Textura::setImagen(SDL_Surface* imagen) { this->imagen = imagen; }
[ "[email protected]@0b808588-0f27-11de-aab3-ff745001d230" ]
[ [ [ 1, 58 ] ] ]
9c12ddf691df15331dab4496152e4173dccfd3eb
854ee643a4e4d0b7a202fce237ee76b6930315ec
/arcemu_svn/src/arcemu-world/ArenaTeam.h
88a527a0d2db1ad258f63367e1f4b505e3d341de
[]
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
2,778
h
/* * ArcEmu MMORPG Server * Copyright (C) 2005-2007 Ascent Team <http://www.ascentemu.com/> * Copyright (C) 2008 <http://www.ArcEmu.org/> * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * */ #ifndef arcemu_ARENATEAMS_H #define arcemu_ARENATEAMS_H struct ArenaTeamMember { PlayerInfo * Info; uint32 Played_ThisWeek; uint32 Won_ThisWeek; uint32 Played_ThisSeason; uint32 Won_ThisSeason; uint32 PersonalRating; }; class SERVER_DECL ArenaTeam { void AllocateSlots(uint32 Type) { uint32 Slots = 0; if(Type == ARENA_TEAM_TYPE_2V2) Slots=4; else if(Type == ARENA_TEAM_TYPE_3V3) Slots=6; else if(Type == ARENA_TEAM_TYPE_5V5) Slots=10; ASSERT(Slots); m_members = new ArenaTeamMember[Slots]; memset(m_members,0,sizeof(ArenaTeamMember)*Slots); m_slots = Slots; m_memberCount=0; } public: uint32 m_id; uint32 m_type; uint32 m_leader; uint32 m_slots; string m_name; uint32 m_memberCount; ArenaTeamMember * m_members; uint32 m_emblemStyle; uint32 m_emblemColour; uint32 m_borderStyle; uint32 m_borderColour; uint32 m_backgroundColour; uint32 m_stat_rating; uint32 m_stat_gamesplayedweek; uint32 m_stat_gameswonweek; uint32 m_stat_gamesplayedseason; uint32 m_stat_gameswonseason; uint32 m_stat_ranking; ArenaTeam(uint32 Type, uint32 Id); ArenaTeam(Field * f); ~ArenaTeam() { delete [] m_members; } void SendPacket(WorldPacket * data); void Query(WorldPacket & data); void Stat(WorldPacket & data); void Roster(WorldPacket & data); void Inspect(WorldPacket & data); void Destroy(); void SaveToDB(); bool AddMember(PlayerInfo * info); bool RemoveMember(PlayerInfo * info); bool HasMember(uint32 guid); void SetLeader(PlayerInfo * info); ArenaTeamMember * GetMember(PlayerInfo * info); ArenaTeamMember * GetMemberByGuid(uint32 guid); uint32 GetPlayersPerTeam() { switch(m_type) { case ARENA_TEAM_TYPE_2V2: return 2; case ARENA_TEAM_TYPE_3V3: return 3; case ARENA_TEAM_TYPE_5V5: return 5; } // never reached return 2; } }; #endif // arcemu_ARENATEAMS_H
[ "[email protected]@3074cc92-8d2b-11dd-8ab4-67102e0efeef", "[email protected]@3074cc92-8d2b-11dd-8ab4-67102e0efeef" ]
[ [ [ 1, 1 ], [ 5, 20 ], [ 23, 115 ] ], [ [ 2, 4 ], [ 21, 22 ], [ 116, 116 ] ] ]
cf08ea2b59669918d1be8d6b248a0c1ec508d20c
b9115b524856b1595a21004603ce52bc25440515
/Conversation/header_files/Conversation/CTextArea.hpp
63be877b67ef85abe4822f343b41bf9b8ab2279d
[]
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
2,364
hpp
/* * CTextarea.hpp * * Created on: 25.08.2010 * Author: Martu */ #ifndef CTEXTAREA_HPP_ #define CTEXTAREA_HPP_ #include "CFXSprite.hpp" #include "CImageManager.hpp" #include "CFontManager.hpp" // describes a class which is used for creating a text area for the game class CTextArea { private: sf::Vector2f m_Position; // Position of the Area sf::Vector2f m_Size; // Size of the Area (Ignored when a sprite is the background) CFXSprite m_BackgroundSprite; bool m_bCursor; // if the cursor should displayed or not bool m_bIsActive; // If the complete text is displayed or not float m_fCursorBlinkSpeed; // Speed for the Blinking of the Cursor float m_fElapsedTimeCursor; // Elapsed time for the Cursor Blinking float m_fTextSpeed; // speed for the single characters of the Text to appear float m_fElapsedTime; // Elapsed time for the Text float m_fCurAlpha; // Current alpha value of the text, used for scenechanges while fading int m_CurPos; // current number of character to display string m_sCompleteText; // complete Text string m_sPartText; // Part of the Text to display sf::String m_sDisplayText; // characters which should be displayed sf::String m_sSpeakerName; // Name of the Speaker sf::Color m_SpeakerColor; // Color for the Speaker sf::Color m_MessageColor; // Color for normal messages sf::Color m_ReadMessageColor; // Color for read messages public: void Init (sf::Vector2f Position, sf::Vector2f Size, string Font, int FontSize, float fSpeed, float fBlinkSpeed); void SetBackgroundSprite (string BGSprite); void SetBackgroundColor (sf::Color BGColor); void SetTextColor (sf::Color Text, sf::Color ReadMessage); void SetTextColor (sf::Color Text, sf::Color ReadMessage, sf::Color Speaker); void SetSpeakerPosition (sf::Vector2f Position); void SetTextPosition (sf::Vector2f Position); void SetText (string sSpeaker, string sText, bool bIsRead = false); void SetFade (float from, float to, float duration); bool IsActive () {return m_bIsActive;}; void DisplayAll (); void Update (float fElapsed); void Render (sf::RenderWindow *pWindow); }; #endif /* CTEXTAREA_HPP_ */
[ [ [ 1, 60 ] ] ]
663507094482abb6de130ebaff19bf6cc4724b25
81128e8bcf44c1db5790433785e83bbd70b8d9c2
/Testbed/Tests/TestFixture.cpp
258ea213ae48862b7cd1878399b8c0778c172384
[ "Zlib" ]
permissive
vanminhle246/Box2D_v2.2.1
8a16ef72688c6b03466c7887e501e92f264ed923
6f06dda1e2c9c7277ce26eb7aa6340863d1f3bbb
refs/heads/master
2016-09-05T18:41:00.133321
2011-11-28T07:47:32
2011-11-28T07:47:32
2,817,435
0
0
null
null
null
null
UTF-8
C++
false
false
2,004
cpp
#include "TestFixture.h" TestFixture::TestFixture(void) { b2BodyDef myBodyDef; myBodyDef.type = b2_dynamicBody; myBodyDef.position.Set(-10, 20); b2Body* dynamicBody1 = m_world->CreateBody(&myBodyDef); b2CircleShape circleShape; circleShape.m_p.Set(0, 0); circleShape.m_radius = 1; b2FixtureDef myFixtureDef; myFixtureDef.density = 1; myFixtureDef.shape = &circleShape; dynamicBody1->CreateFixture(&myFixtureDef); /** b2Vec2 vertices[12]; vertices[0].Set(0, -1); vertices[1].Set(1, 0); vertices[2].Set(1, -2); vertices[3].Set(2, -2); vertices[4].Set(2, 2); vertices[5].Set(1, 2); vertices[6].Set(0, 1); vertices[7].Set(-1, 2); vertices[8].Set(-2, 2); vertices[9].Set(-2, -2); vertices[10].Set(-1, -2); vertices[11].Set(-1, 0); /**/ /**/ b2Vec2 vertices[5]; vertices[0].Set(-1 +10, 2); vertices[1].Set(-1 +10, 0); vertices[2].Set( 0 +10, -3); vertices[3].Set( 1 +10, 0); vertices[4].Set( 1 +10, 1); /**/ b2PolygonShape polygonShape; polygonShape.Set(vertices, 5); myFixtureDef.shape = &polygonShape; myBodyDef.position.Set(0, 20); b2Body* dynamicBody2 = m_world->CreateBody(&myBodyDef); dynamicBody2->CreateFixture(&myFixtureDef); polygonShape.SetAsBox(2, 1); myBodyDef.position.Set(10, 20); b2Body* dynamicBody3 = m_world->CreateBody(&myBodyDef); dynamicBody3->CreateFixture(&myFixtureDef); myBodyDef.type = b2_staticBody; myBodyDef.position.Set(0, 0); b2EdgeShape edgeShape; edgeShape.Set(b2Vec2(-15,0), b2Vec2(15,0)); myFixtureDef.shape = &edgeShape; //polygonShape.SetAsBox(15, 0.01); b2Body* staticBody = m_world->CreateBody(&myBodyDef); staticBody->CreateFixture(&myFixtureDef); } TestFixture::~TestFixture(void) { } void TestFixture::Step(Settings* settings) { //run the default physics and rendering Test::Step(settings); //show some text in the main screen m_debugDraw.DrawString(5, m_textLine, "Now we have a fixture test"); m_textLine += 15; }
[ [ [ 1, 79 ] ] ]
4302f04af29f363de96429080ef3cccefd18a099
e5ded38277ec6db30ef7721a9f6f5757924e130e
/Cpp/SoSe10/Blatt05.Aufgabe03/Blatt05.Aufgabe03.cpp
3451b45ca09779edc585e11264bcb1d8a7e7acbc
[]
no_license
TetsuoCologne/sose10
67986c8a014c4bdef19dc52e0e71e91602600aa0
67505537b0eec497d474bd2d28621e36e8858307
refs/heads/master
2020-05-27T04:36:02.620546
2010-06-22T20:47:08
2010-06-22T20:47:08
32,480,813
0
0
null
null
null
null
UTF-8
C++
false
false
435
cpp
// Blatt05.Aufgabe03.cpp : Defines the entry point for the console application. // #include "stdafx.h" #include <iostream> #include <string> #include <fstream> using namespace std; struct Data { int x, y; }; void readData(const char*, unsigned int&, Data*&); int _tmain(int argc, _TCHAR* argv[]) { return 0; } void readData(const char* pcFileName, unsigned int& szData, Data*& data) { ifstream in; }
[ "[email protected]@f2f8bf26-27bb-74d3-be08-1e18597623ec" ]
[ [ [ 1, 27 ] ] ]
b1d0a8dd51106a8af4c15125fab3da2ccff2ee35
3b5dcd8c97cf0b128ff4571f616e6f93cde4d14f
/src-qt3/StandardTypes/Modules/Video/Common/v4ldemos/rgb2yuv.cpp
dc6b90364d7844fa2fda45323efc529bc4597b0e
[]
no_license
jeez/iqr
d096820360516cda49f33a96cfe34ded36300c4c
c6e066cc5d4ce235d4399ca34e0b238d7784a7af
refs/heads/master
2021-01-01T16:55:55.516919
2011-02-10T12:00:01
2011-02-10T12:00:01
1,109,194
1
0
null
null
null
null
UTF-8
C++
false
false
2,611
cpp
/*--------------------------------------------------------------------------------------*/ // File: rgb2yuv.cpp // Desription: Rgb2yuv class implementation // Author: Ben Bridgwater // History: // 09/16/00 Initial revision. /*--------------------------------------------------------------------------------------*/ #include "rgb2yuv.h" /*--------------------------------------------------------------------------------------*/ RGB2YUV::RGB2YUV() { float f_y_, f_cb, f_cr; int y_, cb, cr; for (int r = 0; r <= 255; r++) { // yr, ur, vr yr[r] = ((int) (0.2990 * r)) * 256; ur[r] = - ((int) (0.1678 * r)) * 256; vr[r] = ((int) (0.5000 * r)) * 256; } // end for for (int g = 0; g <= 255; g++) { // yg, ug, vg yg[g] = ((int) (0.5670 * g)) * 256; ug[g] = - ((int) (0.3313 * g)) * 256; vg[g] = - ((int) (0.4187 * g)) * 256; } // end for for (int b = 0; b <= 255; b++) { // yb, ub, vb yb[b] = ((int) (0.1140 * b)) * 256; ub[b] = ((int) (0.5000 * b)) * 256; vb[b] = - ((int) (0.0813 * b)) * 256; } // end for for (int y = 0; y <= 255; y++) { // y2y_ f_y_ = ((float) 219 / 255) * (y + 16); y_ = (int) (f_y_ + 0.5); if (y_ < 16) y_ = 16; else if (y_ > 235) y_ = 235; y2y_[y] = y_; } // end for for (int u = 0; u <= 255; u++) { // u2cb f_cb = ((float) 112 / 127) * (u + 128); cb = (int) (f_cb + 0.5); if (cb < 16) cb = 16; else if (cb > 240) cb = 240; u2cb[u] = cb; } // end for for (int v = 0; v <= 255; v++) { // v2cr f_cr = ((float) 112 / 127) * (v + 128); cr = (int) (f_cr + 0.5); if (cr < 16) cr = 16; else if (cr > 240) cr = 240; v2cr[v] = cr; } // end for } // end RGB2YUV::RGB2YUV /*--------------------------------------------------------------------------------------*/ YUV2RGB::YUV2RGB() { float y, u, v; for (int y_ = 0; y_ <= 255; y_++) { // xy y = ((float) 255 / 219) * (y_ - 16); xy[y_] = ((int) y) * 256; } // end for for (int cb = 0; cb <= 255; cb++) { // gu, bu u = ((float) 127 / 112) * (cb - 128); gu[cb] = - ((int) (0.344 * u)) * 256; bu[cb] = ((int) (1.772 * u)) * 256; } // end for for (int cr = 0; cr <= 255; cr++) { // rv, gv v = ((float) 127 / 112) * (cr - 128); rv[cr] = ((int) (1.402 * v)) * 256; gv[cr] = - ((int) (0.714 * v)) * 256; } // end for } // end YUV2RGB::YUV2RGB /*--------------------------------------------------------------------------------------*/
[ [ [ 1, 93 ] ] ]
cc62fef54fb27cce67c582553a27d185b9dad582
629e4fdc23cb90c0144457e994d1cbb7c6ab8a93
/lib/entity/mutableentitytemplate.cpp
90785c6c8ca51730ad3cbf328e2e239ff680e0c0
[]
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
965
cpp
/* * mutableentitytemplate.cpp * * Created on: 9.11.2011 * Author: akin */ #include "mutableentitytemplate" namespace ice { MutableEntityTemplate::MutableEntityTemplate( std::string name ) : EntityTemplate( name ) { } MutableEntityTemplate::~MutableEntityTemplate() { } void MutableEntityTemplate::setName( std::string name ) { this->name = name; } void MutableEntityTemplate::attach( Component& component ) { components.push_back( &component ); } void MutableEntityTemplate::attach( EntityTemplate& tpl ) { templates.push_back( &tpl ); } void MutableEntityTemplate::attach( Entity& entity ) { // Attach this templates components. for( int i = components.size() - 1 ; i >= 0 ; --i ) { components.at( i )->attach( entity ); } // Attach slave templates components. for( int i = templates.size() - 1 ; i >= 0 ; --i ) { templates.at( i )->attach( entity ); } } } /* namespace ice */
[ "akin@localhost" ]
[ [ [ 1, 51 ] ] ]
59bef36719e9d31f268cd3f307dca84ee8d44528
3da0b0276bc8c3d7d1bcdbabfb0e763a38d3a24c
/zju.finished/2731.cpp
ade8fa68bda049965715045ddbc665f5f98c3a5e
[]
no_license
usherfu/zoj
4af6de9798bcb0ffa9dbb7f773b903f630e06617
8bb41d209b54292d6f596c5be55babd781610a52
refs/heads/master
2021-05-28T11:21:55.965737
2009-12-15T07:58:33
2009-12-15T07:58:33
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,289
cpp
#include<iostream> using namespace std; enum { SIZ = 1008, }; int jose[SIZ]; int die[SIZ]; int n, m; // 先计算当jose被杀时,剩下的那个人与他的距离,再把他调整到jose的位置 // jose 向下换到新的位置 void fun(){ int i, s = 1, t; m--; for(i=1; i<n;i++){ t = n - i + 1; s = (s + m -1)% t + 1; die[i-1] = s; jose[i] = jose[i-1]; if(jose[i-1] > s){ jose[i]--; } else if(jose[i-1]==s){ jose[i] = -1; } if(s==n-i+1){ s = 1; } } if(jose[i-1]!=-1){ printf("%d\n", jose[0]); return; } s = 1; for(i=n-1; i>0 && jose[i]==-1; i--){ if(s>=die[i-1]){ s++; } } t = n - i; /* if( s > jose[i]){ m = s - jose[i]; } else { m = t - jose[i] + s; } s = jose[i] - m + t; */ s = 2 * jose[i] - s + t; s = (s-1) % t + 1; for( ; i>0; i--){ if(s>=die[i-1]){ s++; } } printf("%d\n", s); } int readIn(){ scanf("%d%d%d",&n,&m,&jose[0]); return n+m+jose[0]; } int main(){ while(readIn() > 0){ fun(); } return 0; }
[ [ [ 1, 67 ] ] ]
5f31d0b30557044156014afd905d8ba98c1dd021
6b3fa487428d3e2c66376572fd3c6dd3501b282c
/sapien190/trunk/source/Sandbox/Sapien/rpy/RecordFile.h
62f13d2b2eb848c63647a7bb7dc98784272bf43f
[]
no_license
kimbjerge/iirtsf10grp5
8626a10b23ee5cdde9944280c3cd06833e326adb
3cbdd2ded74369d2cd455f63691abc834edfb95c
refs/heads/master
2021-01-25T06:36:48.487881
2010-06-03T09:26:19
2010-06-03T09:26:19
32,920,746
0
0
null
null
null
null
UTF-8
C++
false
false
1,425
h
/********************************************************************* Rhapsody : 7.5 Login : KBE Component : DefaultComponent Configuration : DefaultConfig Model Element : RecordFile //! Generated Date : Fri, 30, Apr 2010 File Path : DefaultComponent/DefaultConfig/RecordFile.h *********************************************************************/ #ifndef RecordFile_H #define RecordFile_H //#[ ignore #ifdef _MSC_VER // disable Microsoft compiler warning (debug information truncated) #pragma warning(disable: 4786) #endif //#] //## auto_generated #include <oxf/oxf.h> //## auto_generated #include <string> //## auto_generated #include <algorithm> //## auto_generated #include "Continuous.h" //## class RecordFile #include "Record.h" //## auto_generated #include "math.h" //## package Application::Continuous //## class RecordFile class RecordFile : public Record { public : //// Constructors and destructors //// //## auto_generated RecordFile(); //// Operations //// //// Additional operations //// //// Attributes //// //## auto_generated ~RecordFile(); }; #endif /********************************************************************* File Path : DefaultComponent/DefaultConfig/RecordFile.h *********************************************************************/
[ "bjergekim@49e60964-1571-11df-9d2a-2365f6df44e6" ]
[ [ [ 1, 57 ] ] ]
0b472611f5b381e06bfcf7216ac789ed0abd1f53
6c8c4728e608a4badd88de181910a294be56953a
/OgreRenderingModule/OgreSkeletonResource.h
34432416a098ad97396df12bc47af18953a37856
[ "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
2,121
h
// For conditions of distribution and use, see copyright notice in license.txt #ifndef incl_OgreRenderer_OgreSkeletonResource_h #define incl_OgreRenderer_OgreSkeletonResource_h #include "AssetInterface.h" #include "ResourceInterface.h" #include "OgreModuleApi.h" #include <OgreSkeleton.h> namespace OgreRenderer { class OgreSkeletonResource; typedef boost::shared_ptr<OgreSkeletonResource> OgreSkeletonResourcePtr; //! An Ogre-specific skeleton resource, contains bone structure and skeletal animations /*! \ingroup OgreRenderingModuleClient */ class OGRE_MODULE_API OgreSkeletonResource : public Foundation::ResourceInterface { public: //! Generates an empty unloaded skeleton resource. /*! \param id The resource ID that is associated to this skeleton. */ explicit OgreSkeletonResource(const std::string& id); //! constructor /*! \param id material id \param source asset data to construct skeleton from */ OgreSkeletonResource(const std::string& id, Foundation::AssetPtr source); //! destructor virtual ~OgreSkeletonResource(); //! returns resource type in text form virtual const std::string& GetType() const; //! returns whether resource valid virtual bool IsValid() const; //! returns Ogre skeleton /*! may be null if no data successfully set yet */ Ogre::SkeletonPtr GetSkeleton() const { return ogre_skeleton_; } //! sets contents from asset data /*! \param source asset data to construct the skeleton from \return true if successful */ bool SetData(Foundation::AssetPtr source); //! returns resource type in text form (static) static const std::string& GetTypeStatic(); private: Ogre::SkeletonPtr ogre_skeleton_; //! Deinitializes the skeleton and frees all Ogre-side structures as well. void RemoveSkeleton(); }; } #endif
[ "cadaver@5b2332b8-efa3-11de-8684-7d64432d61a3" ]
[ [ [ 1, 66 ] ] ]
3a174f5c2a42c8f38c80fce9187d5527bd8b2be2
5bd189ea897b10ece778fbf9c7a0891bf76ef371
/BasicEngine/BasicEngine/Game/InputConfiguration.cpp
606ad1afb6d76e2648524d49a38f644ec83779c8
[]
no_license
boriel/masterullgrupo
c323bdf91f5e1e62c4c44a739daaedf095029710
81b3d81e831eb4d55ede181f875f57c715aa18e3
refs/heads/master
2021-01-02T08:19:54.413488
2011-12-14T22:42:23
2011-12-14T22:42:23
32,330,054
0
0
null
null
null
null
WINDOWS-1250
C++
false
false
1,660
cpp
#include "InputConfiguration.h" #include "..\Input\InputManager.h" #include "..\Input\Mouse.h" tActionMapping kaActionMapping[] = { { eIA_CloseApplication, eKeyboard, OIS::KC_ESCAPE }, { eIA_CloseApplication, eMouse, eMouse_Button1}, // Se sale con el botón izquierdo { eIA_Up, eKeyboard, OIS::KC_UP }, { eIA_Down, eKeyboard, OIS::KC_DOWN }, { eIA_Left, eKeyboard, OIS::KC_LEFT }, { eIA_Right, eKeyboard, OIS::KC_RIGHT }, { eIA_PlayerForward, eKeyboard, OIS::KC_UP }, { eIA_PlayerBack, eKeyboard, OIS::KC_DOWN }, { eIA_PlayerLeft, eKeyboard, OIS::KC_LEFT }, { eIA_PlayerRight, eKeyboard, OIS::KC_RIGHT }, { eIA_CameraForward, eKeyboard, OIS::KC_W }, { eIA_CameraBack, eKeyboard, OIS::KC_S }, { eIA_CameraLeft, eKeyboard, OIS::KC_A }, { eIA_CameraRight, eKeyboard, OIS::KC_D }, { eIA_CameraUp, eKeyboard, OIS::KC_PGUP }, { eIA_CameraDown, eKeyboard, OIS::KC_PGDOWN }, { eIA_ChangeMode, eKeyboard, OIS::KC_F1 }, { eIA_PlayJog, eKeyboard, OIS::KC_1 }, { eIA_StopJog, eKeyboard, OIS::KC_2 }, { eIA_PlayWave, eKeyboard, OIS::KC_3 }, { eIA_StopWave, eKeyboard, OIS::KC_4 }, { eIA_ChangeModeDebug, eKeyboard, OIS::KC_F9 }, { eIA_ChangeCamera, eKeyboard, OIS::KC_F8 }, { eIA_CameraRecorridoLibre, eKeyboard, OIS::KC_F7 }, { eIA_KeyI, eKeyboard, OIS::KC_I }, { eIA_KeyK, eKeyboard, OIS::KC_K }, { eIA_KeyJ, eKeyboard, OIS::KC_J }, { eIA_KeyL, eKeyboard, OIS::KC_L }, { eIA_Accept, eKeyboard, OIS::KC_RETURN}, { eIA_Reload, eKeyboard, OIS::KC_R}, { eIA_Drift, eKeyboard, OIS::KC_SPACE}, { eIA_Colon, eKeyboard, OIS::KC_COLON}, { -1, -1, -1 } // End of the table (Marca el final de la tabla) };
[ "yormanh@f2da8aa9-0175-0678-5dcd-d323193514b7", "[email protected]@f2da8aa9-0175-0678-5dcd-d323193514b7", "davidvargas.tenerife@f2da8aa9-0175-0678-5dcd-d323193514b7", "[email protected]@f2da8aa9-0175-0678-5dcd-d323193514b7", "[email protected]@f2da8aa9-0175-0678-5dcd-d323193514b7" ]
[ [ [ 1, 2 ], [ 4, 6 ], [ 8, 11 ], [ 27, 28 ], [ 30, 33 ], [ 35, 35 ], [ 38, 41 ] ], [ [ 3, 3 ], [ 7, 7 ] ], [ [ 12, 15 ], [ 19, 19 ], [ 22, 22 ] ], [ [ 16, 18 ], [ 20, 21 ], [ 23, 26 ], [ 29, 29 ], [ 37, 37 ] ], [ [ 34, 34 ], [ 36, 36 ] ] ]
78f66b9a7bb19260e4041f01c6a0b7a34ee839ad
ea12fed4c32e9c7992956419eb3e2bace91f063a
/zombie/code/nebula2/src/gui/nguicanvas_main.cc
cc7ef75bdb30a30ab81aeee27ce9671552b410a6
[]
no_license
ugozapad/TheZombieEngine
832492930df28c28cd349673f79f3609b1fe7190
8e8c3e6225c2ed93e07287356def9fbdeacf3d6a
refs/heads/master
2020-04-30T11:35:36.258363
2011-02-24T14:18:43
2011-02-24T14:18:43
null
0
0
null
null
null
null
UTF-8
C++
false
false
8,759
cc
#include "precompiled/pchngui.h" //------------------------------------------------------------------------------ // nguicanvas_main.cc // (C) 2004 RadonLabs GmbH //------------------------------------------------------------------------------ #include "gui/nguicanvas.h" #include "gfx2/ngfxserver2.h" #include "resource/nresourceserver.h" #include "gui/nguiwindow.h" nNebulaClass(nGuiCanvas, "nguiwidget"); //------------------------------------------------------------------------------ /** */ void nGuiCanvas::AddLabel(const char* text, vector2 pos, vector4 col, const char* font) { int id; for (id = 0; id < this->textarray.Size(); id++); nString txt=text; rectangle widgetRect = this->rect; pos.x = pos.x * (widgetRect.v1.x - widgetRect.v0.x); pos.y = pos.y * (widgetRect.v1.y - widgetRect.v0.y); //nGuiCanvas::Text* thetext = n_new nGuiCanvas::Text(txt, pos, col, id, font); nGuiCanvas::Text thetext(txt, pos, col, id, font); this->textarray.Append(thetext); } //------------------------------------------------------------------------------ /** */ void nGuiCanvas::BeginCurve(vector4 col) { this->inCurve = true; // FIXME: Consistency int id; for (id = 0; id < this->curvearray.Size(); id++); this->activeCurveID = id; this->currentCurveColor = col; } //------------------------------------------------------------------------------ /** */ void nGuiCanvas::EndCurve() { n_assert(inCurve); n_assert(this->activeCurveID >= 0); this->activeCurveID = -1; this->inCurve = false; this->isDirty = true; } //------------------------------------------------------------------------------ /** */ rectangle nGuiCanvas::GetLabelRect(int id) { if (id < textarray.Size() ) { const Text& label = this->textarray.At(id); vector2 pos = label.GetPosition(); nFont2* textfont = (nFont2*) nResourceServer::Instance()->FindResource(label.GetFont().Get(), nResource::Font); nFont2* oldfont = nGfxServer2::Instance()->GetFont(); nGfxServer2::Instance()->SetFont(textfont); vector2 extent = nGfxServer2::Instance()->GetTextExtent(label.GetContent().Get()); nGfxServer2::Instance()->SetFont(oldfont); rectangle labelrect = rectangle(pos, pos+extent); return labelrect; } else { n_printf("textlabel with ID %d not found!", id); return rectangle(vector2(0.0f, 0.0f), vector2(0.0f, 0.0f)); } } //------------------------------------------------------------------------------ /** */ void nGuiCanvas::OnShow() { // empty } //------------------------------------------------------------------------------ /** */ void nGuiCanvas::OnHide() { nGuiWidget::OnHide(); } //------------------------------------------------------------------------------ /** */ bool nGuiCanvas::Render() { if (this->IsShown()) { const vector4& activeWindowColor = ((nGuiWindow*) this->GetOwnerWindow())->GetWindowColor(); rectangle screenSpaceRect = this->GetScreenSpaceRect(); rectangle textRect; vector2 textextent; const int renderFlags = nFont2::Left | nFont2::ExpandTabs; nGuiServer::Instance()->DrawBrush(screenSpaceRect, this->defaultBrush); int i; for (i = 0; i < this->textarray.Size(); i++) { // Set the font for the textlabel nFont2* textfont = (nFont2*) nResourceServer::Instance()->FindResource(this->textarray.At(i).GetFont().Get(), nResource::Font); n_assert(textfont); nGfxServer2::Instance()->SetFont(textfont); // Determine how much screenspace the textlabel needs textextent = nGfxServer2::Instance()->GetTextExtent(this->textarray.At(i).GetContent().Get()); textRect = rectangle( vector2( screenSpaceRect.v0.x + textarray.At(i).GetPosition().x, screenSpaceRect.v0.y + textarray.At(i).GetPosition().y), vector2( screenSpaceRect.v0.x + textarray.At(i).GetPosition().x + textextent.x, screenSpaceRect.v0.y + textarray.At(i).GetPosition().y + textextent.y ) ); // Draw the content of the textlabel vector4 textcolor = textarray.At(i).GetColor(); textcolor.w = activeWindowColor.w; nGuiServer::Instance()->DrawText( textarray.At(i).GetContent().Get(), textcolor, textRect, renderFlags ); } // Do we have to update the line-coordinates? if(this->isDirty) { this->Update(); } // Render the curves nGfxServer2::Instance()->BeginLines(); for(i = 0; i < this->curveDescArray.Size(); i++) { curveDesc cd = this->curveDescArray.At(i); cd.color.w = activeWindowColor.w; nGfxServer2::Instance()->DrawLines2d( vertexPtr + cd.first, cd.num, cd.color); } nGfxServer2::Instance()->EndLines(); return true; } return false; } //------------------------------------------------------------------------------ /** */ void nGuiCanvas::Update() { if (this->isDirty) { const nDisplayMode2& dispMode = nGfxServer2::Instance()->GetDisplayMode(); float dispWidth = (float) dispMode.GetWidth(); float dispHeight = (float) dispMode.GetHeight(); rectangle screenSpaceRect = this->GetScreenSpaceRect(); float topLeftX = screenSpaceRect.v0.x * dispWidth; float topLeftY = screenSpaceRect.v0.y * dispHeight; vector2 scale; scale.x = screenSpaceRect.v1.x - screenSpaceRect.v0.x; scale.y = screenSpaceRect.v1.y - screenSpaceRect.v0.y; int i; int num = this->curvearray.Size(); for(i = 0; i < this->curvearray.Size(); i++) { num += this->curvearray.At(i).GetCurve().Size() + 1; } if ( this->vertexBasePtr != 0 ) { n_delete[] this->vertexBasePtr; this->vertexBasePtr = 0; } this->vertexBasePtr = n_new vector2[ num ]; n_assert(this->vertexBasePtr); this->vertexPtr = this->vertexBasePtr; int numVertices = 0; for (i = 0; i < this->curvearray.Size(); i++) { curveDesc cd; cd.first = numVertices; cd.color = this->curvearray.At(i)->GetColor(); cd.num = this->curvearray.At(i)->GetCurve().Size() + 1; // store pointer to first vertex, number of vertices and color of each curve this->curveDescArray.PushBack(cd); int j; for (j = 0; j < this->curvearray.At(i)->GetCurve().Size(); j++) { line2 theline = this->curvearray.At(i)->GetCurve().At(j); vertexPtr[ numVertices ].x = topLeftX + scale.x * theline.b.x * dispWidth; vertexPtr[ numVertices ].y = topLeftY + scale.y * theline.b.y * dispHeight; numVertices++; if ((this->curvearray.At(i)->GetCurve().Size() -1) == j) { vertexPtr[ numVertices ].x = topLeftX + scale.x * (theline.b.x + theline.m.x) * dispWidth; vertexPtr[ numVertices ].y = topLeftY + scale.y * (theline.b.y + theline.m.y) * dispHeight; numVertices++; } } } this->isDirty=false; vertexPtr = vertexBasePtr; } else { n_printf("Canvas not dirty!"); } } //----------------------------------------------------------------------------- /** This method is called when the rectangle of the canvas is going to change. */ void nGuiCanvas::OnRectChange(const rectangle& newRect) { nGuiWidget::OnRectChange(newRect); this->isDirty = true; } //----------------------------------------------------------------------------- /** This method is called when the canvas gets focus. */ void nGuiCanvas::OnObtainFocus() { nGuiWidget::OnObtainFocus(); this->isDirty = true; }
[ "magarcias@c1fa4281-9647-0410-8f2c-f027dd5e0a91" ]
[ [ [ 1, 275 ] ] ]
a1a075d9d90ccb0c44157e41b0a5b72a8dd1d34f
028d79ad6dd6bb4114891b8f4840ef9f0e9d4a32
/src/drivers/crbaloon.cpp
a2d9b5a04731fa9d95c3f261cec6608493517e65
[]
no_license
neonichu/iMame4All-for-iPad
72f56710d2ed7458594838a5152e50c72c2fb67f
4eb3d4ed2e5ccb5c606fcbcefcb7c5a662ace611
refs/heads/master
2020-04-21T07:26:37.595653
2011-11-26T12:21:56
2011-11-26T12:21:56
2,855,022
4
0
null
null
null
null
UTF-8
C++
false
false
12,714
cpp
#include "../vidhrdw/crbaloon.cpp" /*************************************************************************** Crazy Balloon memory map (preliminary) 0000-2fff ROM 4000-43ff RAM 4800-4bff Video RAM 5000-53ff Color RAM I/O: read: 00 dsw 01 joystick 02 bit 0-3 from chip PC3259 (bit 3 is the sprite/char collision detection) bit 4-7 dsw 03 bit 0 dsw bit 1 high score name reset bit 2 service bit 3 tilt bit 4-7 from chip PC3092; coin inputs & start buttons 06-0a-0e mirror addresses for 02; address lines 2 and 3 go to the PC3256 chip so they probably alter its output, while the dsw bits (4-7) stay the same. write: 01 ? 02 bit 0-3 sprite code bit 4-7 sprite color 03 sprite X pos 04 sprite Y pos 05 music?? to a counter? 06 sound bit 0 IRQ enable/acknowledge bit 1 sound enable bit 2 sound related (to amplifier) bit 3 explosion (to 76477) bit 4 breath (to 76477) bit 5 appear (to 76477) bit 6 sound related (to 555) bit 7 to chip PC3259 07 to chip PC3092 (bits 0-3) 08 to chip PC3092 (bits 0-3) bit 0 seems to be flip screen bit 1 might enable coin input 09 to chip PC3092 (bits 0-3) 0a to chip PC3092 (bits 0-3) 0b to chip PC3092 (bits 0-3) 0c MSK (to chip PC3259) 0d CC (not used) ***************************************************************************/ #include "driver.h" #include "vidhrdw/generic.h" WRITE_HANDLER( crbaloon_spritectrl_w ); WRITE_HANDLER( crbaloon_flipscreen_w ); void crbaloon_vh_convert_color_prom(unsigned char *palette, unsigned short *colortable,const unsigned char *color_prom); void crbaloon_vh_screenrefresh(struct osd_bitmap *bitmap,int full_refresh); int val06,val08,val0a; static void crbaloon_machine_init(void) { /* MIXER A = 0, MIXER C = 1 */ SN76477_mixer_a_w(0, 0); SN76477_mixer_c_w(0, 1); /* ENVELOPE is constant: pin1 = hi, pin 28 = lo */ SN76477_envelope_w(0, 1); /* fake: pulse the enable line to get rid of the constant noise */ SN76477_enable_w(0, 1); SN76477_enable_w(0, 0); } WRITE_HANDLER( crbaloon_06_w ) { val06 = data; interrupt_enable_w(offset,data & 1); /* SOUND STOP high? */ if( data & 0x02 ) { if( data & 0x08 ) { /* enable is connected to EXPLOSION */ SN76477_enable_w(0, 1); } else { SN76477_enable_w(0, 0); } if( data & 0x10 ) { /* BREATH changes slf_res to 10k (middle of two 10k resistors) */ SN76477_set_slf_res(0, RES_K(10)); /* it also puts a tantal capacitor agains GND on the output, but this section of the schematics is not readable. */ } else { SN76477_set_slf_res(0, RES_K(20)); } if( data & 0x20 ) { /* APPEAR is connected to MIXER B */ SN76477_mixer_b_w(0, 1); } else { SN76477_mixer_b_w(0, 4); } /* constant: pin1 = hi, pin 28 = lo */ SN76477_envelope_w(0, 1); } } WRITE_HANDLER( crbaloon_08_w ) { val08 = data; crbaloon_flipscreen_w(offset,data & 1); } WRITE_HANDLER( crbaloon_0a_w ) { val0a = data; } READ_HANDLER( crbaloon_IN2_r ) { extern int crbaloon_collision; if (crbaloon_collision != 0) { return (input_port_2_r(0) & 0xf0) | 0x08; } /* the following is needed for the game to boot up */ if (val06 & 0x80) { //logerror("PC %04x: %02x high\n",cpu_get_pc(),offset); return (input_port_2_r(0) & 0xf0) | 0x07; } else { //logerror("PC %04x: %02x low\n",cpu_get_pc(),offset); return (input_port_2_r(0) & 0xf0) | 0x07; } } READ_HANDLER( crbaloon_IN3_r ) { if (val08 & 0x02) /* enable coin & start input? Wild guess!!! */ return input_port_3_r(0); /* the following is needed for the game to boot up */ if (val0a & 0x01) { //logerror("PC %04x: 03 high\n",cpu_get_pc()); return (input_port_3_r(0) & 0x0f) | 0x00; } else { //logerror("PC %04x: 03 low\n",cpu_get_pc()); return (input_port_3_r(0) & 0x0f) | 0x00; } } READ_HANDLER( crbaloon_IN_r ) { switch (offset & 0x03) { case 0: return input_port_0_r(offset); case 1: return input_port_1_r(offset); case 2: return crbaloon_IN2_r(offset); case 3: return crbaloon_IN3_r(offset); } return 0; } static struct MemoryReadAddress readmem[] = { { 0x0000, 0x2fff, MRA_ROM }, { 0x4000, 0x43ff, MRA_RAM }, { 0x4800, 0x4bff, MRA_RAM }, { 0x5000, 0x53ff, MRA_RAM }, { -1 } /* end of table */ }; static struct MemoryWriteAddress writemem[] = { { 0x0000, 0x2fff, MWA_ROM }, { 0x4000, 0x43ff, MWA_RAM }, { 0x4800, 0x4bff, videoram_w, &videoram, &videoram_size }, { 0x5000, 0x53ff, colorram_w, &colorram }, { -1 } /* end of table */ }; static struct IOReadPort readport[] = { { 0x00, 0x0f, crbaloon_IN_r }, { -1 } /* end of table */ }; static struct IOWritePort writeport[] = { { 0x02, 0x04, crbaloon_spritectrl_w }, { 0x06, 0x06, crbaloon_06_w }, { 0x08, 0x08, crbaloon_08_w }, { 0x0a, 0x0a, crbaloon_0a_w }, { -1 } /* end of table */ }; INPUT_PORTS_START( crbaloon ) PORT_START PORT_DIPNAME( 0x01, 0x01, "Test?" ) PORT_DIPSETTING( 0x01, "I/O Check?" ) PORT_DIPSETTING( 0x00, "RAM Check?" ) PORT_DIPNAME( 0x02, 0x02, DEF_STR( Cabinet ) ) PORT_DIPSETTING( 0x02, DEF_STR( Upright ) ) PORT_DIPSETTING( 0x00, DEF_STR( Cocktail ) ) PORT_DIPNAME( 0x0c, 0x04, DEF_STR( Lives ) ) PORT_DIPSETTING( 0x00, "2" ) PORT_DIPSETTING( 0x04, "3" ) PORT_DIPSETTING( 0x08, "4" ) PORT_DIPSETTING( 0x0c, "5" ) PORT_DIPNAME( 0x10, 0x00, DEF_STR( Bonus_Life ) ) PORT_DIPSETTING( 0x00, "5000" ) PORT_DIPSETTING( 0x10, "10000" ) PORT_DIPNAME( 0xe0, 0x80, DEF_STR( Coinage ) ) PORT_DIPSETTING( 0x20, DEF_STR( 4C_1C ) ) PORT_DIPSETTING( 0x40, DEF_STR( 3C_1C ) ) PORT_DIPSETTING( 0x60, DEF_STR( 2C_1C ) ) PORT_DIPSETTING( 0x80, DEF_STR( 1C_1C ) ) PORT_DIPSETTING( 0xa0, DEF_STR( 1C_2C ) ) PORT_DIPSETTING( 0xc0, DEF_STR( 1C_3C ) ) PORT_DIPSETTING( 0xe0, DEF_STR( 1C_4C ) ) PORT_DIPSETTING( 0x00, "Disable" ) PORT_START PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_UP | IPF_8WAY ) PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN | IPF_8WAY ) PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT | IPF_8WAY ) PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT | IPF_8WAY ) PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_JOYSTICK_UP | IPF_8WAY | IPF_COCKTAIL ) PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN | IPF_8WAY | IPF_COCKTAIL ) PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT | IPF_8WAY | IPF_COCKTAIL ) PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT | IPF_8WAY | IPF_COCKTAIL ) PORT_START PORT_BIT( 0x0f, IP_ACTIVE_HIGH, IPT_UNKNOWN ) /* from chip PC3259 */ PORT_BITX( 0x10, 0x10, IPT_DIPSWITCH_NAME | IPF_CHEAT, "Invulnerability", IP_KEY_NONE, IP_JOY_NONE ) PORT_DIPSETTING( 0x10, DEF_STR( Off ) ) PORT_DIPSETTING( 0x00, DEF_STR( On ) ) PORT_DIPNAME( 0x20, 0x20, DEF_STR( Unknown ) ) PORT_DIPSETTING( 0x20, DEF_STR( Off ) ) PORT_DIPSETTING( 0x00, DEF_STR( On ) ) PORT_DIPNAME( 0x40, 0x40, DEF_STR( Unknown ) ) PORT_DIPSETTING( 0x40, DEF_STR( Off ) ) PORT_DIPSETTING( 0x00, DEF_STR( On ) ) PORT_DIPNAME( 0x80, 0x80, DEF_STR( Unknown ) ) PORT_DIPSETTING( 0x80, DEF_STR( Off ) ) PORT_DIPSETTING( 0x00, DEF_STR( On ) ) PORT_START PORT_DIPNAME( 0x01, 0x01, DEF_STR( Unknown ) ) PORT_DIPSETTING( 0x01, DEF_STR( Off ) ) PORT_DIPSETTING( 0x00, DEF_STR( On ) ) PORT_BITX(0x02, IP_ACTIVE_LOW, IPT_BUTTON1, "High Score Name Reset", IP_KEY_DEFAULT, IP_JOY_DEFAULT ) PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_COIN2 ) /* should be COIN2 */ PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_TILT ) /* the following four bits come from chip PC3092 */ PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_START1 ) PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_START2 ) PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_COIN1 ) PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_UNKNOWN ) INPUT_PORTS_END static struct GfxLayout charlayout = { 8,8, /* 8*8 characters */ 256, /* 256 characters */ 1, /* 1 bit per pixel */ { 0 }, { 0, 1, 2, 3, 4, 5, 6, 7 }, { 7*8, 6*8, 5*8, 4*8, 3*8, 2*8, 1*8, 0*8 }, 8*8 /* every char takes 8 consecutive bytes */ }; static struct GfxLayout spritelayout = { 32,32, /* 32*32 sprites */ 16, /* 16 sprites */ 1, /* 1 bit per pixel */ { 0 }, { 3*32*8+0, 3*32*8+1, 3*32*8+2, 3*32*8+3, 3*32*8+4, 3*32*8+5, 3*32*8+6, 3*32*8+7, 2*32*8+0, 2*32*8+1, 2*32*8+2, 2*32*8+3, 2*32*8+4, 2*32*8+5, 2*32*8+6, 2*32*8+7, 1*32*8+0, 1*32*8+1, 1*32*8+2, 1*32*8+3, 1*32*8+4, 1*32*8+5, 1*32*8+6, 1*32*8+7, 0*32*8+0, 0*32*8+1, 0*32*8+2, 0*32*8+3, 0*32*8+4, 0*32*8+5, 0*32*8+6, 0*32*8+7 }, { 31*8, 30*8, 29*8, 28*8, 27*8, 26*8, 25*8, 24*8, 23*8, 22*8, 21*8, 20*8, 19*8, 18*8, 17*8, 16*8, 15*8, 14*8, 13*8, 12*8, 11*8, 10*8, 9*8, 8*8, 7*8, 6*8, 5*8, 4*8, 3*8, 2*8, 1*8, 0*8 }, 32*4*8 /* every sprite takes 128 consecutive bytes */ }; static struct GfxDecodeInfo gfxdecodeinfo[] = { { REGION_GFX1, 0, &charlayout, 0, 16 }, { REGION_GFX2, 0, &spritelayout, 0, 16 }, { -1 } /* end of array */ }; static struct SN76477interface sn76477_interface = { 1, /* 1 chip */ { 100 }, /* mixing level pin description */ { RES_K( 47) }, /* 4 noise_res */ { RES_K(330) }, /* 5 filter_res */ { CAP_P(470) }, /* 6 filter_cap */ { RES_K(220) }, /* 7 decay_res */ { CAP_U(1.0) }, /* 8 attack_decay_cap */ { RES_K(4.7) }, /* 10 attack_res */ { RES_M( 1) }, /* 11 amplitude_res */ { RES_K(200) }, /* 12 feedback_res */ { 5.0 }, /* 16 vco_voltage */ { CAP_P(470) }, /* 17 vco_cap */ { RES_K(330) }, /* 18 vco_res */ { 5.0 }, /* 19 pitch_voltage */ { RES_K( 20) }, /* 20 slf_res */ { CAP_P(420) }, /* 21 slf_cap */ { CAP_U(1.0) }, /* 23 oneshot_cap */ { RES_K( 47) } /* 24 oneshot_res */ }; static struct MachineDriver machine_driver_crbaloon = { /* basic machine hardware */ { { CPU_Z80, 3072000, /* 3.072 Mhz ????? */ readmem,writemem,readport,writeport, interrupt,1 } }, 60, DEFAULT_60HZ_VBLANK_DURATION, /* frames per second, vblank duration */ 1, /* single CPU, no need for interleaving */ crbaloon_machine_init, /* video hardware */ 32*8, 32*8, { 0*8, 32*8-1, 4*8, 32*8-1 }, gfxdecodeinfo, 16, 16*2, crbaloon_vh_convert_color_prom, VIDEO_TYPE_RASTER|VIDEO_SUPPORTS_DIRTY, 0, generic_vh_start, generic_vh_stop, crbaloon_vh_screenrefresh, /* sound hardware */ 0,0,0,0, { { SOUND_SN76477, &sn76477_interface } } }; /*************************************************************************** Game driver(s) ***************************************************************************/ ROM_START( crbaloon ) ROM_REGION( 0x10000, REGION_CPU1 ) /* 64k for code */ ROM_LOAD( "cl01.bin", 0x0000, 0x0800, 0x9d4eef0b ) ROM_LOAD( "cl02.bin", 0x0800, 0x0800, 0x10f7a6f7 ) ROM_LOAD( "cl03.bin", 0x1000, 0x0800, 0x44ed6030 ) ROM_LOAD( "cl04.bin", 0x1800, 0x0800, 0x62f66f6c ) ROM_LOAD( "cl05.bin", 0x2000, 0x0800, 0xc8f1e2be ) ROM_LOAD( "cl06.bin", 0x2800, 0x0800, 0x7d465691 ) ROM_REGION( 0x0800, REGION_GFX1 | REGIONFLAG_DISPOSE ) ROM_LOAD( "cl07.bin", 0x0000, 0x0800, 0x2c1fbea8 ) ROM_REGION( 0x0800, REGION_GFX2 | REGIONFLAG_DISPOSE ) ROM_LOAD( "cl08.bin", 0x0000, 0x0800, 0xba898659 ) ROM_END ROM_START( crbalon2 ) ROM_REGION( 0x10000, REGION_CPU1 ) /* 64k for code */ ROM_LOAD( "cl01.bin", 0x0000, 0x0800, 0x9d4eef0b ) ROM_LOAD( "crazybal.ep2", 0x0800, 0x0800, 0x87572086 ) ROM_LOAD( "crazybal.ep3", 0x1000, 0x0800, 0x575fe995 ) ROM_LOAD( "cl04.bin", 0x1800, 0x0800, 0x62f66f6c ) ROM_LOAD( "cl05.bin", 0x2000, 0x0800, 0xc8f1e2be ) ROM_LOAD( "crazybal.ep6", 0x2800, 0x0800, 0xfed6ff5c ) ROM_REGION( 0x0800, REGION_GFX1 | REGIONFLAG_DISPOSE ) ROM_LOAD( "cl07.bin", 0x0000, 0x0800, 0x2c1fbea8 ) ROM_REGION( 0x0800, REGION_GFX2 | REGIONFLAG_DISPOSE ) ROM_LOAD( "cl08.bin", 0x0000, 0x0800, 0xba898659 ) ROM_END GAMEX( 1980, crbaloon, 0, crbaloon, crbaloon, 0, ROT90, "Taito Corporation", "Crazy Balloon (set 1)", GAME_IMPERFECT_SOUND ) GAMEX( 1980, crbalon2, crbaloon, crbaloon, crbaloon, 0, ROT90, "Taito Corporation", "Crazy Balloon (set 2)", GAME_IMPERFECT_SOUND )
[ [ [ 1, 441 ] ] ]
89e5526022d43a2407fa8188f46419c162375557
619941b532c6d2987c0f4e92b73549c6c945c7e5
/Source/Nuclex/Support/ThreadPool.cpp
5a38a7ab7b2418653e0de40e7685306be2dcfa96
[]
no_license
dzw/stellarengine
2b70ddefc2827be4f44ec6082201c955788a8a16
2a0a7db2e43c7c3519e79afa56db247f9708bc26
refs/heads/master
2016-09-01T21:12:36.888921
2008-12-12T12:40:37
2008-12-12T12:40:37
36,939,169
0
0
null
null
null
null
UTF-8
C++
false
false
4,630
cpp
//  // // # # ### # # -= Nuclex Library =-  // // ## # # # ## ## ThreadPool.cpp - Thread pool  // // ### # # ###  // // # ### # ### A pool of worker threads for parallel processing  // // # ## # # ## ##  // // # # ### # # R1 (C)2002-2004 Markus Ewald -> License.txt  // //  // #include "Nuclex/Support/ThreadPool.h" #include "Nuclex/Support/Exception.h" using namespace Nuclex; using namespace Nuclex::Support; namespace { void doNothing() {} } // ####################################################################### // // # Nuclex::ThreadPool::ThreadPool() Constructor # // // ####################################################################### // /** Initializes a thread pool and starts the worker threads @param NumThreads Number of worker threads to use */ ThreadPool::ThreadPool(size_t NumThreads) : m_WorkerThreads(NumThreads) { // Create the threads and put them in sleep mode for(WorkerThreadVector::iterator It = m_WorkerThreads.begin(); It != m_WorkerThreads.end(); ++It) { It->second = new WorkerThread(*this); It->second->getSignal().set(false); It->first = shared_ptr<Thread>(new Thread(std::auto_ptr<Thread::Function>(It->second))); } } // ####################################################################### // // # Nuclex::ThreadPool::~ThreadPool() Destructor # // // ####################################################################### // /** Destroy the thread pool, stopping and joining all threads currently belonging to the pool. */ ThreadPool::~ThreadPool() { // Request stop and wake up on all threads for(WorkerThreadVector::iterator It = m_WorkerThreads.begin(); It != m_WorkerThreads.end(); ++It) { It->first->requestStop(); It->second->getSignal().set(); } // Wait for the threads to finish for(WorkerThreadVector::iterator It = m_WorkerThreads.begin(); It != m_WorkerThreads.end(); ++It) It->first->join(); } // ####################################################################### // // # Nuclex::ThreadPool::enqueue() # // // ####################################################################### // /** Puts a new task in the queue to be worked on by a thread @param spTask Function to be queued for execution on a thread */ void ThreadPool::enqueue(std::auto_ptr<Thread::Function> spTask) { // Put the task in the queue { Mutex::ScopedLock TaskLock(m_TasksMutex); // Grab away the auto_ptr's object. It was only used to make it // clear to the user that the object will be deleted after completion m_Tasks.push_back(shared_ptr<Thread::Function>(spTask.release())); } // Look for a free thread to perform this task for(WorkerThreadVector::iterator It = m_WorkerThreads.begin(); It != m_WorkerThreads.end(); ++It) { // If the thread is free, wake it up and end the search if(!It->second->isWorking()) { It->second->getSignal().set(); break; } } } // ####################################################################### // // # Nuclex::ThreadPool::WorkerThread::operator() # // // ####################################################################### // /** The thread's main method. Takes an open task from the queue and executes it, if available, or goes to sleep. */ void ThreadPool::WorkerThread::operator()() { while(!m_bStopRequested) { shared_ptr<Thread::Function> spTask; bool bSleep; // Look for a new taks in the task queue { Mutex::ScopedLock TaskLock(m_Owner.m_TasksMutex); if(m_Owner.m_Tasks.size() > 0) { spTask = m_Owner.m_Tasks.front(); m_Owner.m_Tasks.pop_front(); bSleep = false; } else { bSleep = true; } } // Go to sleep if no tasks are available if(bSleep) { m_bWorking = false; m_Signal.set(false); m_Signal.wait(); } else { spTask->operator()(); } } } // ne kw hm, bt he ws ster tn te wd // ...ad stth he wd nd, fr he ws up agst hs fl chge
[ [ [ 1, 122 ] ] ]
1d29d47676cab17e13dea0aca9232cc24369eaf3
a30b091525dc3f07cd7e12c80b8d168a0ee4f808
/EngineAll/Graphics Devices/OpenGLGraphicsDevice.cpp
94e70ef41059e2b30772ce07ea86b865b9ecc968
[]
no_license
ghsoftco/basecode14
f50dc049b8f2f8d284fece4ee72f9d2f3f59a700
57de2a24c01cec6dc3312cbfe200f2b15d923419
refs/heads/master
2021-01-10T11:18:29.585561
2011-01-23T02:25:21
2011-01-23T02:25:21
47,255,927
0
0
null
null
null
null
UTF-8
C++
false
false
10,895
cpp
/* OpenGLGraphicsDevice.cpp Written by Matthew Fisher Certain parts are borrowed from the NeHe tutorials, http://nehe.gamedev.net/ an OpenGL instance of GraphicsDevice. Contains no new functionality over GraphicsDevice. */ #include "..\\..\\Main.h" #include "OpenGLGraphicsDevice.h" #ifdef USE_OPENGL OpenGLGraphicsDevice::OpenGLGraphicsDevice() { _Type = GD_OpenGL; _DeviceContext = 0; _RenderContext = 0; _Window = 0; _RestoreDevices = false; _BaseInitalized = false; } OpenGLGraphicsDevice::~OpenGLGraphicsDevice() { FreeMemory(); } void OpenGLGraphicsDevice::FreeMemory() { if(_RenderContext) { wglMakeCurrent(NULL,NULL); wglDeleteContext(_RenderContext); _RenderContext = 0; } if(_DeviceContext && _Window) { ReleaseDC(_Window, _DeviceContext); _DeviceContext = 0; } if(_BaseInitalized) { glDeleteLists(_FontBase, 96); _BaseInitalized = false; } } void OpenGLGraphicsDevice::CaptureScreen(WindowManager &WM, Bitmap &B) { int i, i2, Width, Height; RECT WindowCoord; RGBColor Color; Bitmap Temp; HWND Hwnd = WM.CastWindows().GetHWND(); GetClientRect(Hwnd, &WindowCoord); MapWindowPoints(Hwnd, GetDesktopWindow(), (LPPOINT)&WindowCoord, 2); Width = WindowCoord.right - WindowCoord.left; Height = WindowCoord.bottom - WindowCoord.top; //get the screen width and height Temp.Allocate(Width, Height); B.Allocate(Width, Height); //allocate space in the bitmaps glReadBuffer(GL_FRONT); //read from the front buffer glReadPixels(0, 0, Width, Height, GL_RGBA, GL_UNSIGNED_BYTE, &Temp[0][0]); //load the data into the Temp bitmap for(i=0;i<Height;i++) { for(i2=0;i2<Width;i2++) { Color = Temp[Height-1-i][i2]; //get the color, B[i][i2] = RGBColor(Color.b, Color.g, Color.r, Color.a); //flip it from BGRA to RGBA } } } void OpenGLGraphicsDevice::InitializeStateMachine(WindowManager &WM) { //default state machine options glShadeModel(GL_SMOOTH); glClearColor(1.0f, 1.0f, 1.0f, 0.5f); glClearDepth(1.0f); glEnable(GL_DEPTH_TEST); glDepthFunc(GL_LEQUAL); glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST); glMatrixMode(GL_PROJECTION); glLoadIdentity(); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); glViewport(0,0,WM.GetWidth(),WM.GetHeight()); } void OpenGLGraphicsDevice::SetScreenColor(RGBColor _ScreenColor) { glClearColor(_ScreenColor.r / 255.0f, _ScreenColor.g / 255.0f, _ScreenColor.b / 255.0f, 0.5f); } void OpenGLGraphicsDevice::Init3D(WindowObjects &O, const GraphicsDeviceParameters &Parameters) { FreeMemory(); _Parameters = Parameters; if(_Parameters.MainFontName.Length() == 0) { _Parameters.MainFontName = "Georgia"; } unsigned int PixelFormat; _Window = O.GetWindowManager().CastWindows().GetHWND(); _FullScreen = O.GetWindowManager().GetFullScreen(); if(_FullScreen) //if we're full screen we need to change the screen resolution { DEVMODE dmScreenSettings; memset(&dmScreenSettings, 0, sizeof(dmScreenSettings)); dmScreenSettings.dmSize = sizeof(dmScreenSettings); dmScreenSettings.dmPelsWidth = O.GetWindowManager().GetWidth(); dmScreenSettings.dmPelsHeight = O.GetWindowManager().GetHeight(); dmScreenSettings.dmBitsPerPel = 32; dmScreenSettings.dmFields = DM_BITSPERPEL | DM_PELSWIDTH | DM_PELSHEIGHT; LONG Result = ChangeDisplaySettings(&dmScreenSettings,CDS_FULLSCREEN); Assert(Result == DISP_CHANGE_SUCCESSFUL, "Failed to change display resolution"); } static PIXELFORMATDESCRIPTOR pfd= // pfd Tells Windows How We Want Things To Be { sizeof(PIXELFORMATDESCRIPTOR), // Size Of This Pixel Format Descriptor 1, // Version Number PFD_DRAW_TO_WINDOW | // Format Must Support Window PFD_SUPPORT_OPENGL | // Format Must Support OpenGL PFD_DOUBLEBUFFER, // Must Support Double Buffering PFD_TYPE_RGBA, // Request An RGBA Format 32, // Select Our Color Depth 0, 0, 0, 0, 0, 0, // Color Bits Ignored 0, // No Alpha Buffer 0, // Shift Bit Ignored 0, // No Accumulation Buffer 0, 0, 0, 0, // Accumulation Bits Ignored 32, // 16Bit Z-Buffer (Depth Buffer) 0, // No Stencil Buffer 0, // No Auxiliary Buffer PFD_MAIN_PLANE, // Main Drawing Layer 0, // Reserved 0, 0, 0 // Layer Masks Ignored }; _DeviceContext = GetDC(O.GetWindowManager().CastWindows().GetHWND()); PixelFormat = ChoosePixelFormat(_DeviceContext, &pfd); SetPixelFormat(_DeviceContext, PixelFormat, &pfd); _RenderContext = wglCreateContext(_DeviceContext); wglMakeCurrent(_DeviceContext, _RenderContext); // // Create the font for text rendering // HFONT font; // Windows Font ID HFONT oldfont; // Used For Good House Keeping _FontBase = glGenLists(96); // Storage For 96 Characters font = CreateFont( -16, // Height Of Font 0, // Width Of Font 0, // Angle Of Escapement 0, // Orientation Angle FW_BOLD, // Font Weight FALSE, // Italic FALSE, // Underline FALSE, // Strikeout ANSI_CHARSET, // Character Set Identifier OUT_TT_PRECIS, // Output Precision CLIP_DEFAULT_PRECIS, // Clipping Precision ANTIALIASED_QUALITY, // Output Quality FF_DONTCARE|DEFAULT_PITCH, // Family And Pitch _Parameters.MainFontName.CString()); // Font Name _FontScreenWidth = O.GetWindowManager().GetWidth(); _FontScreenHeight = O.GetWindowManager().GetHeight(); oldfont = (HFONT)SelectObject(_DeviceContext, font); // Selects The Font We Want wglUseFontBitmaps(_DeviceContext, 32, 96, _FontBase); // Builds 96 Characters Starting At Character 32 _BaseInitalized = true; SelectObject(_DeviceContext, oldfont); // Selects The Font We Want DeleteObject(font); // Delete The Font InitializeStateMachine(O.GetWindowManager()); } void OpenGLGraphicsDevice::StartRender(WindowObjects &O) { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); } void OpenGLGraphicsDevice::FinishRender(WindowObjects &O, AppInterface &App) { SwapBuffers(_DeviceContext); } void OpenGLGraphicsDevice::RestoreSystem() { _SystemActive = true; } void OpenGLGraphicsDevice::ReSize(WindowObjects &O, AppInterface &App) { glViewport(0,0,O.GetWindowManager().GetWidth(),O.GetWindowManager().GetHeight()); _FontScreenWidth = O.GetWindowManager().GetWidth(); _FontScreenHeight = O.GetWindowManager().GetHeight(); _RestoreDevices = true; } void OpenGLGraphicsDevice::ReSizeFullScreen(WindowObjects &O, AppInterface &App) { if(!O.GetWindowManager().GetFullScreen()) ChangeDisplaySettings(NULL,0); Init3D(O, _Parameters); _RestoreDevices = true; } void OpenGLGraphicsDevice::DrawStringFloat(const String &Text, float x, float y, RGBColor c) { glMatrixMode(GL_MODELVIEW); //see NeHe for a full description glLoadIdentity(); glTranslatef(0.0f, 0.0f, -1.0f); glColor3f(c.r / 255.0f,c.g / 255.0f,c.b / 255.0f); glRasterPos2f( float(Math::LinearMap(0.0f, float(_FontScreenWidth), -1.0f, 1.0f, x)), float(Math::LinearMap(0.0f, float(_FontScreenHeight), 1.0f, -1.0f, y + 20.0f))); glPushAttrib(GL_LIST_BIT); glListBase(_FontBase - 32); glCallLists(int(Text.Length()), GL_UNSIGNED_BYTE, Text.CString()); glPopAttrib(); glLoadIdentity(); glLoadMatrixf(&(_SavedMatrix[0][0])); } void OpenGLGraphicsDevice::LoadMatrix(MatrixController &MC) { Matrix4 Total = MC.TotalMatrix(); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); glLoadMatrixf(&(Total[0][0])); _SavedMatrix = Total; } void OpenGLGraphicsDevice::SetWireframe() { glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); } void OpenGLGraphicsDevice::DisableWireframe() { glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); } void OpenGLGraphicsDevice::ToggleWireframe() { SignalError("Not implemented"); } void OpenGLGraphicsDevice::ClearTexture(UINT Index) { } void OpenGLGraphicsDevice::Render(const Mesh &M) { glBegin(GL_TRIANGLES); UINT VertexCount = M.VertexCount(), IndexCount = M.IndexCount(); const MeshVertex *Vertices = M.Vertices(); const DWORD *Indices = M.Indices(); for(UINT IndexIndex = 0; IndexIndex < IndexCount; IndexIndex++) { const MeshVertex &Vtx = Vertices[Indices[IndexIndex]]; glColor3f(Vtx.Color.r / 255.0f, Vtx.Color.g / 255.0f, Vtx.Color.b / 255.0f); glTexCoord2f(Vtx.TexCoord.x, Vtx.TexCoord.y); glVertex3f(Vtx.Pos.x, Vtx.Pos.y, Vtx.Pos.z); } glEnd(); } BaseTexture* OpenGLGraphicsDevice::CreateTexture() { #ifdef USE_OPENGL_TEXTURES BaseTexture *Tex = new OpenGLTexture; //return an OpenGLTexture return Tex; #else return NULL; #endif } void OpenGLGraphicsDevice::SetZState(ZState NewState) { if(NewState == ZStateAlways) { glDepthFunc(GL_ALWAYS); } else if(NewState == ZStateLessEqual) { glDepthFunc(GL_LEQUAL); } } void OpenGLGraphicsDevice::RenderLineStrip(const Mesh &M) { //not implemented yet } #endif
[ "zhaodongmpii@7e7f00ea-7cf8-66b5-cf80-f378872134d2" ]
[ [ [ 1, 317 ] ] ]
c4352ec678313262d64aa0f6f5e28d074ac1cec3
c1a2953285f2a6ac7d903059b7ea6480a7e2228e
/deitel/ch19/Fig20_05_07/MergeSort.cpp
6c213969d270d7b27ee83274e201b4fca59acfef
[]
no_license
tecmilenio/computacion2
728ac47299c1a4066b6140cebc9668bf1121053a
a1387e0f7f11c767574fcba608d94e5d61b7f36c
refs/heads/master
2016-09-06T19:17:29.842053
2008-09-28T04:27:56
2008-09-28T04:27:56
50,540
4
3
null
null
null
null
UTF-8
C++
false
false
6,027
cpp
// Fig 20.06: MergeSort.cpp // Class MergeSort member-function definition. #include <iostream> using std::cout; using std::endl; #include <vector> using std::vector; #include <cstdlib> // prototypes for functions srand and rand using std::rand; using std::srand; #include <ctime> // prototype for function time using std::time; #include "MergeSort.h" // class MergeSort definition // constructor fill vector with random integers MergeSort::MergeSort( int vectorSize ) { size = ( vectorSize > 0 ? vectorSize : 10 ); // validate vectorSize srand( time( 0 ) ); // seed random number generator using current time // fill vector with random ints in range 10-99 for ( int i = 0; i < size; i++ ) data.push_back( 10 + rand() % 90 ); } // end MergeSort constructor // split vector, sort subvectors and merge subvectors into sorted vector void MergeSort::sort() { sortSubVector( 0, size - 1 ); // recursively sort entire vector } // end function sort // recursive function to sort subvectors void MergeSort::sortSubVector( int low, int high ) { // test base case; size of vector equals 1 if ( ( high - low ) >= 1 ) // if not base case { int middle1 = ( low + high ) / 2; // calculate middle of vector int middle2 = middle1 + 1; // calculate next element over // output split step cout << "split: "; displaySubVector( low, high ); cout << endl << " "; displaySubVector( low, middle1 ); cout << endl << " "; displaySubVector( middle2, high ); cout << endl << endl; // split vector in half; sort each half (recursive calls) sortSubVector( low, middle1 ); // first half of vector sortSubVector( middle2, high ); // second half of vector // merge two sorted vectors after split calls return merge( low, middle1, middle2, high ); } // end if } // end function sortSubVector // merge two sorted subvectors into one sorted subvector void MergeSort::merge( int left, int middle1, int middle2, int right ) { int leftIndex = left; // index into left subvector int rightIndex = middle2; // index into right subvector int combinedIndex = left; // index into temporary working vector vector< int > combined( size ); // working vector // output two subvectors before merging cout << "merge: "; displaySubVector( left, middle1 ); cout << endl << " "; displaySubVector( middle2, right ); cout << endl; // merge vectors until reaching end of either while ( leftIndex <= middle1 && rightIndex <= right ) { // place smaller of two current elements into result // and move to next space in vector if ( data[ leftIndex ] <= data[ rightIndex ] ) combined[ combinedIndex++ ] = data[ leftIndex++ ]; else combined[ combinedIndex++ ] = data[ rightIndex++ ]; } // end while if ( leftIndex == middle2 ) // if at end of left vector { while ( rightIndex <= right ) // copy in rest of right vector combined[ combinedIndex++ ] = data[ rightIndex++ ]; } // end if else // at end of right vector { while ( leftIndex <= middle1 ) // copy in rest of left vector combined[ combinedIndex++ ] = data[ leftIndex++ ]; } // end else // copy values back into original vector for ( int i = left; i <= right; i++ ) data[ i ] = combined[ i ]; // output merged vector cout << " "; displaySubVector( left, right ); cout << endl << endl; } // end function merge // display elements in vector void MergeSort::displayElements() const { displaySubVector( 0, size - 1 ); } // end function displayElements // display certain values in vector void MergeSort::displaySubVector( int low, int high ) const { // output spaces for alignment for ( int i = 0; i < low; i++ ) cout << " "; // output elements left in vector for ( int i = low; i <= high; i++ ) cout << " " << data[ i ]; } // end function displaySubVector /************************************************************************** * (C) Copyright 1992-2008 by Deitel & Associates, Inc. and * * Pearson Education, Inc. All Rights Reserved. * * * * DISCLAIMER: The authors and publisher of this book have used their * * best efforts in preparing the book. These efforts include the * * development, research, and testing of the theories and programs * * to determine their effectiveness. The authors and publisher make * * no warranty of any kind, expressed or implied, with regard to these * * programs or to the documentation contained in these books. The authors * * and publisher shall not be liable in any event for incidental or * * consequential damages in connection with, or arising out of, the * * furnishing, performance, or use of these programs. * *************************************************************************/
[ [ [ 1, 143 ] ] ]
e8acabb03b230f670c4af37844f86164cb5c1881
2d4221efb0beb3d28118d065261791d431f4518a
/OIDE源代码/OLIDE/Controls/scintilla/SyntaxCtrl.cpp
c2c847f62b76e213990c137d20fab381fe41c79d
[]
no_license
ophyos/olanguage
3ea9304da44f54110297a5abe31b051a13330db3
38d89352e48c2e687fd9410ffc59636f2431f006
refs/heads/master
2021-01-10T05:54:10.604301
2010-03-23T11:38:51
2010-03-23T11:38:51
48,682,489
1
0
null
null
null
null
GB18030
C++
false
false
2,829
cpp
// SyntaxCtrl.cpp : 实现文件 // #include "stdafx.h" #include "SyntaxCtrl.h" // CSyntaxCtrl IMPLEMENT_DYNAMIC(CSyntaxCtrl, CScintillaCtrl) CSyntaxCtrl::CSyntaxCtrl() { } CSyntaxCtrl::~CSyntaxCtrl() { } BEGIN_MESSAGE_MAP(CSyntaxCtrl, CScintillaCtrl) ON_WM_RBUTTONDOWN() ON_WM_RBUTTONUP() ON_WM_CHAR() ON_WM_KEYDOWN() ON_WM_KEYUP() ON_WM_LBUTTONDOWN() ON_WM_LBUTTONUP() ON_WM_HELPINFO() END_MESSAGE_MAP() // CSyntaxCtrl 消息处理程序 void CSyntaxCtrl::OnRButtonDown(UINT nFlags, CPoint point) { GetParent()->SendMessage(WM_RBUTTONDOWN,(WPARAM)nFlags,MAKELPARAM(point.x,point.y)); } void CSyntaxCtrl::OnRButtonUp(UINT nFlags, CPoint point) { GetParent()->SendMessage(WM_RBUTTONUP,(WPARAM)nFlags,MAKELPARAM(point.x,point.y)); } void CSyntaxCtrl::OnChar(UINT nChar, UINT nRepCnt, UINT nFlags) { // TODO: 在此添加消息处理程序代码和/或调用默认值 switch(nChar) { case VK_RETURN: //如果是回车 case VK_TAB: //TAB键 { //如果是SHIFT if(GetKeyState(VK_SHIFT)&0x8000) break; GetParent()->SendMessage(WM_CHAR,(WPARAM)nChar,MAKELPARAM(nRepCnt,nFlags)); return; } } CScintillaCtrl::OnChar(nChar, nRepCnt, nFlags); //Back键 if(nChar == VK_BACK) { GetParent()->SendMessage(WM_CHAR,(WPARAM)nChar,MAKELPARAM(nRepCnt,nFlags)); } } void CSyntaxCtrl::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags) { // TODO: 在此添加消息处理程序代码和/或调用默认值 switch(nChar) { case VK_RETURN: //如果是回车 case VK_TAB: //TAB键 return; } CScintillaCtrl::OnKeyDown(nChar, nRepCnt, nFlags); } void CSyntaxCtrl::OnKeyUp(UINT nChar, UINT nRepCnt, UINT nFlags) { // TODO: 在此添加消息处理程序代码和/或调用默认值 switch(nChar) { case VK_RETURN: //如果是回车 case VK_TAB: //TAB键 return; } CScintillaCtrl::OnKeyUp(nChar, nRepCnt, nFlags); } void CSyntaxCtrl::OnLButtonDown(UINT nFlags, CPoint point) { // TODO: 在此添加消息处理程序代码和/或调用默认值 GetParent()->SendMessage(WM_LBUTTONDOWN,(WPARAM)nFlags,MAKELPARAM(point.x,point.y)); CScintillaCtrl::OnLButtonDown(nFlags, point); } void CSyntaxCtrl::OnLButtonUp(UINT nFlags, CPoint point) { // TODO: 在此添加消息处理程序代码和/或调用默认值 GetParent()->SendMessage(WM_LBUTTONUP,(WPARAM)nFlags,MAKELPARAM(point.x,point.y)); CScintillaCtrl::OnLButtonUp(nFlags, point); } BOOL CSyntaxCtrl::OnHelpInfo(HELPINFO* pHelpInfo) { // TODO: 在此添加消息处理程序代码和/或调用默认值 return CScintillaCtrl::OnHelpInfo(pHelpInfo); } int CSyntaxCtrl::GetCurrentLine() { int line = LineFromPosition (GetCurrentPos()); return line; }
[ [ [ 1, 130 ] ] ]
7cf9c479ed33babcc7986e6fe2f3cd969b97eefa
5fb9b06a4bf002fc851502717a020362b7d9d042
/developertools/GumpEditor/entity/GumpPaperdoll.h
fb30448e6772b0679cc90467eeb636feae47791e
[]
no_license
bravesoftdz/iris-svn
8f30b28773cf55ecf8951b982370854536d78870
c03438fcf59d9c788f6cb66b6cb9cf7235fbcbd4
refs/heads/master
2021-12-05T18:32:54.525624
2006-08-21T13:10:54
2006-08-21T13:10:54
null
0
0
null
null
null
null
UTF-8
C++
false
false
322
h
#pragma once #include "GumpPicture.h" class CGumpPaperdoll : public CGumpPicture { public: CGumpPaperdoll(CGumpPtr pGump); ~CGumpPaperdoll(void); static CGumpEntity* CreateFromNode( XML::Node* node ); // Overrides virtual CDiagramEntity* Clone(); //virtual void Draw( CDC* dc, CRect rect ); };
[ "sience@a725d9c3-d2eb-0310-b856-fa980ef11a19" ]
[ [ [ 1, 16 ] ] ]
8b5367960d5cad932bd263d18a325ad414380037
6e4f9952ef7a3a47330a707aa993247afde65597
/PROJECTS_ROOT/WireChanger/glfrac/frac_test.cpp
62e97df6f209523c4b6d5e55c045ad10fd3823e8
[]
no_license
meiercn/wiredplane-wintools
b35422570e2c4b486c3aa6e73200ea7035e9b232
134db644e4271079d631776cffcedc51b5456442
refs/heads/master
2021-01-19T07:50:42.622687
2009-07-07T03:34:11
2009-07-07T03:34:11
34,017,037
2
1
null
null
null
null
UTF-8
C++
false
false
1,779
cpp
#include "fractal" #include <fstream> using namespace fractals; template<class _Ty> class myfractal : public mandelbrot<_Ty> { public: myfractal(unsigned short _W, unsigned short _H) : mandelbrot<_Ty>(_W, _H) {} protected: virtual void color(unsigned _N, unsigned char& _R, unsigned char& _G, unsigned char& _B) {_R = _N, _G = _N * 2, _B = _N * 3; } }; int main() { { // myfractal myfractal<double> m(400, 400); m.render(-1.250, 0.048, 0.005, 0.005); std::ofstream os0("myfractal.tga", std::ios_base::binary); os0 << m; } { // mandelbrot set mandelbrot<double> m0(400, 400); mandelbrot<double> m1 = m0; // test copy constructor mandelbrot<double> m(200, 200); m = m1; // test assignment operator m.render(-1.5, 1.5, 3, 3); // 400x400 std::ofstream os("mandelbrot.tga", std::ios_base::binary); os << m; } { // sea horse valley mandelbrot<double> m(400, 400); m.render(-1.250, 0.048, 0.005, 0.005); std::ofstream os("seahorsevalley.tga", std::ios_base::binary); os << m; } { // san marco fractal julia<float> j0(400, 400); julia<float> j1 = j0; // test copy constructor julia<float> j(200, 200); j = j1; // test assignment operator j.c = std::complex<float>(-3.0f / 4.0f, 0); j.render(-1.5, 1.5, 3, 3); // 400x400 std::ofstream os("sanmarco.tga", std::ios_base::binary); os << j; } { // cactus fractal cactus<float> c0(400, 400); cactus<float> c1 = c0; // test copy constructor cactus<float> c(200, 200); c = c1; // test assignment operator c.render(-1.5, 1.5, 3, 3); // 400x400 std::ofstream os("cactus.tga", std::ios_base::binary); os << c; } }
[ "wplabs@3fb49600-69e0-11de-a8c1-9da277d31688" ]
[ [ [ 1, 77 ] ] ]
9444c9dcd4d115792ab0e6c0fd3b4ac25f004c35
d425cf21f2066a0cce2d6e804bf3efbf6dd00c00
/Editor/Editor Taskbar Creation.cpp
029947420152322d39e51b318405459483e857e2
[]
no_license
infernuslord/ja2
d5ac783931044e9b9311fc61629eb671f376d064
91f88d470e48e60ebfdb584c23cc9814f620ccee
refs/heads/master
2021-01-02T23:07:58.941216
2011-10-18T09:22:53
2011-10-18T09:22:53
null
0
0
null
null
null
null
UTF-8
C++
false
false
58,801
cpp
#ifdef PRECOMPILEDHEADERS #include "Editor All.h" #else #include "builddefines.h" #endif #ifdef JA2EDITOR #ifndef PRECOMPILEDHEADERS //sgp #include "Button System.h" #include "Font Control.h" #include "debug.h" //editor #include "EditorDefines.h" #include "Editor Callback Prototypes.h" #include "Editor Taskbar Utils.h" #include "EditorMercs.h" #include "EditorMapInfo.h" //tactical #include "Soldier Create.h" #include "overhead types.h" #include "local.h" #include "Text.h" #endif //Category tabs of the editor buttons void InitEditorTerrainToolbar(); void InitEditorBuildingsToolbar(); void InitEditorItemsToolbar(); void InitEditorMercsToolbar(); void InitEditorMapInfoToolbar(); void InitEditorOptionsToolbar(); void InitEditorItemStatsButtons(); void InitEditorItemStatsButtons() { iEditorButton[ ITEMSTATS_PANEL ] = CreateTextButton( 0, 0, 0, 0, BUTTON_USE_DEFAULT, iScreenWidthOffset + 480, 2 * iScreenHeightOffset + 361, 160, 99, BUTTON_TOGGLE, MSYS_PRIORITY_NORMAL, BUTTON_NO_CALLBACK, BUTTON_NO_CALLBACK ); SpecifyDisabledButtonStyle( iEditorButton[ ITEMSTATS_PANEL ], DISABLED_STYLE_NONE ); DisableButton( iEditorButton[ ITEMSTATS_PANEL ] ); iEditorButton[ ITEMSTATS_HIDDEN_BTN ] = CreateCheckBoxButton( iScreenWidthOffset + 485, 2 * iScreenHeightOffset + 365, "EDITOR//SmCheckbox.sti", MSYS_PRIORITY_NORMAL, ItemStatsToggleHideCallback ); iEditorButton[ ITEMSTATS_DELETE_BTN ] = CreateTextButton( iEditorItemStatsButtonsText[0], FONT10ARIAL, FONT_RED, FONT_BLACK, BUTTON_USE_DEFAULT, iScreenWidthOffset + 600, 2 * iScreenHeightOffset + 441, 36, 16, BUTTON_NO_TOGGLE, MSYS_PRIORITY_NORMAL+1, DEFAULT_MOVE_CALLBACK, ItemStatsDeleteCallback ); } void InitEditorMercsToolbar() { CHAR16 TempString[30]; // STR16 FaceDirs[8] = {L"north",L"northeast",L"east",L"southeast",L"south",L"southwest",L"west",L"northwest"}; INT32 x; iEditorButton[ MERCS_PLAYERTOGGLE ] = CreateCheckBoxButton( iScreenWidthOffset + 4, 2 * iScreenHeightOffset + 362, "EDITOR//SmCheckbox.sti", MSYS_PRIORITY_NORMAL, MercsTogglePlayers ); if( gfShowPlayers ) ClickEditorButton( MERCS_PLAYERTOGGLE ); SetButtonFastHelpText( iEditorButton[ MERCS_PLAYERTOGGLE ], iEditorMercsToolbarText[0]); DisableButton( iEditorButton[ MERCS_PLAYERTOGGLE ] ); iEditorButton[ MERCS_ENEMYTOGGLE ] = CreateCheckBoxButton( iScreenWidthOffset + 4, 2 * iScreenHeightOffset + 382, "EDITOR//SmCheckbox.sti", MSYS_PRIORITY_NORMAL, MercsToggleEnemies ); if( gfShowEnemies ) ClickEditorButton( MERCS_ENEMYTOGGLE ); SetButtonFastHelpText( iEditorButton[ MERCS_ENEMYTOGGLE ], iEditorMercsToolbarText[1]); iEditorButton[ MERCS_CREATURETOGGLE ] = CreateCheckBoxButton( iScreenWidthOffset + 4, 2 * iScreenHeightOffset + 402, "EDITOR//SmCheckbox.sti", MSYS_PRIORITY_NORMAL, MercsToggleCreatures ); if( gfShowCreatures ) ClickEditorButton( MERCS_CREATURETOGGLE ); SetButtonFastHelpText( iEditorButton[ MERCS_CREATURETOGGLE ], iEditorMercsToolbarText[2]); iEditorButton[ MERCS_REBELTOGGLE ] = CreateCheckBoxButton( iScreenWidthOffset + 4, 2 * iScreenHeightOffset + 422, "EDITOR//SmCheckbox.sti", MSYS_PRIORITY_NORMAL, MercsToggleRebels ); if( gfShowRebels ) ClickEditorButton( MERCS_REBELTOGGLE ); SetButtonFastHelpText( iEditorButton[ MERCS_REBELTOGGLE ], iEditorMercsToolbarText[3]); iEditorButton[ MERCS_CIVILIANTOGGLE ] = CreateCheckBoxButton( iScreenWidthOffset + 4, 2 * iScreenHeightOffset + 442, "EDITOR//SmCheckbox.sti", MSYS_PRIORITY_NORMAL, MercsToggleCivilians ); if( gfShowCivilians ) ClickEditorButton( MERCS_CIVILIANTOGGLE ); SetButtonFastHelpText( iEditorButton[ MERCS_CIVILIANTOGGLE ], iEditorMercsToolbarText[4]); iEditorButton[MERCS_PLAYER] = CreateTextButton( iEditorMercsToolbarText[5],(UINT16)BLOCKFONT, 165, FONT_BLACK, BUTTON_USE_DEFAULT, iScreenWidthOffset + 20, 2 * iScreenHeightOffset + 362, 78, 19, BUTTON_TOGGLE, MSYS_PRIORITY_NORMAL, DEFAULT_MOVE_CALLBACK, MercsPlayerTeamCallback ); SpecifyButtonDownTextColors( iEditorButton[MERCS_PLAYER], FONT_YELLOW, FONT_BLACK ); DisableButton( iEditorButton[MERCS_PLAYER] ); iEditorButton[MERCS_ENEMY] = CreateTextButton( iEditorMercsToolbarText[6],(UINT16)BLOCKFONT, 165, FONT_BLACK, BUTTON_USE_DEFAULT, iScreenWidthOffset + 20, 2 * iScreenHeightOffset + 382, 78, 19, BUTTON_TOGGLE, MSYS_PRIORITY_NORMAL, DEFAULT_MOVE_CALLBACK, MercsEnemyTeamCallback ); SpecifyButtonDownTextColors( iEditorButton[MERCS_ENEMY], FONT_YELLOW, FONT_BLACK ); iEditorButton[MERCS_CREATURE] = CreateTextButton( iEditorMercsToolbarText[7],(UINT16)BLOCKFONT, 165, FONT_BLACK, BUTTON_USE_DEFAULT, iScreenWidthOffset + 20, 2 * iScreenHeightOffset + 402, 78, 19, BUTTON_TOGGLE, MSYS_PRIORITY_NORMAL, DEFAULT_MOVE_CALLBACK, MercsCreatureTeamCallback ); SpecifyButtonDownTextColors( iEditorButton[MERCS_CREATURE], FONT_YELLOW, FONT_BLACK ); iEditorButton[MERCS_REBEL] = CreateTextButton( iEditorMercsToolbarText[8],(UINT16)BLOCKFONT, 165, FONT_BLACK, BUTTON_USE_DEFAULT, iScreenWidthOffset + 20, 2 * iScreenHeightOffset + 422, 78, 19, BUTTON_TOGGLE, MSYS_PRIORITY_NORMAL, DEFAULT_MOVE_CALLBACK, MercsRebelTeamCallback ); SpecifyButtonDownTextColors( iEditorButton[MERCS_REBEL], FONT_YELLOW, FONT_BLACK ); iEditorButton[MERCS_CIVILIAN] = CreateTextButton( iEditorMercsToolbarText[9],(UINT16)BLOCKFONT, 165, FONT_BLACK, BUTTON_USE_DEFAULT, iScreenWidthOffset + 20, 2 * iScreenHeightOffset + 442, 78, 19, BUTTON_TOGGLE, MSYS_PRIORITY_NORMAL, DEFAULT_MOVE_CALLBACK, MercsCivilianTeamCallback ); SpecifyButtonDownTextColors( iEditorButton[MERCS_CIVILIAN], FONT_YELLOW, FONT_BLACK ); iEditorButton[ MERCS_1 ] = CreateTextButton( iEditorMercsToolbarText[10], SMALLCOMPFONT, FONT_ORANGE, 60, BUTTON_USE_DEFAULT, iScreenWidthOffset + 100, 2 * iScreenHeightOffset + 362, 68, 20, BUTTON_TOGGLE, MSYS_PRIORITY_NORMAL, BUTTON_NO_CALLBACK, BUTTON_NO_CALLBACK ); DisableButton( iEditorButton[ MERCS_1 ] ); SpecifyDisabledButtonStyle( iEditorButton[ MERCS_1 ], DISABLED_STYLE_NONE ); SpecifyButtonTextOffsets( iEditorButton[ MERCS_1 ], 20, 4, FALSE ); SpecifyButtonTextWrappedWidth( iEditorButton[ MERCS_1 ], 46 ); iEditorButton[ MERCS_DETAILEDCHECKBOX ] = CreateCheckBoxButton( iScreenWidthOffset + 103, 2 * iScreenHeightOffset + 365, "EDITOR//checkbox.sti", MSYS_PRIORITY_NORMAL, MercsDetailedPlacementCallback ); iEditorButton[ MERCS_GENERAL ] = CreateEasyToggleButton( iScreenWidthOffset + 100, 2 * iScreenHeightOffset + 382, "EDITOR//MercGeneral.sti", MercsGeneralModeCallback ); SetButtonFastHelpText( iEditorButton[ MERCS_GENERAL ], iEditorMercsToolbarText[11]); iEditorButton[ MERCS_APPEARANCE ] = CreateEasyToggleButton( iScreenWidthOffset + 134, 2 * iScreenHeightOffset + 382, "EDITOR//MercAppearance.sti", MercsAppearanceModeCallback ); SetButtonFastHelpText( iEditorButton[ MERCS_APPEARANCE ], iEditorMercsToolbarText[12]); iEditorButton[ MERCS_ATTRIBUTES ] = CreateEasyToggleButton( iScreenWidthOffset + 100, 2 * iScreenHeightOffset + 408, "EDITOR//MercAttributes.sti", MercsAttributesModeCallback ); SetButtonFastHelpText( iEditorButton[ MERCS_ATTRIBUTES ], iEditorMercsToolbarText[13]); iEditorButton[ MERCS_INVENTORY ] = CreateEasyToggleButton( iScreenWidthOffset + 134, 2 * iScreenHeightOffset + 408, "EDITOR//MercInventory.sti", MercsInventoryModeCallback ); SetButtonFastHelpText( iEditorButton[ MERCS_INVENTORY ], iEditorMercsToolbarText[14]); iEditorButton[ MERCS_PROFILE ] = CreateEasyToggleButton( iScreenWidthOffset + 100, 2 * iScreenHeightOffset + 434, "EDITOR//MercProfile.sti", MercsProfileModeCallback ); SetButtonFastHelpText( iEditorButton[ MERCS_PROFILE ], iEditorMercsToolbarText[15]); iEditorButton[ MERCS_SCHEDULE ] = CreateEasyToggleButton( iScreenWidthOffset + 134, 2 * iScreenHeightOffset + 434, "EDITOR//MercSchedule.sti", MercsScheduleModeCallback ); SetButtonFastHelpText( iEditorButton[ MERCS_SCHEDULE ], iEditorMercsToolbarText[16]); //Workaround for identical buttons. MSYS_SetBtnUserData( iEditorButton[ MERCS_SCHEDULE ], 3, 0xffffffff ); iEditorButton[ MERCS_GLOWSCHEDULE ] = CreateEasyToggleButton( iScreenWidthOffset + 134, 2 * iScreenHeightOffset + 434, "EDITOR//MercGlowSchedule.sti", MercsScheduleModeCallback ); SetButtonFastHelpText( iEditorButton[ MERCS_GLOWSCHEDULE ], iEditorMercsToolbarText[17]); HideEditorButton( MERCS_GLOWSCHEDULE ); iEditorButton[ MERCS_DELETE ] = CreateTextButton( iEditorMercsToolbarText[18], (UINT16)SMALLCOMPFONT, FONT_DKBLUE, FONT_BLACK, BUTTON_USE_DEFAULT, iScreenWidthOffset + 600, 2 * iScreenHeightOffset + 362, 40, 20, BUTTON_NO_TOGGLE, MSYS_PRIORITY_NORMAL, DEFAULT_MOVE_CALLBACK, MercsDeleteCallback ); SetButtonFastHelpText( iEditorButton[ MERCS_DELETE ], iEditorMercsToolbarText[19]); iEditorButton[ MERCS_NEXT ] = CreateTextButton( iEditorMercsToolbarText[20], (UINT16)SMALLCOMPFONT, FONT_DKBLUE, FONT_BLACK, BUTTON_USE_DEFAULT, iScreenWidthOffset + 600, 2 * iScreenHeightOffset + 382, 40, 20, BUTTON_NO_TOGGLE, MSYS_PRIORITY_NORMAL, DEFAULT_MOVE_CALLBACK, MercsNextCallback ); SetButtonFastHelpText( iEditorButton[ MERCS_NEXT ], iEditorMercsToolbarText[21]); //Priority Existance iEditorButton[ MERCS_PRIORITYEXISTANCE_CHECKBOX ] = CreateCheckBoxButton( iScreenWidthOffset + 170, 2 * iScreenHeightOffset + 365, "EDITOR//checkbox.sti", MSYS_PRIORITY_NORMAL, MercsPriorityExistanceCallback ); SetButtonFastHelpText( iEditorButton[ MERCS_PRIORITYEXISTANCE_CHECKBOX ], iEditorMercsToolbarText[22] ); //If merc has keys iEditorButton[ MERCS_HASKEYS_CHECKBOX ] = CreateCheckBoxButton( iScreenWidthOffset + 170, 2 * iScreenHeightOffset + 390, "EDITOR//checkbox.sti", MSYS_PRIORITY_NORMAL, MercsHasKeysCallback ); SetButtonFastHelpText( iEditorButton[ MERCS_HASKEYS_CHECKBOX ], iEditorMercsToolbarText[23] ); //Orders iEditorButton[ MERCS_ORDERS_STATIONARY ] = CreateTextButton( iEditorMercsToolbarText[24], (UINT16)SMALLCOMPFONT, FONT_GRAY2, FONT_BLACK, BUTTON_USE_DEFAULT, iScreenWidthOffset + 200, 2 * iScreenHeightOffset + 368, 70, 12, BUTTON_TOGGLE, MSYS_PRIORITY_NORMAL, DEFAULT_MOVE_CALLBACK, MercsSetOrdersCallback ); iEditorButton[ MERCS_ORDERS_ONGUARD] = CreateTextButton( iEditorMercsToolbarText[25], (UINT16)SMALLCOMPFONT, FONT_GRAY2, FONT_BLACK, BUTTON_USE_DEFAULT, iScreenWidthOffset + 200, 2 * iScreenHeightOffset + 380, 70, 12, BUTTON_TOGGLE, MSYS_PRIORITY_NORMAL, DEFAULT_MOVE_CALLBACK, MercsSetOrdersCallback ); iEditorButton[ MERCS_ORDERS_ONCALL ] = CreateTextButton( iEditorMercsToolbarText[26], (UINT16)SMALLCOMPFONT, FONT_GRAY2, FONT_BLACK, BUTTON_USE_DEFAULT, iScreenWidthOffset + 200, 2 * iScreenHeightOffset + 392, 70, 12, BUTTON_TOGGLE, MSYS_PRIORITY_NORMAL, DEFAULT_MOVE_CALLBACK, MercsSetOrdersCallback ); iEditorButton[ MERCS_ORDERS_SEEKENEMY ] = CreateTextButton( iEditorMercsToolbarText[27], (UINT16)SMALLCOMPFONT, FONT_GRAY2, FONT_BLACK, BUTTON_USE_DEFAULT, iScreenWidthOffset + 200, 2 * iScreenHeightOffset + 404, 70, 12, BUTTON_TOGGLE, MSYS_PRIORITY_NORMAL, DEFAULT_MOVE_CALLBACK, MercsSetOrdersCallback ); iEditorButton[ MERCS_ORDERS_CLOSEPATROL ] = CreateTextButton( iEditorMercsToolbarText[28], (UINT16)SMALLCOMPFONT, FONT_GRAY2, FONT_BLACK, BUTTON_USE_DEFAULT, iScreenWidthOffset + 270, 2 * iScreenHeightOffset + 368, 70, 12, BUTTON_TOGGLE, MSYS_PRIORITY_NORMAL, DEFAULT_MOVE_CALLBACK, MercsSetOrdersCallback ); iEditorButton[ MERCS_ORDERS_FARPATROL ] = CreateTextButton( iEditorMercsToolbarText[29], (UINT16)SMALLCOMPFONT, FONT_GRAY2, FONT_BLACK, BUTTON_USE_DEFAULT, iScreenWidthOffset + 270, 2 * iScreenHeightOffset + 380, 70, 12, BUTTON_TOGGLE, MSYS_PRIORITY_NORMAL, DEFAULT_MOVE_CALLBACK, MercsSetOrdersCallback ); iEditorButton[ MERCS_ORDERS_POINTPATROL ] = CreateTextButton( iEditorMercsToolbarText[30], (UINT16)SMALLCOMPFONT, FONT_GRAY2, FONT_BLACK, BUTTON_USE_DEFAULT, iScreenWidthOffset + 270, 2 * iScreenHeightOffset + 392, 70, 12, BUTTON_TOGGLE, MSYS_PRIORITY_NORMAL, DEFAULT_MOVE_CALLBACK, MercsSetOrdersCallback ); iEditorButton[ MERCS_ORDERS_RNDPTPATROL ] = CreateTextButton( iEditorMercsToolbarText[31], (UINT16)SMALLCOMPFONT, FONT_GRAY2, FONT_BLACK, BUTTON_USE_DEFAULT, iScreenWidthOffset + 270, 2 * iScreenHeightOffset + 404, 70, 12, BUTTON_TOGGLE, MSYS_PRIORITY_NORMAL, DEFAULT_MOVE_CALLBACK, MercsSetOrdersCallback ); for ( x = 0; x < 8; x++ ) { MSYS_SetBtnUserData( iEditorButton[ FIRST_MERCS_ORDERS_BUTTON + x ], 0, x); } //Attitudes iEditorButton[ MERCS_ATTITUDE_DEFENSIVE ] = CreateTextButton( iEditorMercsToolbarText[32], (UINT16)SMALLCOMPFONT, FONT_GRAY4, FONT_BLACK, BUTTON_USE_DEFAULT, iScreenWidthOffset + 200, 2 * iScreenHeightOffset + 424, 70, 12, BUTTON_TOGGLE, MSYS_PRIORITY_NORMAL, DEFAULT_MOVE_CALLBACK, MercsSetAttitudeCallback ); iEditorButton[ MERCS_ATTITUDE_BRAVESOLO ] = CreateTextButton( iEditorMercsToolbarText[33], (UINT16)SMALLCOMPFONT, FONT_GRAY4, FONT_BLACK, BUTTON_USE_DEFAULT, iScreenWidthOffset + 200, 2 * iScreenHeightOffset + 436, 70, 12, BUTTON_TOGGLE, MSYS_PRIORITY_NORMAL, DEFAULT_MOVE_CALLBACK, MercsSetAttitudeCallback ); iEditorButton[ MERCS_ATTITUDE_BRAVEAID ] = CreateTextButton( iEditorMercsToolbarText[34], (UINT16)SMALLCOMPFONT, FONT_GRAY4, FONT_BLACK, BUTTON_USE_DEFAULT, iScreenWidthOffset + 200, 2 * iScreenHeightOffset + 448, 70, 12, BUTTON_TOGGLE, MSYS_PRIORITY_NORMAL, DEFAULT_MOVE_CALLBACK, MercsSetAttitudeCallback ); iEditorButton[ MERCS_ATTITUDE_AGGRESSIVE ] = CreateTextButton( iEditorMercsToolbarText[35], (UINT16)SMALLCOMPFONT, FONT_GRAY4, FONT_BLACK, BUTTON_USE_DEFAULT, iScreenWidthOffset + 270, 2 * iScreenHeightOffset + 424, 70, 12, BUTTON_TOGGLE, MSYS_PRIORITY_NORMAL, DEFAULT_MOVE_CALLBACK, MercsSetAttitudeCallback ); iEditorButton[ MERCS_ATTITUDE_CUNNINGSOLO ] = CreateTextButton( iEditorMercsToolbarText[36], (UINT16)SMALLCOMPFONT, FONT_GRAY4, FONT_BLACK, BUTTON_USE_DEFAULT, iScreenWidthOffset + 270, 2 * iScreenHeightOffset + 436, 70, 12, BUTTON_TOGGLE, MSYS_PRIORITY_NORMAL, DEFAULT_MOVE_CALLBACK, MercsSetAttitudeCallback ); iEditorButton[ MERCS_ATTITUDE_CUNNINGAID ] = CreateTextButton( iEditorMercsToolbarText[37], (UINT16)SMALLCOMPFONT, FONT_GRAY4, FONT_BLACK, BUTTON_USE_DEFAULT, iScreenWidthOffset + 270, 2 * iScreenHeightOffset + 448, 70, 12, BUTTON_TOGGLE, MSYS_PRIORITY_NORMAL, DEFAULT_MOVE_CALLBACK, MercsSetAttitudeCallback ); for ( x = 0; x < 6; x++ ) { MSYS_SetBtnUserData( iEditorButton[ FIRST_MERCS_ATTITUDE_BUTTON + x ], 0, x); } iEditorButton[ MERCS_DIRECTION_W ] = CreateIconButton((INT16)giEditMercDirectionIcons[0], 7, BUTTON_USE_DEFAULT, iScreenWidthOffset + 360, 2 * iScreenHeightOffset + 365, 30, 30, BUTTON_TOGGLE, MSYS_PRIORITY_NORMAL + 1, DEFAULT_MOVE_CALLBACK, MercsDirectionSetCallback ); iEditorButton[ MERCS_DIRECTION_NW ] = CreateIconButton((INT16)giEditMercDirectionIcons[0], 0, BUTTON_USE_DEFAULT, iScreenWidthOffset + 390, 2 * iScreenHeightOffset + 365, 30, 30, BUTTON_TOGGLE, MSYS_PRIORITY_NORMAL + 1, DEFAULT_MOVE_CALLBACK, MercsDirectionSetCallback ); iEditorButton[ MERCS_DIRECTION_N ] = CreateIconButton((INT16)giEditMercDirectionIcons[0], 1, BUTTON_USE_DEFAULT, iScreenWidthOffset + 420, 2 * iScreenHeightOffset + 365, 30, 30, BUTTON_TOGGLE, MSYS_PRIORITY_NORMAL + 1, DEFAULT_MOVE_CALLBACK, MercsDirectionSetCallback ); iEditorButton[ MERCS_DIRECTION_NE] = CreateIconButton((INT16)giEditMercDirectionIcons[0], 2, BUTTON_USE_DEFAULT, iScreenWidthOffset + 420, 2 * iScreenHeightOffset + 395, 30, 30, BUTTON_TOGGLE, MSYS_PRIORITY_NORMAL + 1, DEFAULT_MOVE_CALLBACK, MercsDirectionSetCallback ); iEditorButton[ MERCS_DIRECTION_E ] = CreateIconButton((INT16)giEditMercDirectionIcons[0], 3, BUTTON_USE_DEFAULT, iScreenWidthOffset + 420, 2 * iScreenHeightOffset + 425, 30, 30, BUTTON_TOGGLE, MSYS_PRIORITY_NORMAL + 1, DEFAULT_MOVE_CALLBACK, MercsDirectionSetCallback ); iEditorButton[ MERCS_DIRECTION_SE ] = CreateIconButton((INT16)giEditMercDirectionIcons[0], 4, BUTTON_USE_DEFAULT, iScreenWidthOffset + 390, 2 * iScreenHeightOffset + 425, 30, 30, BUTTON_TOGGLE, MSYS_PRIORITY_NORMAL + 1, DEFAULT_MOVE_CALLBACK, MercsDirectionSetCallback ); iEditorButton[ MERCS_DIRECTION_S ] = CreateIconButton((INT16)giEditMercDirectionIcons[0], 5, BUTTON_USE_DEFAULT, iScreenWidthOffset + 360, 2 * iScreenHeightOffset + 425, 30, 30, BUTTON_TOGGLE, MSYS_PRIORITY_NORMAL + 1, DEFAULT_MOVE_CALLBACK, MercsDirectionSetCallback ); iEditorButton[ MERCS_DIRECTION_SW ] = CreateIconButton((INT16)giEditMercDirectionIcons[0], 6, BUTTON_USE_DEFAULT, iScreenWidthOffset + 360, 2 * iScreenHeightOffset + 395, 30, 30, BUTTON_TOGGLE, MSYS_PRIORITY_NORMAL + 1, DEFAULT_MOVE_CALLBACK, MercsDirectionSetCallback ); for ( x = 0; x < 8; x++ ) { swprintf( TempString, iEditorMercsToolbarText[38], FaceDirs[x] ); SetButtonFastHelpText( iEditorButton[ FIRST_MERCS_DIRECTION_BUTTON + x ], TempString ); MSYS_SetBtnUserData( iEditorButton[ FIRST_MERCS_DIRECTION_BUTTON + x ], 0, x); } iEditorButton[ MERCS_DIRECTION_FIND ] = CreateTextButton( iEditorMercsToolbarText[39], (INT16)FONT12POINT1, FONT_MCOLOR_BLACK, FONT_BLACK, BUTTON_USE_DEFAULT, iScreenWidthOffset + 390, 2 * iScreenHeightOffset + 395, 30, 30, BUTTON_NO_TOGGLE, MSYS_PRIORITY_NORMAL + 1, DEFAULT_MOVE_CALLBACK, MercsFindSelectedMercCallback ); SetButtonFastHelpText( iEditorButton[ MERCS_DIRECTION_FIND] , iEditorMercsToolbarText[63] ); iEditorButton[ MERCS_EQUIPMENT_BAD ] = CreateTextButton( iEditorMercsToolbarText[40], (INT16)SMALLCOMPFONT, FONT_GRAY1, FONT_BLACK, BUTTON_USE_DEFAULT, iScreenWidthOffset + 480, 2 * iScreenHeightOffset + 385, 40, 15, BUTTON_TOGGLE, MSYS_PRIORITY_NORMAL, DEFAULT_MOVE_CALLBACK, MercsSetRelativeEquipmentCallback ); SpecifyButtonDownTextColors( iEditorButton[ MERCS_EQUIPMENT_BAD ], FONT_LTRED, FONT_BLACK ); iEditorButton[ MERCS_EQUIPMENT_POOR ] = CreateTextButton( iEditorMercsToolbarText[41], (INT16)SMALLCOMPFONT, FONT_GRAY1, FONT_BLACK, BUTTON_USE_DEFAULT, iScreenWidthOffset + 480, 2 * iScreenHeightOffset + 400, 40, 15, BUTTON_TOGGLE, MSYS_PRIORITY_NORMAL, DEFAULT_MOVE_CALLBACK, MercsSetRelativeEquipmentCallback ); SpecifyButtonDownTextColors( iEditorButton[ MERCS_EQUIPMENT_POOR ], FONT_ORANGE, FONT_BLACK ); iEditorButton[ MERCS_EQUIPMENT_AVERAGE ] = CreateTextButton( iEditorMercsToolbarText[42], (INT16)SMALLCOMPFONT, FONT_GRAY1, FONT_BLACK, BUTTON_USE_DEFAULT, iScreenWidthOffset + 480, 2 * iScreenHeightOffset + 415, 40, 15, BUTTON_TOGGLE, MSYS_PRIORITY_NORMAL, DEFAULT_MOVE_CALLBACK, MercsSetRelativeEquipmentCallback ); SpecifyButtonDownTextColors( iEditorButton[ MERCS_EQUIPMENT_AVERAGE ], FONT_YELLOW, FONT_BLACK ); iEditorButton[ MERCS_EQUIPMENT_GOOD ] = CreateTextButton( iEditorMercsToolbarText[43], (INT16)SMALLCOMPFONT, FONT_GRAY1, FONT_BLACK, BUTTON_USE_DEFAULT, iScreenWidthOffset + 480, 2 * iScreenHeightOffset + 430, 40, 15, BUTTON_TOGGLE, MSYS_PRIORITY_NORMAL, DEFAULT_MOVE_CALLBACK, MercsSetRelativeEquipmentCallback ); SpecifyButtonDownTextColors( iEditorButton[ MERCS_EQUIPMENT_GOOD ], FONT_LTGREEN, FONT_BLACK ); iEditorButton[ MERCS_EQUIPMENT_GREAT ] = CreateTextButton( iEditorMercsToolbarText[44], (INT16)SMALLCOMPFONT, FONT_GRAY1, FONT_BLACK, BUTTON_USE_DEFAULT, iScreenWidthOffset + 480, 2 * iScreenHeightOffset + 445, 40, 15, BUTTON_TOGGLE, MSYS_PRIORITY_NORMAL, DEFAULT_MOVE_CALLBACK, MercsSetRelativeEquipmentCallback ); SpecifyButtonDownTextColors( iEditorButton[ MERCS_EQUIPMENT_GREAT ], FONT_LTBLUE, FONT_BLACK ); for ( x = 0; x < 5; x++ ) { MSYS_SetBtnUserData( iEditorButton[ FIRST_MERCS_REL_EQUIPMENT_BUTTON + x ], 0, x); } iEditorButton[ MERCS_ATTRIBUTES_BAD ] = CreateTextButton( iEditorMercsToolbarText[45], (INT16)SMALLCOMPFONT, FONT_GRAY1, FONT_BLACK, BUTTON_USE_DEFAULT, iScreenWidthOffset + 530, 2 * iScreenHeightOffset + 385, 40, 15, BUTTON_TOGGLE, MSYS_PRIORITY_NORMAL, DEFAULT_MOVE_CALLBACK, MercsSetRelativeAttributesCallback ); SpecifyButtonDownTextColors( iEditorButton[ MERCS_ATTRIBUTES_BAD ], FONT_LTRED, FONT_BLACK ); iEditorButton[ MERCS_ATTRIBUTES_POOR ] = CreateTextButton( iEditorMercsToolbarText[46], (INT16)SMALLCOMPFONT, FONT_GRAY1, FONT_BLACK, BUTTON_USE_DEFAULT, iScreenWidthOffset + 530, 2 * iScreenHeightOffset + 400, 40, 15, BUTTON_TOGGLE, MSYS_PRIORITY_NORMAL, DEFAULT_MOVE_CALLBACK, MercsSetRelativeAttributesCallback ); SpecifyButtonDownTextColors( iEditorButton[ MERCS_ATTRIBUTES_POOR ], FONT_ORANGE, FONT_BLACK ); iEditorButton[ MERCS_ATTRIBUTES_AVERAGE ] = CreateTextButton( iEditorMercsToolbarText[47], (INT16)SMALLCOMPFONT, FONT_GRAY1, FONT_BLACK, BUTTON_USE_DEFAULT, iScreenWidthOffset + 530, 2 * iScreenHeightOffset + 415, 40, 15, BUTTON_TOGGLE, MSYS_PRIORITY_NORMAL, DEFAULT_MOVE_CALLBACK, MercsSetRelativeAttributesCallback ); SpecifyButtonDownTextColors( iEditorButton[ MERCS_ATTRIBUTES_AVERAGE ], FONT_YELLOW, FONT_BLACK ); iEditorButton[ MERCS_ATTRIBUTES_GOOD ] = CreateTextButton( iEditorMercsToolbarText[48], (INT16)SMALLCOMPFONT, FONT_GRAY1, FONT_BLACK, BUTTON_USE_DEFAULT, iScreenWidthOffset + 530, 2 * iScreenHeightOffset + 430, 40, 15, BUTTON_TOGGLE, MSYS_PRIORITY_NORMAL, DEFAULT_MOVE_CALLBACK, MercsSetRelativeAttributesCallback ); SpecifyButtonDownTextColors( iEditorButton[ MERCS_ATTRIBUTES_GOOD ], FONT_LTGREEN, FONT_BLACK ); iEditorButton[ MERCS_ATTRIBUTES_GREAT ] = CreateTextButton( iEditorMercsToolbarText[49], (INT16)SMALLCOMPFONT, FONT_GRAY1, FONT_BLACK, BUTTON_USE_DEFAULT, iScreenWidthOffset + 530, 2 * iScreenHeightOffset + 445, 40, 15, BUTTON_TOGGLE, MSYS_PRIORITY_NORMAL, DEFAULT_MOVE_CALLBACK, MercsSetRelativeAttributesCallback ); SpecifyButtonDownTextColors( iEditorButton[ MERCS_ATTRIBUTES_GREAT ], FONT_LTBLUE, FONT_BLACK ); for( x = 0; x < 5; x++ ) MSYS_SetBtnUserData( iEditorButton[ FIRST_MERCS_REL_ATTRIBUTE_BUTTON + x ], 0, x); iEditorButton[ MERCS_ARMY_CODE ] = CreateCheckBoxButton( iScreenWidthOffset + 575, 2 * iScreenHeightOffset + 410, "EDITOR//radiobutton.sti", MSYS_PRIORITY_NORMAL, MercsSetEnemyColorCodeCallback ); MSYS_SetBtnUserData( iEditorButton[ MERCS_ARMY_CODE ], 0, SOLDIER_CLASS_ARMY ); iEditorButton[ MERCS_ADMIN_CODE ] = CreateCheckBoxButton( iScreenWidthOffset + 575, 2 * iScreenHeightOffset + 424, "EDITOR//radiobutton.sti", MSYS_PRIORITY_NORMAL, MercsSetEnemyColorCodeCallback ); MSYS_SetBtnUserData( iEditorButton[ MERCS_ADMIN_CODE ], 0, SOLDIER_CLASS_ADMINISTRATOR ); iEditorButton[ MERCS_ELITE_CODE ] = CreateCheckBoxButton( iScreenWidthOffset + 575, 2 * iScreenHeightOffset + 438, "EDITOR//radiobutton.sti", MSYS_PRIORITY_NORMAL, MercsSetEnemyColorCodeCallback ); MSYS_SetBtnUserData( iEditorButton[ MERCS_ELITE_CODE ], 0, SOLDIER_CLASS_ELITE ); iEditorButton[ MERCS_CIVILIAN_GROUP ] = CreateTextButton( gszCivGroupNames[0], (INT16)SMALLCOMPFONT, FONT_YELLOW, FONT_BLACK, BUTTON_USE_DEFAULT, iScreenWidthOffset + 574, 2 * iScreenHeightOffset + 410, 60, 25, BUTTON_TOGGLE, MSYS_PRIORITY_NORMAL, DEFAULT_MOVE_CALLBACK, MercsCivilianGroupCallback ); iEditorButton[ MERCS_TOGGLECOLOR_BUTTON ] = CreateCheckBoxButton( iScreenWidthOffset + 180, 2 * iScreenHeightOffset +364, "EDITOR//checkbox.sti", MSYS_PRIORITY_NORMAL, MercsToggleColorModeCallback ); iEditorButton[MERCS_HAIRCOLOR_DOWN] = CreateEasyNoToggleButton( iScreenWidthOffset + 200,2 * iScreenHeightOffset +364,"EDITOR//leftarrow.sti", MercsSetColorsCallback ); iEditorButton[MERCS_HAIRCOLOR_UP] = CreateEasyNoToggleButton( iScreenWidthOffset + 360,2 * iScreenHeightOffset +364,"EDITOR//rightarrow.sti", MercsSetColorsCallback ); iEditorButton[MERCS_SKINCOLOR_DOWN] = CreateEasyNoToggleButton( iScreenWidthOffset + 200,2 * iScreenHeightOffset +388,"EDITOR//leftarrow.sti", MercsSetColorsCallback ); iEditorButton[MERCS_SKINCOLOR_UP] = CreateEasyNoToggleButton( iScreenWidthOffset + 360,2 * iScreenHeightOffset +388,"EDITOR//rightarrow.sti", MercsSetColorsCallback ); iEditorButton[MERCS_VESTCOLOR_DOWN] = CreateEasyNoToggleButton( iScreenWidthOffset + 200,2 * iScreenHeightOffset +412,"EDITOR//leftarrow.sti", MercsSetColorsCallback ); iEditorButton[MERCS_VESTCOLOR_UP] = CreateEasyNoToggleButton( iScreenWidthOffset + 360,2 * iScreenHeightOffset +412,"EDITOR//rightarrow.sti", MercsSetColorsCallback ); iEditorButton[MERCS_PANTCOLOR_DOWN] = CreateEasyNoToggleButton( iScreenWidthOffset + 200,2 * iScreenHeightOffset +436,"EDITOR//leftarrow.sti", MercsSetColorsCallback ); iEditorButton[MERCS_PANTCOLOR_UP] = CreateEasyNoToggleButton( iScreenWidthOffset + 360,2 * iScreenHeightOffset +436,"EDITOR//rightarrow.sti", MercsSetColorsCallback ); for ( x = FIRST_MERCS_COLOR_BUTTON; x < LAST_MERCS_COLOR_BUTTON; x+=2 ) { SetButtonFastHelpText( iEditorButton[x], iEditorMercsToolbarText[50] ); SetButtonFastHelpText( iEditorButton[x + 1], iEditorMercsToolbarText[51] ); DisableButton( iEditorButton[ x ] ); DisableButton( iEditorButton[ x + 1 ] ); } iEditorButton[MERCS_BODYTYPE_DOWN] = CreateEasyNoToggleButton( iScreenWidthOffset + 460, 2 * iScreenHeightOffset +364,"EDITOR//leftarrow.sti", MercsSetBodyTypeCallback ); SetButtonFastHelpText( iEditorButton[ MERCS_BODYTYPE_DOWN ], iEditorMercsToolbarText[52]); iEditorButton[MERCS_BODYTYPE_UP] = CreateEasyNoToggleButton( iScreenWidthOffset + 560, 2 * iScreenHeightOffset +364,"EDITOR//rightarrow.sti", MercsSetBodyTypeCallback ); SetButtonFastHelpText( iEditorButton[ MERCS_BODYTYPE_UP ], iEditorMercsToolbarText[53]); iEditorButton[ MERCS_SCHEDULE_VARIANCE1 ] = CreateCheckBoxButton( iScreenWidthOffset + 309, 2 * iScreenHeightOffset +375, "EDITOR//SmCheckBox.sti", MSYS_PRIORITY_NORMAL, MercsScheduleToggleVariance1Callback ); SetButtonFastHelpText( iEditorButton[ MERCS_SCHEDULE_VARIANCE1 ], iEditorMercsToolbarText[54]); iEditorButton[ MERCS_SCHEDULE_VARIANCE2 ] = CreateCheckBoxButton( iScreenWidthOffset + 309, 2 * iScreenHeightOffset +396, "EDITOR//SmCheckBox.sti", MSYS_PRIORITY_NORMAL, MercsScheduleToggleVariance2Callback ); SetButtonFastHelpText( iEditorButton[ MERCS_SCHEDULE_VARIANCE2 ], iEditorMercsToolbarText[55]); iEditorButton[ MERCS_SCHEDULE_VARIANCE3 ] = CreateCheckBoxButton( iScreenWidthOffset + 309, 2 * iScreenHeightOffset +417, "EDITOR//SmCheckBox.sti", MSYS_PRIORITY_NORMAL, MercsScheduleToggleVariance3Callback ); SetButtonFastHelpText( iEditorButton[ MERCS_SCHEDULE_VARIANCE3 ], iEditorMercsToolbarText[56]); iEditorButton[ MERCS_SCHEDULE_VARIANCE4 ] = CreateCheckBoxButton( iScreenWidthOffset + 309, 2 * iScreenHeightOffset +438, "EDITOR//SmCheckBox.sti", MSYS_PRIORITY_NORMAL, MercsScheduleToggleVariance4Callback ); SetButtonFastHelpText( iEditorButton[ MERCS_SCHEDULE_VARIANCE4 ], iEditorMercsToolbarText[57]); iEditorButton[ MERCS_SCHEDULE_ACTION1 ] = CreateTextButton( iEditorMercsToolbarText[58], FONT10ARIAL, FONT_YELLOW, FONT_BLACK, BUTTON_USE_DEFAULT, iScreenWidthOffset + 186, 2 * iScreenHeightOffset + 373, 77, 16, BUTTON_NO_TOGGLE, MSYS_PRIORITY_NORMAL, DEFAULT_MOVE_CALLBACK, MercsScheduleAction1Callback ); iEditorButton[ MERCS_SCHEDULE_ACTION2 ] = CreateTextButton( iEditorMercsToolbarText[59], FONT10ARIAL, FONT_YELLOW, FONT_BLACK, BUTTON_USE_DEFAULT, iScreenWidthOffset + 186, 2 * iScreenHeightOffset + 394, 77, 16, BUTTON_NO_TOGGLE, MSYS_PRIORITY_NORMAL, DEFAULT_MOVE_CALLBACK, MercsScheduleAction2Callback ); iEditorButton[ MERCS_SCHEDULE_ACTION3 ] = CreateTextButton( iEditorMercsToolbarText[60], FONT10ARIAL, FONT_YELLOW, FONT_BLACK, BUTTON_USE_DEFAULT, iScreenWidthOffset + 186, 2 * iScreenHeightOffset + 415, 77, 16, BUTTON_NO_TOGGLE, MSYS_PRIORITY_NORMAL, DEFAULT_MOVE_CALLBACK, MercsScheduleAction3Callback ); iEditorButton[ MERCS_SCHEDULE_ACTION4 ] = CreateTextButton( iEditorMercsToolbarText[61], FONT10ARIAL, FONT_YELLOW, FONT_BLACK, BUTTON_USE_DEFAULT, iScreenWidthOffset + 186, 2 * iScreenHeightOffset + 436, 77, 16, BUTTON_NO_TOGGLE, MSYS_PRIORITY_NORMAL, DEFAULT_MOVE_CALLBACK, MercsScheduleAction4Callback ); iEditorButton[ MERCS_SCHEDULE_DATA1A ] = CreateTextButton( L"", FONT10ARIAL, FONT_YELLOW, FONT_BLACK, BUTTON_USE_DEFAULT, iScreenWidthOffset + 331, 2 * iScreenHeightOffset + 373, 40, 16, BUTTON_NO_TOGGLE, MSYS_PRIORITY_NORMAL, DEFAULT_MOVE_CALLBACK, MercsScheduleData1ACallback ); iEditorButton[ MERCS_SCHEDULE_DATA1B ] = CreateTextButton( L"", FONT10ARIAL, FONT_YELLOW, FONT_BLACK, BUTTON_USE_DEFAULT, iScreenWidthOffset + 381, 2 * iScreenHeightOffset + 373, 40, 16, BUTTON_NO_TOGGLE, MSYS_PRIORITY_NORMAL, DEFAULT_MOVE_CALLBACK, MercsScheduleData1BCallback ); iEditorButton[ MERCS_SCHEDULE_DATA2A ] = CreateTextButton( L"", FONT10ARIAL, FONT_YELLOW, FONT_BLACK, BUTTON_USE_DEFAULT, iScreenWidthOffset + 331, 2 * iScreenHeightOffset + 394, 40, 16, BUTTON_NO_TOGGLE, MSYS_PRIORITY_NORMAL, DEFAULT_MOVE_CALLBACK, MercsScheduleData2ACallback ); iEditorButton[ MERCS_SCHEDULE_DATA2B ] = CreateTextButton( L"", FONT10ARIAL, FONT_YELLOW, FONT_BLACK, BUTTON_USE_DEFAULT, iScreenWidthOffset + 381, 2 * iScreenHeightOffset + 394, 40, 16, BUTTON_NO_TOGGLE, MSYS_PRIORITY_NORMAL, DEFAULT_MOVE_CALLBACK, MercsScheduleData2BCallback ); iEditorButton[ MERCS_SCHEDULE_DATA3A ] = CreateTextButton( L"", FONT10ARIAL, FONT_YELLOW, FONT_BLACK, BUTTON_USE_DEFAULT, iScreenWidthOffset + 331, 2 * iScreenHeightOffset + 415, 40, 16, BUTTON_NO_TOGGLE, MSYS_PRIORITY_NORMAL, DEFAULT_MOVE_CALLBACK, MercsScheduleData3ACallback ); iEditorButton[ MERCS_SCHEDULE_DATA3B ] = CreateTextButton( L"", FONT10ARIAL, FONT_YELLOW, FONT_BLACK, BUTTON_USE_DEFAULT, iScreenWidthOffset + 381, 2 * iScreenHeightOffset + 415, 40, 16, BUTTON_NO_TOGGLE, MSYS_PRIORITY_NORMAL, DEFAULT_MOVE_CALLBACK, MercsScheduleData3BCallback ); iEditorButton[ MERCS_SCHEDULE_DATA4A ] = CreateTextButton( L"", FONT10ARIAL, FONT_YELLOW, FONT_BLACK, BUTTON_USE_DEFAULT, iScreenWidthOffset + 331, 2 * iScreenHeightOffset + 436, 40, 16, BUTTON_NO_TOGGLE, MSYS_PRIORITY_NORMAL, DEFAULT_MOVE_CALLBACK, MercsScheduleData4ACallback ); iEditorButton[ MERCS_SCHEDULE_DATA4B ] = CreateTextButton( L"", FONT10ARIAL, FONT_YELLOW, FONT_BLACK, BUTTON_USE_DEFAULT, iScreenWidthOffset + 381, 2 * iScreenHeightOffset + 436, 40, 16, BUTTON_NO_TOGGLE, MSYS_PRIORITY_NORMAL, DEFAULT_MOVE_CALLBACK, MercsScheduleData4BCallback ); iEditorButton[ MERCS_SCHEDULE_CLEAR ] = CreateTextButton( iEditorMercsToolbarText[62], FONT10ARIAL, FONT_YELLOW, FONT_BLACK, BUTTON_USE_DEFAULT, iScreenWidthOffset + 516, 2 * iScreenHeightOffset + 362, 77, 16, BUTTON_NO_TOGGLE, MSYS_PRIORITY_NORMAL, DEFAULT_MOVE_CALLBACK, MercsScheduleClearCallback ); HideEditorButtons( MERCS_SCHEDULE_DATA1A, MERCS_SCHEDULE_DATA4B ); iEditorButton[ MERCS_HEAD_SLOT ] = CreateCheckBoxButton( MERCPANEL_X+61, MERCPANEL_Y+0, "EDITOR//smCheckbox.sti", MSYS_PRIORITY_NORMAL+1, MercsInventorySlotCallback ); MSYS_SetBtnUserData( iEditorButton[ MERCS_HEAD_SLOT ], 0, HELMETPOS ); iEditorButton[ MERCS_BODY_SLOT ] = CreateCheckBoxButton( MERCPANEL_X+61, MERCPANEL_Y+22, "EDITOR//smCheckbox.sti", MSYS_PRIORITY_NORMAL+1, MercsInventorySlotCallback ); MSYS_SetBtnUserData( iEditorButton[ MERCS_BODY_SLOT ], 0, VESTPOS ); iEditorButton[ MERCS_LEGS_SLOT ] = CreateCheckBoxButton( MERCPANEL_X+62, MERCPANEL_Y+73, "EDITOR//smCheckbox.sti", MSYS_PRIORITY_NORMAL+1, MercsInventorySlotCallback ); MSYS_SetBtnUserData( iEditorButton[ MERCS_LEGS_SLOT ], 0, LEGPOS ); iEditorButton[ MERCS_LEFTHAND_SLOT ] = CreateCheckBoxButton( MERCPANEL_X+12, MERCPANEL_Y+43, "EDITOR//smCheckbox.sti", MSYS_PRIORITY_NORMAL+1, MercsInventorySlotCallback ); MSYS_SetBtnUserData( iEditorButton[ MERCS_LEFTHAND_SLOT ], 0, HANDPOS ); iEditorButton[ MERCS_RIGHTHAND_SLOT ] = CreateCheckBoxButton( MERCPANEL_X+90, MERCPANEL_Y+42, "EDITOR//smCheckbox.sti", MSYS_PRIORITY_NORMAL+1, MercsInventorySlotCallback ); MSYS_SetBtnUserData( iEditorButton[ MERCS_RIGHTHAND_SLOT ], 0, SECONDHANDPOS ); iEditorButton[ MERCS_PACK1_SLOT ] = CreateCheckBoxButton( MERCPANEL_X+166, MERCPANEL_Y+6, "EDITOR//smCheckbox.sti", MSYS_PRIORITY_NORMAL+1, MercsInventorySlotCallback ); MSYS_SetBtnUserData( iEditorButton[ MERCS_PACK1_SLOT ], 0, BIGPOCK1POS ); iEditorButton[ MERCS_PACK2_SLOT ] = CreateCheckBoxButton( MERCPANEL_X+166, MERCPANEL_Y+29, "EDITOR//smCheckbox.sti", MSYS_PRIORITY_NORMAL+1, MercsInventorySlotCallback ); MSYS_SetBtnUserData( iEditorButton[ MERCS_PACK2_SLOT ], 0, BIGPOCK2POS ); iEditorButton[ MERCS_PACK3_SLOT ] = CreateCheckBoxButton( MERCPANEL_X+166, MERCPANEL_Y+52, "EDITOR//smCheckbox.sti", MSYS_PRIORITY_NORMAL+1, MercsInventorySlotCallback ); MSYS_SetBtnUserData( iEditorButton[ MERCS_PACK3_SLOT ], 0, BIGPOCK3POS ); iEditorButton[ MERCS_PACK4_SLOT ] = CreateCheckBoxButton( MERCPANEL_X+166, MERCPANEL_Y+75, "EDITOR//smCheckbox.sti", MSYS_PRIORITY_NORMAL+1, MercsInventorySlotCallback ); MSYS_SetBtnUserData( iEditorButton[ MERCS_PACK4_SLOT ], 0, BIGPOCK4POS ); } void InitEditorBuildingsToolbar() { iEditorButton[BUILDING_TOGGLE_ROOF_VIEW] = CreateTextButton(iEditorBuildingsToolbarText[0],(UINT16)SMALLCOMPFONT, FONT_YELLOW, FONT_BLACK, BUTTON_USE_DEFAULT, iScreenWidthOffset + 110, 2 * iScreenHeightOffset + 400, 50, 15, BUTTON_TOGGLE,MSYS_PRIORITY_NORMAL,BUTTON_NO_CALLBACK, BuildingToggleRoofViewCallback); iEditorButton[BUILDING_TOGGLE_WALL_VIEW] = CreateTextButton(iEditorBuildingsToolbarText[1],(UINT16)SMALLCOMPFONT, FONT_YELLOW, FONT_BLACK, BUTTON_USE_DEFAULT, iScreenWidthOffset + 110, 2 * iScreenHeightOffset + 415, 50, 15, BUTTON_TOGGLE,MSYS_PRIORITY_NORMAL,BUTTON_NO_CALLBACK, BuildingToggleWallViewCallback); iEditorButton[BUILDING_TOGGLE_INFO_VIEW] = CreateTextButton(iEditorBuildingsToolbarText[2],(UINT16)SMALLCOMPFONT, FONT_YELLOW, FONT_BLACK, BUTTON_USE_DEFAULT, iScreenWidthOffset + 110, 2 * iScreenHeightOffset + 430, 50, 15, BUTTON_TOGGLE,MSYS_PRIORITY_NORMAL,BUTTON_NO_CALLBACK, BuildingToggleInfoViewCallback); //Selection method buttons iEditorButton[BUILDING_PLACE_WALLS] = CreateEasyToggleButton( iScreenWidthOffset + 180,2 * iScreenHeightOffset + 370,"EDITOR//wall.sti", BuildingWallCallback); SetButtonFastHelpText(iEditorButton[BUILDING_PLACE_WALLS],iEditorBuildingsToolbarText[3]);//dnl fix for to many tooltip message in place walls iEditorButton[BUILDING_PLACE_DOORS] = CreateEasyToggleButton( iScreenWidthOffset + 210,2 * iScreenHeightOffset + 370,"EDITOR//door.sti", BuildingDoorCallback); SetButtonFastHelpText(iEditorButton[BUILDING_PLACE_DOORS],iEditorBuildingsToolbarText[4]); iEditorButton[BUILDING_PLACE_ROOFS] = CreateEasyToggleButton( iScreenWidthOffset + 240,2 * iScreenHeightOffset + 370,"EDITOR//roof.sti", BuildingRoofCallback); SetButtonFastHelpText(iEditorButton[BUILDING_PLACE_ROOFS],iEditorBuildingsToolbarText[5]); iEditorButton[BUILDING_PLACE_WINDOWS] = CreateEasyToggleButton( iScreenWidthOffset + 180,2 * iScreenHeightOffset + 400,"EDITOR//window.sti", BuildingWindowCallback); SetButtonFastHelpText(iEditorButton[BUILDING_PLACE_WINDOWS],iEditorBuildingsToolbarText[6]); iEditorButton[BUILDING_PLACE_BROKEN_WALLS] = CreateEasyToggleButton( iScreenWidthOffset + 210, 2 * iScreenHeightOffset + 400,"EDITOR//crackwall.sti", BuildingCrackWallCallback); SetButtonFastHelpText(iEditorButton[BUILDING_PLACE_BROKEN_WALLS],iEditorBuildingsToolbarText[7]); iEditorButton[BUILDING_PLACE_FURNITURE] = CreateEasyToggleButton( iScreenWidthOffset + 240, 2 * iScreenHeightOffset + 400,"EDITOR//decor.sti", BuildingFurnitureCallback); SetButtonFastHelpText(iEditorButton[BUILDING_PLACE_FURNITURE],iEditorBuildingsToolbarText[8]); iEditorButton[BUILDING_PLACE_DECALS] = CreateEasyToggleButton( iScreenWidthOffset + 180, 2 * iScreenHeightOffset + 430,"EDITOR//decal.sti", BuildingDecalCallback); SetButtonFastHelpText(iEditorButton[BUILDING_PLACE_DECALS],iEditorBuildingsToolbarText[9]); iEditorButton[BUILDING_PLACE_FLOORS] = CreateEasyToggleButton( iScreenWidthOffset + 210, 2 * iScreenHeightOffset + 430,"EDITOR//floor.sti", BuildingFloorCallback); SetButtonFastHelpText(iEditorButton[BUILDING_PLACE_FLOORS],iEditorBuildingsToolbarText[10]); iEditorButton[BUILDING_PLACE_TOILETS] = CreateEasyToggleButton( iScreenWidthOffset + 240, 2 * iScreenHeightOffset + 430,"EDITOR//toilet.sti", BuildingToiletCallback); SetButtonFastHelpText(iEditorButton[BUILDING_PLACE_TOILETS],iEditorBuildingsToolbarText[11]); //Smart method buttons iEditorButton[BUILDING_SMART_WALLS] = CreateEasyToggleButton( iScreenWidthOffset + 290, 2 * iScreenHeightOffset + 370,"EDITOR//wall.sti", BuildingSmartWallCallback); SetButtonFastHelpText(iEditorButton[BUILDING_SMART_WALLS],iEditorBuildingsToolbarText[12]); iEditorButton[BUILDING_SMART_DOORS] = CreateEasyToggleButton( iScreenWidthOffset + 320, 2 * iScreenHeightOffset + 370,"EDITOR//door.sti", BuildingSmartDoorCallback); SetButtonFastHelpText(iEditorButton[BUILDING_SMART_DOORS],iEditorBuildingsToolbarText[13]); iEditorButton[BUILDING_SMART_WINDOWS] = CreateEasyToggleButton( iScreenWidthOffset + 290, 2 * iScreenHeightOffset + 400,"EDITOR//window.sti", BuildingSmartWindowCallback); SetButtonFastHelpText(iEditorButton[BUILDING_SMART_WINDOWS],iEditorBuildingsToolbarText[14]); iEditorButton[BUILDING_SMART_BROKEN_WALLS] = CreateEasyToggleButton( iScreenWidthOffset + 320, 2 * iScreenHeightOffset + 400,"EDITOR//crackwall.sti", BuildingSmartCrackWallCallback); SetButtonFastHelpText(iEditorButton[BUILDING_SMART_BROKEN_WALLS],iEditorBuildingsToolbarText[15]); iEditorButton[BUILDING_DOORKEY] = CreateEasyToggleButton( iScreenWidthOffset + 290, 2 * iScreenHeightOffset + 430,"EDITOR//key.sti", BuildingDoorKeyCallback); SetButtonFastHelpText(iEditorButton[BUILDING_DOORKEY], iEditorBuildingsToolbarText[16] ); iEditorButton[BUILDING_NEW_ROOM] = CreateEasyToggleButton( iScreenWidthOffset + 370, 2 * iScreenHeightOffset + 370,"EDITOR//newroom.sti", BuildingNewRoomCallback); SetButtonFastHelpText(iEditorButton[BUILDING_NEW_ROOM],iEditorBuildingsToolbarText[17]); iEditorButton[BUILDING_CAVE_DRAWING] = CreateEasyToggleButton( iScreenWidthOffset + 370, 2 * iScreenHeightOffset + 370,"EDITOR//caves.sti", BuildingCaveDrawingCallback); SetButtonFastHelpText(iEditorButton[BUILDING_CAVE_DRAWING],iEditorBuildingsToolbarText[18]); iEditorButton[BUILDING_SAW_ROOM] = CreateEasyToggleButton( iScreenWidthOffset + 370, 2 * iScreenHeightOffset + 400,"EDITOR//sawroom.sti", BuildingSawRoomCallback); SetButtonFastHelpText(iEditorButton[BUILDING_SAW_ROOM],iEditorBuildingsToolbarText[19]); iEditorButton[BUILDING_KILL_BUILDING] = CreateEasyToggleButton( iScreenWidthOffset + 370, 2 * iScreenHeightOffset + 430,"EDITOR//delroom.sti", BuildingKillBuildingCallback); SetButtonFastHelpText(iEditorButton[BUILDING_KILL_BUILDING],iEditorBuildingsToolbarText[20]); iEditorButton[BUILDING_NEW_ROOF] = CreateEasyToggleButton( iScreenWidthOffset + 400, 2 * iScreenHeightOffset + 430,"EDITOR//newroof.sti", BuildingNewRoofCallback); SetButtonFastHelpText(iEditorButton[BUILDING_NEW_ROOF],iEditorBuildingsToolbarText[21]); iEditorButton[BUILDING_COPY_BUILDING] = CreateEasyToggleButton( iScreenWidthOffset + 430, 2 * iScreenHeightOffset + 430,"EDITOR//copyroom.sti", BuildingCopyBuildingCallback); SetButtonFastHelpText(iEditorButton[BUILDING_COPY_BUILDING],iEditorBuildingsToolbarText[22]); iEditorButton[BUILDING_MOVE_BUILDING] = CreateEasyToggleButton( iScreenWidthOffset + 460, 2 * iScreenHeightOffset + 430,"EDITOR//moveroom.sti", BuildingMoveBuildingCallback); SetButtonFastHelpText(iEditorButton[BUILDING_MOVE_BUILDING],iEditorBuildingsToolbarText[23]); iEditorButton[BUILDING_DRAW_ROOMNUM] = CreateEasyToggleButton( iScreenWidthOffset + 410, 2 * iScreenHeightOffset + 370,"EDITOR//addTileRoom.sti", BuildingDrawRoomNumCallback); SetButtonFastHelpText(iEditorButton[BUILDING_DRAW_ROOMNUM],iEditorBuildingsToolbarText[24]); iEditorButton[BUILDING_ERASE_ROOMNUM] = CreateEasyToggleButton( iScreenWidthOffset + 440, 2 * iScreenHeightOffset + 370,"EDITOR//killTileRoom.sti", BuildingEraseRoomNumCallback); SetButtonFastHelpText(iEditorButton[BUILDING_ERASE_ROOMNUM],iEditorBuildingsToolbarText[25]); iEditorButton[BUILDING_TOGGLE_ERASEMODE] = CreateEasyToggleButton( iScreenWidthOffset + 500, 2 * iScreenHeightOffset + 400,"EDITOR//eraser.sti", BtnEraseCallback); SetButtonFastHelpText(iEditorButton[BUILDING_TOGGLE_ERASEMODE],iEditorBuildingsToolbarText[26]); iEditorButton[BUILDING_UNDO] = CreateEasyNoToggleButton( iScreenWidthOffset + 530, 2 * iScreenHeightOffset + 400,"EDITOR//undo.sti", BtnUndoCallback); SetButtonFastHelpText(iEditorButton[BUILDING_UNDO],iEditorBuildingsToolbarText[27]); iEditorButton[BUILDING_CYCLE_BRUSHSIZE] = CreateEasyNoToggleButton( iScreenWidthOffset + 500, 2 * iScreenHeightOffset + 430,"EDITOR//paint.sti",BtnBrushCallback); SetButtonFastHelpText( iEditorButton[ BUILDING_CYCLE_BRUSHSIZE ], iEditorBuildingsToolbarText[28]); } void InitEditorItemsToolbar() { SetFontForeground( FONT_MCOLOR_LTRED ); iEditorButton[ITEMS_WEAPONS] = CreateTextButton(iEditorItemsToolbarText[0],(UINT16)BLOCKFONT, FONT_MCOLOR_DKWHITE, FONT_BLACK, BUTTON_USE_DEFAULT, iScreenWidthOffset + 100, 2 * iScreenHeightOffset + 440, 59, 20, BUTTON_TOGGLE,MSYS_PRIORITY_NORMAL,DEFAULT_MOVE_CALLBACK, ItemsWeaponsCallback); iEditorButton[ITEMS_AMMO] = CreateTextButton(iEditorItemsToolbarText[1],(UINT16)BLOCKFONT, FONT_MCOLOR_DKWHITE, FONT_BLACK, BUTTON_USE_DEFAULT, iScreenWidthOffset + 159, 2 * iScreenHeightOffset + 440, 40, 20, BUTTON_TOGGLE,MSYS_PRIORITY_NORMAL,DEFAULT_MOVE_CALLBACK, ItemsAmmoCallback); iEditorButton[ITEMS_ARMOUR] = CreateTextButton(iEditorItemsToolbarText[2],(UINT16)BLOCKFONT, FONT_MCOLOR_DKWHITE, FONT_BLACK, BUTTON_USE_DEFAULT, iScreenWidthOffset + 199, 2 * iScreenHeightOffset + 440, 52, 20, BUTTON_TOGGLE,MSYS_PRIORITY_NORMAL,DEFAULT_MOVE_CALLBACK, ItemsArmourCallback); iEditorButton[ITEMS_LBEGEAR] = CreateTextButton(iEditorItemsToolbarText[3],(UINT16)BLOCKFONT, FONT_MCOLOR_DKWHITE, FONT_BLACK, BUTTON_USE_DEFAULT, iScreenWidthOffset + 251, 2 * iScreenHeightOffset + 440, 30, 20, BUTTON_TOGGLE,MSYS_PRIORITY_NORMAL,DEFAULT_MOVE_CALLBACK, ItemsLBECallback); iEditorButton[ITEMS_EXPLOSIVES] = CreateTextButton(iEditorItemsToolbarText[4],(UINT16)BLOCKFONT, FONT_MCOLOR_DKWHITE, FONT_BLACK, BUTTON_USE_DEFAULT, iScreenWidthOffset + 281, 2 * iScreenHeightOffset + 440, 39, 20, BUTTON_TOGGLE,MSYS_PRIORITY_NORMAL,DEFAULT_MOVE_CALLBACK, ItemsExplosivesCallback); iEditorButton[ITEMS_EQUIPMENT1] = CreateTextButton(iEditorItemsToolbarText[5],(UINT16)BLOCKFONT, FONT_MCOLOR_DKWHITE, FONT_BLACK, BUTTON_USE_DEFAULT, iScreenWidthOffset + 320, 2 * iScreenHeightOffset + 440, 21, 20, BUTTON_TOGGLE,MSYS_PRIORITY_NORMAL,DEFAULT_MOVE_CALLBACK, ItemsEquipment1Callback); iEditorButton[ITEMS_EQUIPMENT2] = CreateTextButton(iEditorItemsToolbarText[6],(UINT16)BLOCKFONT, FONT_MCOLOR_DKWHITE, FONT_BLACK, BUTTON_USE_DEFAULT, iScreenWidthOffset + 341, 2 * iScreenHeightOffset + 440, 21, 20, BUTTON_TOGGLE,MSYS_PRIORITY_NORMAL,DEFAULT_MOVE_CALLBACK, ItemsEquipment2Callback); iEditorButton[ITEMS_EQUIPMENT3] = CreateTextButton(iEditorItemsToolbarText[7],(UINT16)BLOCKFONT, FONT_MCOLOR_DKWHITE, FONT_BLACK, BUTTON_USE_DEFAULT, iScreenWidthOffset + 362, 2 * iScreenHeightOffset + 440, 21, 20, BUTTON_TOGGLE,MSYS_PRIORITY_NORMAL,DEFAULT_MOVE_CALLBACK, ItemsEquipment3Callback); iEditorButton[ITEMS_TRIGGERS] = CreateTextButton(iEditorItemsToolbarText[8],(UINT16)BLOCKFONT, FONT_MCOLOR_DKWHITE, FONT_BLACK, BUTTON_USE_DEFAULT, iScreenWidthOffset + 383, 2 * iScreenHeightOffset + 440, 59, 20, BUTTON_TOGGLE,MSYS_PRIORITY_NORMAL,DEFAULT_MOVE_CALLBACK, ItemsTriggersCallback ); iEditorButton[ITEMS_KEYS] = CreateTextButton(iEditorItemsToolbarText[9],(UINT16)BLOCKFONT, FONT_MCOLOR_DKWHITE, FONT_BLACK, BUTTON_USE_DEFAULT, iScreenWidthOffset + 442, 2 * iScreenHeightOffset + 440, 38, 20, BUTTON_TOGGLE,MSYS_PRIORITY_NORMAL,DEFAULT_MOVE_CALLBACK, ItemsKeysCallback ); iEditorButton[ITEMS_LEFTSCROLL] = CreateEasyNoToggleButton( iScreenWidthOffset + 1, 2 * iScreenHeightOffset + 361,"EDITOR//leftscroll.sti", ItemsLeftScrollCallback); iEditorButton[ITEMS_RIGHTSCROLL] = CreateEasyNoToggleButton( iScreenWidthOffset + 50, 2 * iScreenHeightOffset + 361,"EDITOR//rightscroll.sti", ItemsRightScrollCallback); } void InitEditorMapInfoToolbar() { iEditorButton[MAPINFO_ADD_LIGHT1_SOURCE] = CreateEasyToggleButton( iScreenWidthOffset + 10, SCREEN_HEIGHT - 118, "EDITOR//light.sti", BtnDrawLightsCallback ); SetButtonFastHelpText(iEditorButton[MAPINFO_ADD_LIGHT1_SOURCE],iEditorMapInfoToolbarText[0]); iEditorButton[ MAPINFO_LIGHT_PANEL ] = CreateTextButton( 0, 0, 0, 0, BUTTON_USE_DEFAULT, iScreenWidthOffset + 45, SCREEN_HEIGHT - 118, 60, 50, BUTTON_TOGGLE, MSYS_PRIORITY_NORMAL, BUTTON_NO_CALLBACK, BUTTON_NO_CALLBACK ); SpecifyDisabledButtonStyle( iEditorButton[ MAPINFO_LIGHT_PANEL ], DISABLED_STYLE_NONE ); DisableButton( iEditorButton[ MAPINFO_LIGHT_PANEL ] ); iEditorButton[ MAPINFO_PRIMETIME_LIGHT ] = CreateCheckBoxButton( iScreenWidthOffset + 48, SCREEN_HEIGHT - 115, "EDITOR//radiobutton.sti", MSYS_PRIORITY_NORMAL, MapInfoPrimeTimeRadioCallback ); iEditorButton[ MAPINFO_NIGHTTIME_LIGHT ] = CreateCheckBoxButton( iScreenWidthOffset + 48, SCREEN_HEIGHT - 100, "EDITOR//radiobutton.sti", MSYS_PRIORITY_NORMAL, MapInfoNightTimeRadioCallback ); iEditorButton[ MAPINFO_24HOUR_LIGHT ] = CreateCheckBoxButton( iScreenWidthOffset + 48, SCREEN_HEIGHT - 85, "EDITOR//radiobutton.sti", MSYS_PRIORITY_NORMAL, MapInfo24HourTimeRadioCallback ); ClickEditorButton( gbDefaultLightType + MAPINFO_PRIMETIME_LIGHT ); iEditorButton[MAPINFO_TOGGLE_FAKE_LIGHTS] = CreateEasyToggleButton( iScreenWidthOffset + 120, SCREEN_HEIGHT - 118, "EDITOR//fakelight.sti", BtnFakeLightCallback ); SetButtonFastHelpText(iEditorButton[MAPINFO_TOGGLE_FAKE_LIGHTS], iEditorMapInfoToolbarText[1]); iEditorButton[ MAPINFO_RADIO_PANEL ] = CreateTextButton( 0, 0, 0, 0, BUTTON_USE_DEFAULT, iScreenWidthOffset + 207, SCREEN_HEIGHT - 118, 70, 50, BUTTON_TOGGLE, MSYS_PRIORITY_NORMAL, BUTTON_NO_CALLBACK, BUTTON_NO_CALLBACK ); SpecifyDisabledButtonStyle( iEditorButton[ MAPINFO_RADIO_PANEL ], DISABLED_STYLE_NONE ); DisableButton( iEditorButton[ MAPINFO_RADIO_PANEL ] ); iEditorButton[ MAPINFO_RADIO_NORMAL ] = CreateCheckBoxButton( iScreenWidthOffset + 210, SCREEN_HEIGHT - 115, "EDITOR//radiobutton.sti", MSYS_PRIORITY_NORMAL, MapInfoNormalRadioCallback ); iEditorButton[ MAPINFO_RADIO_BASEMENT ] = CreateCheckBoxButton( iScreenWidthOffset + 210, SCREEN_HEIGHT - 100, "EDITOR//radiobutton.sti", MSYS_PRIORITY_NORMAL, MapInfoBasementRadioCallback ); iEditorButton[ MAPINFO_RADIO_CAVES ] = CreateCheckBoxButton( iScreenWidthOffset + 210, SCREEN_HEIGHT - 85, "EDITOR//radiobutton.sti", MSYS_PRIORITY_NORMAL, MapInfoCavesRadioCallback ); iEditorButton[MAPINFO_DRAW_EXITGRIDS] = CreateEasyToggleButton( iScreenWidthOffset + 305, SCREEN_HEIGHT - 108, "EDITOR//exitgridbut.sti", MapInfoDrawExitGridCallback ); SetButtonFastHelpText(iEditorButton[MAPINFO_DRAW_EXITGRIDS],iEditorMapInfoToolbarText[2]); iEditorButton[MAPINFO_CYCLE_BRUSHSIZE] = CreateEasyNoToggleButton( iScreenWidthOffset + 420, SCREEN_HEIGHT - 50, "EDITOR//paint.sti", BtnBrushCallback ); SetButtonFastHelpText(iEditorButton[MAPINFO_CYCLE_BRUSHSIZE],iEditorMapInfoToolbarText[3]); iEditorButton[MAPINFO_UNDO] = CreateEasyNoToggleButton( iScreenWidthOffset + 510, SCREEN_HEIGHT - 50, "EDITOR//undo.sti", BtnUndoCallback ); SetButtonFastHelpText(iEditorButton[MAPINFO_UNDO],iEditorMapInfoToolbarText[4]); iEditorButton[MAPINFO_TOGGLE_ERASEMODE] = CreateEasyToggleButton( iScreenWidthOffset + 540, SCREEN_HEIGHT - 50, "EDITOR//eraser.sti", BtnEraseCallback); SetButtonFastHelpText(iEditorButton[MAPINFO_TOGGLE_ERASEMODE],iEditorMapInfoToolbarText[5]); iEditorButton[ MAPINFO_NORTH_POINT ] = CreateEasyToggleButton( iScreenWidthOffset + 540, SCREEN_HEIGHT - 115, "EDITOR//north.sti", MapInfoEntryPointsCallback); SetButtonFastHelpText( iEditorButton[ MAPINFO_NORTH_POINT ], iEditorMapInfoToolbarText[6]); iEditorButton[ MAPINFO_WEST_POINT ] = CreateEasyToggleButton( iScreenWidthOffset + 525, SCREEN_HEIGHT - 94, "EDITOR//west.sti", MapInfoEntryPointsCallback); SetButtonFastHelpText( iEditorButton[ MAPINFO_WEST_POINT ], iEditorMapInfoToolbarText[7]); iEditorButton[ MAPINFO_EAST_POINT ] = CreateEasyToggleButton( iScreenWidthOffset + 555, SCREEN_HEIGHT - 94, "EDITOR//east.sti", MapInfoEntryPointsCallback); SetButtonFastHelpText( iEditorButton[ MAPINFO_EAST_POINT ], iEditorMapInfoToolbarText[8]); iEditorButton[ MAPINFO_SOUTH_POINT ] = CreateEasyToggleButton( iScreenWidthOffset + 540, SCREEN_HEIGHT - 73, "EDITOR//south.sti", MapInfoEntryPointsCallback); SetButtonFastHelpText( iEditorButton[ MAPINFO_SOUTH_POINT ], iEditorMapInfoToolbarText[9]); iEditorButton[ MAPINFO_CENTER_POINT ] = CreateEasyToggleButton( iScreenWidthOffset + 590, SCREEN_HEIGHT - 105, "EDITOR//center.sti", MapInfoEntryPointsCallback); SetButtonFastHelpText( iEditorButton[ MAPINFO_CENTER_POINT ], iEditorMapInfoToolbarText[10]); iEditorButton[ MAPINFO_ISOLATED_POINT ] = CreateEasyToggleButton( iScreenWidthOffset + 590, SCREEN_HEIGHT - 84, "EDITOR//isolated.sti", MapInfoEntryPointsCallback); SetButtonFastHelpText( iEditorButton[ MAPINFO_ISOLATED_POINT ], iEditorMapInfoToolbarText[11]); } void InitEditorOptionsToolbar() { iEditorButton[OPTIONS_NEW_MAP] = CreateEasyNoToggleButton( iScreenWidthOffset + 71,SCREEN_HEIGHT - 79,"EDITOR//new.sti", BtnNewMapCallback); SetButtonFastHelpText(iEditorButton[OPTIONS_NEW_MAP],iEditorOptionsToolbarText[0]); iEditorButton[OPTIONS_NEW_BASEMENT] = CreateEasyNoToggleButton( iScreenWidthOffset + 101,SCREEN_HEIGHT - 79,"EDITOR//new.sti", BtnNewBasementCallback); SetButtonFastHelpText(iEditorButton[OPTIONS_NEW_BASEMENT],iEditorOptionsToolbarText[1]); iEditorButton[OPTIONS_NEW_CAVES] = CreateEasyNoToggleButton( iScreenWidthOffset + 131,SCREEN_HEIGHT - 79,"EDITOR//new.sti", BtnNewCavesCallback); SetButtonFastHelpText(iEditorButton[OPTIONS_NEW_CAVES],iEditorOptionsToolbarText[2]); iEditorButton[OPTIONS_SAVE_MAP] = CreateEasyNoToggleButton( iScreenWidthOffset + 161,SCREEN_HEIGHT - 79,"EDITOR//save.sti", BtnSaveCallback); SetButtonFastHelpText(iEditorButton[OPTIONS_SAVE_MAP],iEditorOptionsToolbarText[3]); iEditorButton[OPTIONS_LOAD_MAP] = CreateEasyNoToggleButton( iScreenWidthOffset + 191,SCREEN_HEIGHT - 79,"EDITOR//load.sti", BtnLoadCallback); SetButtonFastHelpText(iEditorButton[OPTIONS_LOAD_MAP],iEditorOptionsToolbarText[4]); iEditorButton[OPTIONS_CHANGE_TILESET] = CreateEasyNoToggleButton( iScreenWidthOffset + 221,SCREEN_HEIGHT - 79,"EDITOR//tileset.sti", BtnChangeTilesetCallback); SetButtonFastHelpText(iEditorButton[OPTIONS_CHANGE_TILESET],iEditorOptionsToolbarText[5]); iEditorButton[OPTIONS_LEAVE_EDITOR] = CreateEasyNoToggleButton( iScreenWidthOffset + 251,SCREEN_HEIGHT - 79,"EDITOR//cancel.sti", BtnCancelCallback); SetButtonFastHelpText(iEditorButton[OPTIONS_LEAVE_EDITOR],iEditorOptionsToolbarText[6]); iEditorButton[OPTIONS_QUIT_GAME] = CreateEasyNoToggleButton( iScreenWidthOffset + 281,SCREEN_HEIGHT - 79,"EDITOR//cancel.sti", BtnQuitCallback); SetButtonFastHelpText(iEditorButton[OPTIONS_QUIT_GAME],iEditorOptionsToolbarText[7]); //dnl ch9 071009 iEditorButton[OPTIONS_RADAR_MAP] = CreateEasyNoToggleButton( iScreenWidthOffset + 311,SCREEN_HEIGHT - 79,"EDITOR//tileset.sti", BtnRadarMapCallback); SetButtonFastHelpText(iEditorButton[OPTIONS_RADAR_MAP],iEditorOptionsToolbarText[8]); //dnl ch33 160909 iEditorButton[OPTIONS_VANILLA_MODE] = CreateCheckBoxButton(iScreenWidthOffset+71, SCREEN_HEIGHT-119, "EDITOR//smcheckbox.sti", MSYS_PRIORITY_NORMAL, VanillaModeCallback); SetButtonFastHelpText(iEditorButton[OPTIONS_VANILLA_MODE],iEditorOptionsToolbarText[9]); // TODO.MAP iEditorButton[OPTIONS_RESIZE_MAP_ON_LOADING] = CreateCheckBoxButton(iScreenWidthOffset+5, SCREEN_HEIGHT-42, "EDITOR//smcheckbox.sti", MSYS_PRIORITY_NORMAL, ResizeMapOnLoadingCallback); SetButtonFastHelpText(iEditorButton[OPTIONS_RESIZE_MAP_ON_LOADING],iEditorOptionsToolbarText[10]); } void InitEditorTerrainToolbar() { iEditorButton[TERRAIN_FGROUND_TEXTURES] = CreateEasyToggleButton( iScreenWidthOffset + 100,SCREEN_HEIGHT - 80,"EDITOR//downgrid.sti", BtnFgGrndCallback); SetButtonFastHelpText(iEditorButton[TERRAIN_FGROUND_TEXTURES],iEditorTerrainToolbarText[0]); iEditorButton[TERRAIN_BGROUND_TEXTURES] = CreateEasyToggleButton( iScreenWidthOffset + 130,SCREEN_HEIGHT - 80,"EDITOR//upgrid.sti", BtnBkGrndCallback); SetButtonFastHelpText(iEditorButton[TERRAIN_BGROUND_TEXTURES],iEditorTerrainToolbarText[1]); iEditorButton[TERRAIN_PLACE_CLIFFS] = CreateEasyToggleButton( iScreenWidthOffset + 160,SCREEN_HEIGHT - 80,"EDITOR//banks.sti", BtnBanksCallback); SetButtonFastHelpText(iEditorButton[TERRAIN_PLACE_CLIFFS],iEditorTerrainToolbarText[2]); iEditorButton[TERRAIN_PLACE_ROADS] = CreateEasyToggleButton( iScreenWidthOffset + 190,SCREEN_HEIGHT - 80,"EDITOR//road.sti", BtnRoadsCallback); SetButtonFastHelpText(iEditorButton[TERRAIN_PLACE_ROADS],iEditorTerrainToolbarText[3]); iEditorButton[TERRAIN_PLACE_DEBRIS] = CreateEasyToggleButton( iScreenWidthOffset + 220,SCREEN_HEIGHT - 80,"EDITOR//debris.sti", BtnDebrisCallback); SetButtonFastHelpText(iEditorButton[TERRAIN_PLACE_DEBRIS],iEditorTerrainToolbarText[4]); iEditorButton[TERRAIN_PLACE_TREES] = CreateEasyToggleButton( iScreenWidthOffset + 250,SCREEN_HEIGHT - 80,"EDITOR//tree.sti", BtnObjectCallback); SetButtonFastHelpText(iEditorButton[TERRAIN_PLACE_TREES],iEditorTerrainToolbarText[5]); iEditorButton[TERRAIN_PLACE_ROCKS] = CreateEasyToggleButton( iScreenWidthOffset + 280,SCREEN_HEIGHT - 80,"EDITOR//num1.sti", BtnObject1Callback); SetButtonFastHelpText(iEditorButton[TERRAIN_PLACE_ROCKS],iEditorTerrainToolbarText[6]); iEditorButton[TERRAIN_PLACE_MISC] = CreateEasyToggleButton( iScreenWidthOffset + 310,SCREEN_HEIGHT - 80,"EDITOR//num2.sti", BtnObject2Callback); SetButtonFastHelpText(iEditorButton[TERRAIN_PLACE_MISC],iEditorTerrainToolbarText[7]); iEditorButton[TERRAIN_FILL_AREA] = CreateEasyToggleButton( iScreenWidthOffset + 100,SCREEN_HEIGHT - 50,"EDITOR//fill.sti", BtnFillCallback); SetButtonFastHelpText(iEditorButton[TERRAIN_FILL_AREA],iEditorTerrainToolbarText[8]); iEditorButton[TERRAIN_UNDO] = CreateEasyNoToggleButton( iScreenWidthOffset + 130,SCREEN_HEIGHT - 50,"EDITOR//undo.sti", BtnUndoCallback); SetButtonFastHelpText(iEditorButton[TERRAIN_UNDO],iEditorTerrainToolbarText[9]); iEditorButton[TERRAIN_TOGGLE_ERASEMODE] = CreateEasyToggleButton( iScreenWidthOffset + 160,SCREEN_HEIGHT - 50,"EDITOR//eraser.sti", BtnEraseCallback); SetButtonFastHelpText(iEditorButton[TERRAIN_TOGGLE_ERASEMODE],iEditorTerrainToolbarText[10]); iEditorButton[TERRAIN_CYCLE_BRUSHSIZE] = CreateEasyNoToggleButton( iScreenWidthOffset + 190,SCREEN_HEIGHT - 50,"EDITOR//paint.sti", BtnBrushCallback); SetButtonFastHelpText(iEditorButton[TERRAIN_CYCLE_BRUSHSIZE],iEditorTerrainToolbarText[11]); iEditorButton[TERRAIN_RAISE_DENSITY] = CreateEasyNoToggleButton( iScreenWidthOffset + 280,SCREEN_HEIGHT - 50,"EDITOR//uparrow.sti", BtnIncBrushDensityCallback); SetButtonFastHelpText(iEditorButton[TERRAIN_RAISE_DENSITY],iEditorTerrainToolbarText[12]); iEditorButton[TERRAIN_LOWER_DENSITY] = CreateEasyNoToggleButton( iScreenWidthOffset + 350,SCREEN_HEIGHT - 50,"EDITOR//downarrow.sti", BtnDecBrushDensityCallback); SetButtonFastHelpText(iEditorButton[TERRAIN_LOWER_DENSITY],iEditorTerrainToolbarText[13]); } void CreateEditorTaskbarInternal() { //Create the tabs for the editor taskbar iEditorButton[ TAB_TERRAIN ] = CreateTextButton(iEditorTaskbarInternalText[0], (UINT16)SMALLFONT1, FONT_LTKHAKI, FONT_DKKHAKI, BUTTON_USE_DEFAULT, iScreenWidthOffset + 100, SCREEN_HEIGHT - 20, 90, 20, BUTTON_TOGGLE,MSYS_PRIORITY_HIGH,BUTTON_NO_CALLBACK, TaskTerrainCallback); SpecifyButtonDownTextColors( iEditorButton[TAB_TERRAIN], FONT_YELLOW, FONT_ORANGE ); iEditorButton[ TAB_BUILDINGS ] = CreateTextButton(iEditorTaskbarInternalText[1], (UINT16)SMALLFONT1, FONT_LTKHAKI, FONT_DKKHAKI, BUTTON_USE_DEFAULT, iScreenWidthOffset + 190, SCREEN_HEIGHT - 20, 90, 20, BUTTON_TOGGLE,MSYS_PRIORITY_HIGH,BUTTON_NO_CALLBACK, TaskBuildingCallback); SpecifyButtonDownTextColors( iEditorButton[TAB_BUILDINGS], FONT_YELLOW, FONT_ORANGE ); iEditorButton[ TAB_ITEMS ] = CreateTextButton(iEditorTaskbarInternalText[2], (UINT16)SMALLFONT1, FONT_LTKHAKI, FONT_DKKHAKI, BUTTON_USE_DEFAULT, iScreenWidthOffset + 280, SCREEN_HEIGHT - 20, 90, 20, BUTTON_TOGGLE,MSYS_PRIORITY_HIGH,BUTTON_NO_CALLBACK, TaskItemsCallback); SpecifyButtonDownTextColors( iEditorButton[TAB_ITEMS], FONT_YELLOW, FONT_ORANGE ); iEditorButton[ TAB_MERCS ] = CreateTextButton(iEditorTaskbarInternalText[3], (UINT16)SMALLFONT1, FONT_LTKHAKI, FONT_DKKHAKI, BUTTON_USE_DEFAULT, iScreenWidthOffset + 370, SCREEN_HEIGHT - 20, 90, 20, BUTTON_TOGGLE,MSYS_PRIORITY_HIGH,BUTTON_NO_CALLBACK, TaskMercsCallback); SpecifyButtonDownTextColors( iEditorButton[TAB_MERCS], FONT_YELLOW, FONT_ORANGE ); iEditorButton[ TAB_MAPINFO ] = CreateTextButton(iEditorTaskbarInternalText[4], (UINT16)SMALLFONT1, FONT_LTKHAKI, FONT_DKKHAKI, BUTTON_USE_DEFAULT, iScreenWidthOffset + 460, SCREEN_HEIGHT - 20, 90, 20, BUTTON_TOGGLE,MSYS_PRIORITY_HIGH,BUTTON_NO_CALLBACK, TaskMapInfoCallback); SpecifyButtonDownTextColors( iEditorButton[TAB_MAPINFO], FONT_YELLOW, FONT_ORANGE ); iEditorButton[ TAB_OPTIONS ] = CreateTextButton(iEditorTaskbarInternalText[5], (UINT16)SMALLFONT1, FONT_LTKHAKI, FONT_DKKHAKI, BUTTON_USE_DEFAULT, iScreenWidthOffset + 550, SCREEN_HEIGHT - 20, 90, 20, BUTTON_TOGGLE,MSYS_PRIORITY_HIGH,BUTTON_NO_CALLBACK, TaskOptionsCallback); SpecifyButtonDownTextColors( iEditorButton[TAB_OPTIONS], FONT_YELLOW, FONT_ORANGE ); //Create the buttons within each tab. InitEditorTerrainToolbar(); InitEditorBuildingsToolbar(); InitEditorItemsToolbar(); InitEditorMercsToolbar(); InitEditorMapInfoToolbar(); InitEditorOptionsToolbar(); InitEditorItemStatsButtons(); } #endif
[ "jazz_ja@b41f55df-6250-4c49-8e33-4aa727ad62a1" ]
[ [ [ 1, 824 ] ] ]
1f319fb0c76935b0a92d1ef9baa806ba52d00595
c70941413b8f7bf90173533115c148411c868bad
/core/src/vtxAtlasNode.cpp
31dc641aece86045b6133a5fbff937ae5c0ae915
[]
no_license
cnsuhao/vektrix
ac6e028dca066aad4f942b8d9eb73665853fbbbe
9b8c5fa7119ff7f3dc80fb05b7cdba335cf02c1a
refs/heads/master
2021-06-23T11:28:34.907098
2011-03-27T17:39:37
2011-03-27T17:39:37
null
0
0
null
null
null
null
UTF-8
C++
false
false
7,462
cpp
/* ----------------------------------------------------------------------------- This source file is part of "vektrix" (the rich media and vector graphics rendering library) For the latest info, see http://www.fuse-software.com/ Copyright (c) 2009-2010 Fuse-Software (tm) Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ----------------------------------------------------------------------------- */ #include "vtxAtlasNode.h" #include "vtxAtlasElement.h" #include "vtxRasterizer.h" namespace vtx { //----------------------------------------------------------------------- AtlasNode::AtlasNode(const Rect& rect, Texture* parent) : mRect(rect), mRotated(false), mParent(parent), mChild_1(NULL), mChild_2(NULL), mElement(NULL) { } //----------------------------------------------------------------------- AtlasNode::~AtlasNode() { delete mChild_1; delete mChild_2; mChild_1 = NULL; mChild_2 = NULL; } //----------------------------------------------------------------------- void AtlasNode::renderElement(Rasterizer* rasterizer) { if(mElement) { mElement->paintToNode(this, rasterizer); } if(mChild_1) { mChild_1->renderElement(rasterizer); } if(mChild_2) { mChild_2->renderElement(rasterizer); } } //----------------------------------------------------------------------- void AtlasNode::setElement(AtlasElement* element) { mElement = element; } //----------------------------------------------------------------------- const Rect& AtlasNode::getRect() const { return mRect; } //----------------------------------------------------------------------- Texture* AtlasNode::getTexture() const { return mParent; } //----------------------------------------------------------------------- uint AtlasNode::getPackedSize() { uint result = 0; if(mChild_1) { result += mChild_1->getPackedSize(); } if(mChild_2) { result += mChild_2->getPackedSize(); } if(mElement) { result += mElement->getPackableWidth()*mElement->getPackableHeight(); } return result; } //----------------------------------------------------------------------- AtlasNode::FitMode AtlasNode::fits(AtlasElement* element) { // check if it fits normally if(element->getPackableWidth() <= mRect.w() && element->getPackableHeight() <= mRect.h()) { return FITS_NORMAL; } // ...no? -> check if it fits when rotated //if(element->getPackableWidth() <= mRect.h() && element->getPackableHeight() <= mRect.w()) //{ // return FITS_ROTATED; //} // it doesn't fit either way return DOESNT_FIT; } //----------------------------------------------------------------------- AtlasNode::FitMode AtlasNode::fitsExactly(AtlasElement* element) { // check if it fits normally if(element->getPackableWidth() == mRect.w() && element->getPackableHeight() == mRect.h()) { return FITS_NORMAL; } // ...no? -> check if it fits when rotated //if(element->getPackableWidth() == mRect.h() && element->getPackableHeight() == mRect.w()) //{ // return FITS_ROTATED; //} // it doesn't fit either way return DOESNT_FIT; } //----------------------------------------------------------------------- AtlasNode* AtlasNode::insert(AtlasElement* element) { uint element_width_PoT = element->getPackableWidth(); uint element_height_PoT = element->getPackableHeight(); // this is not a leaf (i.e. there are children) if(mChild_1 || mChild_2) { // try to insert into first child node AtlasNode* foundNode = mChild_1->insert(element); if(foundNode) { // enough space here return foundNode; } // try to insert into second child node return mChild_2->insert(element); } // this is a leaf (i.e. no children) else { // this node already contains an image if(mElement) { return NULL; } const FitMode fit_normal = fits(element); // image is too big for this node if(fit_normal == DOESNT_FIT) { return NULL; } const FitMode fit_exactly = fitsExactly(element); // image fits exactly into this node if(fit_exactly == FITS_NORMAL) { return this; } // image fits exactly into this node when rotated else if(fit_exactly == FITS_ROTATED) { mRotated = true; return this; } // image fits, but not exactly ---> create child nodes //child_1 = new Node; //child_2 = new Node; // split the node for the image if(fit_normal == FITS_NORMAL) { // decide which way to split uint dw = mRect.w() - element_width_PoT; uint dh = mRect.h() - element_height_PoT; // delta width is bigger --> split by width if(dw > dh) { mChild_1 = new AtlasNode(Rect(mRect.left, mRect.top, mRect.left+element_width_PoT, mRect.bottom), mParent); mChild_2 = new AtlasNode(Rect(mRect.left+element_width_PoT, mRect.top, mRect.right, mRect.bottom), mParent); } // delta height is bigger --> split by height else { mChild_1 = new AtlasNode(Rect(mRect.left, mRect.top, mRect.right, mRect.top+element_height_PoT), mParent); mChild_2 = new AtlasNode(Rect(mRect.left, mRect.top+element_height_PoT, mRect.right, mRect.bottom), mParent); } } // split the node for the rotated image else if(fit_normal == FITS_ROTATED) { // decide which way to split uint dw = mRect.w() - element_height_PoT; uint dh = mRect.h() - element_width_PoT; // delta width is bigger --> split by width if(dw > dh) { mChild_1 = new AtlasNode(Rect(mRect.left, mRect.top, mRect.left+element_height_PoT, mRect.bottom), mParent); mChild_2 = new AtlasNode(Rect(mRect.left+element_height_PoT, mRect.top, mRect.right, mRect.bottom), mParent); } // delta height is bigger --> split by height else { mChild_1 = new AtlasNode(Rect(mRect.left, mRect.top, mRect.right, mRect.top+element_width_PoT), mParent); mChild_2 = new AtlasNode(Rect(mRect.left, mRect.top+element_width_PoT, mRect.right, mRect.bottom), mParent); } } // insert into the first child that we created return mChild_1->insert(element); } // texture is full ?! return NULL; } //----------------------------------------------------------------------- }
[ "stonecold_@9773a11d-1121-4470-82d2-da89bd4a628a" ]
[ [ [ 1, 252 ] ] ]
a396bdbd46694c7c6f33506d844988762432d955
54cacc105d6bacdcfc37b10d57016bdd67067383
/trunk/source/xml/XMLElement.cpp
09e373cc833806abf4a2b5566270bb816980f72c
[]
no_license
galek/hesperus
4eb10e05945c6134901cc677c991b74ce6c8ac1e
dabe7ce1bb65ac5aaad144933d0b395556c1adc4
refs/heads/master
2020-12-31T05:40:04.121180
2009-12-06T17:38:49
2009-12-06T17:38:49
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,902
cpp
/*** * hesperus: XMLElement.cpp * Copyright Stuart Golodetz, 2009. All rights reserved. ***/ #include "XMLElement.h" #include <source/exceptions/Exception.h> namespace hesp { //#################### CONSTRUCTORS #################### XMLElement::XMLElement(const std::string& name) : m_name(name) {} //#################### PUBLIC METHODS #################### void XMLElement::add_child(const XMLElement_Ptr& child) { m_children[child->name()].push_back(child); } const std::string& XMLElement::attribute(const std::string& name) const { std::map<std::string,std::string>::const_iterator it = m_attributes.find(name); if(it != m_attributes.end()) return it->second; else throw Exception("The element does not have an attribute named " + name); } std::vector<XMLElement_CPtr> XMLElement::find_children(const std::string& name) const { ChildMap::const_iterator it = m_children.find(name); if(it != m_children.end()) return it->second; else return std::vector<XMLElement_CPtr>(); } XMLElement_CPtr XMLElement::find_unique_child(const std::string& name) const { ChildMap::const_iterator it = m_children.find(name); if(it != m_children.end()) { const std::vector<XMLElement_CPtr>& children = it->second; if(children.size() == 1) return children[0]; else throw Exception("The element has more than one child named " + name); } else throw Exception("The element has no child named " + name); } bool XMLElement::has_attribute(const std::string& name) const { return m_attributes.find(name) != m_attributes.end(); } bool XMLElement::has_child(const std::string& name) const { return m_children.find(name) != m_children.end(); } const std::string& XMLElement::name() const { return m_name; } void XMLElement::set_attribute(const std::string& name, const std::string& value) { m_attributes[name] = value; } }
[ [ [ 1, 69 ] ] ]
29ed5968fb2418393e8652c777ff5ae2621972dd
ed1a161411b6850d6113b640b5b8c776e7cb0f2c
/TiGLiCS/src/Objects/Object.h
fb2a6a3d5e2a2d73d282cd2db157163702e640a2
[]
no_license
weimingtom/tiglics
643d19a616dcae3e474471e3dea868f6631463ba
450346a441ee6c538e39968311ab60eb9e572746
refs/heads/master
2021-01-10T01:36:31.607727
2008-08-13T03:35:45
2008-08-13T03:35:45
48,733,131
0
0
null
null
null
null
SHIFT_JIS
C++
false
false
8,793
h
#pragma once #include "Objects/Fiber.h" #include <typeinfo> //class CEngine;//循環参照回避 //基本オブジェクト //受け取ったテクスチャ、レンダラは解放しない namespace TiGLiCS{ namespace Object{ /** @brief オブジェクトクラス @author my04337 タスクに組み込むためのクラス。ユーザはこのクラスを継承して使用する。 */ class CObject:public IObject,private CFiber{ Sint32 ProcessPriority; CObjectContainer *pObjectContainer; Sint32 WaitNum;//待機フレーム数 bool bDead;//死亡したかどうか public: ///自分の所属するページへのポインタ CPage *pPage; /** @brief コンストラクタ @author my04337 @param pPage [in] 所属させるページへのポインタ @param ProcessPriority [in] 処理優先度 */ CObject(CPage *pPage,Sint32 ProcessPriority); /** @brief デストラクタ @author my04337 デストラクタ。基本的に使用すべきではない。 */ virtual ~CObject(){}//デストラクタ /** @brief 処理優先度取得 @author my04337 @return 処理優先度 処理優先度を取得する。 */ inline Sint32 GetProcessPriority(void){return ProcessPriority;} //必須関数 /** @brief 初期化関数 @author my04337 オブジェクトがタスクに組み込まれた直後に実行される。<br> タスクやページが関係する初期化文はここに書くとよい。 */ virtual void Init(void)=0; /** @brief 処理関数 @author my04337 オブジェクトの移動などの処理を記述する。<br> この館数が終了すると自動的にオブジェクトは削除キューに入る。<br> この関数内でのみ、Update(),Wait()関数を呼び出すことができる。<br> また、この関数内でも描画を行うことはできる。<br> 記述の際には、無限ループなどを作っておき、それをUpdateにて中断する<br> なお、この関数のみスタックは独自に確保した領域を使うため、<br> スタックオーバーフローに注意する必要がある。<br> <br> 以下のコードではProcessが10回呼ばれるとオブジェクトが削除される。 @code class CTestObject:public IObject{ ... Process(){ for(int i=0;i<10;++i){ ...//いろいろな処理(移動処理、キー入力判定など) Update(); } } ... } @endcode */ virtual void Process(void)=0;//処理 /** @brief 描画関数 @author my04337 ここには主に描画処理など毎フレーム確実に実行したい処理を記述する。<br> なお、毎フレーム必ず呼ばれることを利用して移動処理も書くこともできるが、<br> それよりははOnUpdate関数に記述する方式を推奨する。 */ virtual void Draw(void)=0;//描画 /** @brief 解放関数 @author my04337 この関数は、オブジェクトがタスクから外される直前に呼ばれる。<br> 解放処理などはここに書くことを推奨する。<br> ※デストラクタにて解放処理を行うことは推奨しません。 */ virtual void Release(void)=0;//オブジェクトがタスクから外される直前に呼ばれる //任意関数 /** @brief レンダラ描画前 @author my04337 この関数はレンダラが描画を始める前に呼ばれる。<br> 3Dで描画などを行うとき、シーンマネージャの設定などを行いたいときは<br> ここを利用するとよい。なお、この中では描画は不可能である。 */ virtual void BeforeRenderBegin(void){};//Beginする前 /** @brief オブジェクト死亡時 @author my04337 この関数はオブジェクトが死亡し、削除キューに入った直後に呼ばれる。<br> オブジェクトに対しDie()関数を呼び出すと、削除対象のオブジェクトでこの関数が呼ばれる。<br> 死亡直後に処理を行いたいときにここに書けばよい。 */ virtual void OnDie(void){}//オブジェクト死亡時 /** @brief オブジェクトアップデート時 @author my04337 この関数はオブジェクトがUpdate関数を呼び出したときに呼び出される。<br> 移動処理など、毎フレーム実行したい処理などはここに書くとよい。 */ virtual void OnUpdate(void){}//Updateが呼ばれたとき //その他関数 /** @brief アップデート @author my04337 Process内にて、実行を中断し1フレーム待機する関数である。<br> この関数を呼び出した後、Draw関数が実行され、次のオブジェクトの実行が行われる。<br> 絶対にこの関数をProess関数外で使用してはいけない。<br> なお、再開時はこの関数の直後から再開される。 */ virtual void Update();//アップデート処理 ///オブジェクトの死亡判定 bool isDead(){return bDead;} /** @brief オブジェクトを死亡させる @author my04337 この関数を呼び出すことで、オブジェクトは削除キューに入れられる。<br> その後、OnDie関数が呼ばれる。<br> ただし、この関数が呼ばれた時点ではオブジェクトの削除は行われず、<br> 自分自身のDie関数を呼び出した場合でも処理が続行される。 */ void Die();//死亡させる bool _RunProcess();//プロセス実行。 void _SuspendProcess(){Suspend();} int GetRestProcessStack(){return GetStackRest();} /** @brief 指定回数アップデート @author my04337 @param FrameNum [in] 待機フレーム この関数では、FrameNumで指定したフレーム数Update()を呼び出す。<br> Update関数はUpdate(1)とほぼ等価である。<br> なお、この関数はオーバーライトを推奨しない(する場合はUpdate()をオーバーライトすればよい)。 */ void Update(Sint32 FrameNum);//指定フレーム数待機 inline CObjectContainer *GetCObjectContainer(){return pObjectContainer;} inline void SetCObjectContainer(CObjectContainer *pObjectContainer){this->pObjectContainer=pObjectContainer;} //あると便利な関数 /** @brief 画面内外判定 @author my04337 @param pos [in] オブジェクト座標 @retval true 画面外 @retval false 画面内 指定された座標が画面外にいるかを判定する。 */ Bool isScreenOut(Selene::Math::Point2DF &pos); /** @brief キー状態取得 @author my04337 @param KeyCode [in] キーコード @retval おされていない場合 0 @retval おされている場合 おされたフレーム数 キーがおされたかどうかを判定する。CEngine::GetKey()と等価 */ Sint32 GetKey(Selene::eVirtualKeyCode KeyCode); /* @brief オブジェクト追加 @author my04337 @param pObject [in] 追加するオブジェクトのポインタ 現在のページにオブジェクトを追加する。<br> 追加したオブジェクトは次のフレームから実行される。 */ void AddObject(IObject *pOboect); /** @brief スクリーンサイズ取得 @author my04337 @return スクリーンサイズ スクリーンのサイズを取得。CEngine::GetScreenSize()と等価 */ Selene::Math::Point2DI GetScreenSize(); /** @brief フレームレート取得 @author my04337 @return フレームレート 設定されたフレームレートを取得。CEngine::GetFrameRate()と等価 */ Sint32 GetFrameRate(); /** @brief タスクの終了 @author my04337 タスクの実行を終了する。CEngine::End()と等価である */ void End(); }; //----------------------------------------------------------------------------------------------------- class CObjectContainer {//削除高速化対策 void Process(); public: bool isDead;//削除済みかどうか IObject * pObj;//IObjectへのポインタ CObjectContainer(IObject *pObj){ //コンストラクタ isDead=false; this->pObj= pObj;//IObjectへのポインタ } ~CObjectContainer(){} }; }; };
[ "my04337@d15ed888-2954-0410-b748-710a6ca92709" ]
[ [ [ 1, 243 ] ] ]
6a69f1ac63b9b0834bc5795f09f9582960d00e0e
6c8c4728e608a4badd88de181910a294be56953a
/RexLogicModule/EventHandlers/NetworkEventHandler.h
97475dde4caee5b9c7d42ade101b4b777f4025ba
[ "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
2,335
h
// For conditions of distribution and use, see copyright notice in license.txt #ifndef incl_NetworkEventHandler_h #define incl_NetworkEventHandler_h #include "ComponentInterface.h" #include "NetworkEvents.h" namespace ProtocolUtilities { class ProtocolModuleInterface; } namespace RexLogic { struct DecodedTerrainPatch; class RexLogicModule; class ScriptDialogHandler; typedef boost::shared_ptr<ScriptDialogHandler> ScriptDialogHandlerPtr; /// Handles incoming SLUDP network events in a reX-specific way. \todo Break down into more logical functions. class NetworkEventHandler { public: NetworkEventHandler(Foundation::Framework *framework, RexLogicModule *rexlogicmodule); virtual ~NetworkEventHandler(); // !Handle network events coming from OpenSimProtocolModule bool HandleOpenSimNetworkEvent(event_id_t event_id, Foundation::EventDataInterface *data); private: // !Handler functions for Opensim network events bool HandleOSNE_AgentMovementComplete(ProtocolUtilities::NetworkEventInboundData *data); bool HandleOSNE_ImprovedTerseObjectUpdate(ProtocolUtilities::NetworkEventInboundData *data); bool HandleOSNE_KillObject(ProtocolUtilities::NetworkEventInboundData *data); bool HandleOSNE_LogoutReply(ProtocolUtilities::NetworkEventInboundData *data); bool HandleOSNE_ObjectUpdate(ProtocolUtilities::NetworkEventInboundData *data); bool HandleOSNE_RegionHandshake(ProtocolUtilities::NetworkEventInboundData *data); bool HandleOSNE_SoundTrigger(ProtocolUtilities::NetworkEventInboundData *data); bool HandleOSNE_PreloadSound(ProtocolUtilities::NetworkEventInboundData *data); bool HandleOSNE_ScriptDialog(ProtocolUtilities::NetworkEventInboundData *data); //! Handler functions for GenericMessages bool HandleOSNE_GenericMessage(ProtocolUtilities::NetworkEventInboundData *data); void DebugCreateTerrainVisData(const DecodedTerrainPatch &heightData, int patchSize); Foundation::Framework *framework_; boost::weak_ptr<ProtocolUtilities::ProtocolModuleInterface> protocolModule_; RexLogicModule *rexlogicmodule_; ScriptDialogHandlerPtr script_dialog_handler_; }; } #endif
[ "sempuki@5b2332b8-efa3-11de-8684-7d64432d61a3", "jaakkoallander@5b2332b8-efa3-11de-8684-7d64432d61a3", "jonnenau@5b2332b8-efa3-11de-8684-7d64432d61a3", "tuco@5b2332b8-efa3-11de-8684-7d64432d61a3", "jjj@5b2332b8-efa3-11de-8684-7d64432d61a3", "[email protected]@5b2332b8-efa3-11de-8684-7d64432d61a3", "cadaver@5b2332b8-efa3-11de-8684-7d64432d61a3" ]
[ [ [ 1, 6 ], [ 8, 8 ], [ 15, 15 ], [ 27, 27 ], [ 56, 57 ] ], [ [ 7, 7 ], [ 10, 10 ], [ 12, 12 ], [ 21, 21 ], [ 32, 37 ], [ 43, 43 ], [ 48, 50 ] ], [ [ 9, 9 ], [ 11, 11 ] ], [ [ 13, 14 ], [ 17, 17 ], [ 20, 20 ], [ 22, 26 ], [ 28, 28 ], [ 30, 31 ], [ 41, 42 ], [ 47, 47 ], [ 51, 51 ], [ 54, 55 ] ], [ [ 16, 16 ], [ 44, 44 ], [ 46, 46 ] ], [ [ 18, 19 ], [ 40, 40 ], [ 52, 53 ] ], [ [ 29, 29 ], [ 38, 39 ], [ 45, 45 ] ] ]
e90df863e633039a87b76a273b7d40e104e229fa
928b250a42ffbe1d1c1009b4af7fd3f6a1f46266
/forlijia/forlijia/forlijia/FilterAddress.cpp
7ce9125ed50e2009ac5c3d986e8ed525c172bc36
[]
no_license
jimcoly/comyitian
81044cc6e5d06613e1f2bda8b658457e8337ab8f
6f70e202907be1071d3310bfe1441567ebffed1e
refs/heads/master
2020-05-31T17:54:26.448254
2011-09-01T07:28:07
2011-09-01T07:28:07
33,866,360
0
0
null
null
null
null
GB18030
C++
false
false
1,004
cpp
#include "StdAfx.h" #include "FilterAddress.h" #include "config.h" FilterAddressHeader::FilterAddressHeader(void) { config *theConfig=config::getinstance(); m_shengFilter=new FilterWords(theConfig->shenglist,L"省"); m_shiFilter=new FilterWords(theConfig->shilist,L"市"); m_quFilter=new FilterWords(theConfig->qulist,L"区"); m_xianFilter=new FilterWords(theConfig->xianlist,L"县"); m_zhenFilter=new FilterWords(theConfig->zhenlist,L"镇"); } FilterAddressHeader::~FilterAddressHeader(void) { delete m_shengFilter; delete m_shiFilter; delete m_quFilter; delete m_xianFilter; delete m_zhenFilter; } bool FilterAddressHeader::process( std::wstring &str ) { if (!m_shengFilter->process(str)){ return false; }//省是必须的 if (!m_shiFilter->process(str)){ return false; }//市是必须的 if (!m_quFilter->process(str)){ //区不存在就给县镇处理 m_xianFilter->process(str); m_zhenFilter->process(str); } return true; }
[ "sdy63420@3919fc08-f352-11de-9907-777483041811" ]
[ [ [ 1, 40 ] ] ]
ac705a78cc2912b21d47dc7897e8fe2133fe7579
de37068405e7fa8f7a4e43bfe8af9b23787f6926
/mainwindow.h
2b9f5389667091bf4deba62485679dc9b1d64022
[]
no_license
ssserenity/zbuffer-cpu
faf052c30ba77f88fc3140c478b59cb4e6bb24d8
e014c783a25bbd0ff19c7bfc6846d6997bee227e
refs/heads/master
2021-01-21T18:50:59.847444
2011-11-24T16:16:51
2011-11-24T16:16:51
null
0
0
null
null
null
null
UTF-8
C++
false
false
2,041
h
#ifndef MAINWINDOW_H #define MAINWINDOW_H #include <QMainWindow> class QMenu; class QAction; class QActionGroup; class CAccessObj; class CScanLine; class QDoubleSpinBox; class MainWindow : public QMainWindow { Q_OBJECT public: MainWindow(); MainWindow(const QString &fileName); ~MainWindow(); protected: bool eventFilter(QObject *obj, QEvent *e); QSize sizeHint() const; private: void setupUi(); void createActions(); void createMenus(); void createToolBars(); void createStatusBar(); void init(); void initRenderSystem(); void drawCubeTest(); void openObjFile(const QString& fileName); void renderObj(); void saveAsImageFile(const QString& fileName); void setResolution(int width, int height); QString strippedName(const QString& fullFileName); void rotateBy(double xAngle, double yAngle, double zAngle); private slots: void open(); void saveAs(); void resolution(); void shadeModel(QAction* act); void toggleView(QAction* act); void newFrustumOrLight(); void about(); private: QWidget *mImgView; QImage mImage; QMenu *mFileMenu; QMenu *mViewMenu; QMenu *mEditMenu; QMenu *mHelpMenu; QToolBar *mFileToolBar; QToolBar *mEditToolBar; QToolBar *mCameraLightToolBar; QAction *mOpenAct; QAction *mQuitAct; QAction *mSaveAsImageAct; QAction *mResolutionAct; QActionGroup *mShadeActGroup; QAction *mShadeFlatAct; QAction *mShadeSmoothAct; QAction *mToggleLightingAct; QAction *mRandomColorAct; QAction *mPointLightAct; QAction *mDirLightAct; QActionGroup *mViewActGroup; QAction *mViewToolBarAct; QAction *mAboutAct; QAction *mAboutQtAct; QAction *mMouseOpAct; QDoubleSpinBox *mSpinEyeX; QDoubleSpinBox *mSpinEyeY; QDoubleSpinBox *mSpinEyeZ; QDoubleSpinBox *mSpinLightX; QDoubleSpinBox *mSpinLightY; QDoubleSpinBox *mSpinLightZ; CAccessObj *mpAccessObj; CScanLine *mpRenderSystem; // mouse operations QPoint lastPos; int xRot; int yRot; int zRot; }; #endif // MAINWINDOW_H
[ [ [ 1, 95 ] ] ]
36e9a6c1dc42b3ba84cac7512b601f6784916c60
74c8da5b29163992a08a376c7819785998afb588
/NetAnimal/Game/Hunter/NewGameComponent/GameNeedleComponent/include/GameRotationComponent.h
7030d6dacc4cfe5470cc3ee2baf1675ad78a616b
[]
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
WINDOWS-1252
C++
false
false
1,121
h
#ifndef __Orz_GameRotationComponent__ #define __Orz_GameRotationComponent__ namespace Ogre { class SceneNode; } namespace Orz { class WinnerAnimationInterface; class CGameRotationInterface; class GameRotationComponent: public Component//ÄÚÍâȦ { public : GameRotationComponent(void); virtual ~GameRotationComponent(void); private: virtual ComponentInterface * _queryInterface(const TypeInfo & info) const; boost::scoped_ptr<CGameRotationInterface> _gameRotationInterface; ComponentPtr _needleComp; ComponentPtr _needleRotationComp; ComponentPtr _baseComp; ComponentPtr _baseRotationComp; Ogre::SceneNode * _needleNode; Ogre::SceneNode * _baseNode; Ogre::SceneNode * _node; private: bool play(int needle, TimeType needleTime, int base, TimeType baseTime);//> PlayFunction; bool update(TimeType i);//> UpdateFunction; bool winnerUpdate(TimeType i); bool winner(int id, bool move); void reset(void); boost::scoped_ptr<WinnerAnimationInterface> _winnerAnimation; bool init(ComponentPtr sceneComp); int _base; int _needle; }; } #endif
[ [ [ 1, 50 ] ] ]
cf402854ccf57fd8d624b8661ff23f63f94c4149
3472e587cd1dff88c7a75ae2d5e1b1a353962d78
/XMonitor/src/ReportView.h
44e0f56f2dff6a7b9fc233225898ffed90b4404a
[]
no_license
yewberry/yewtic
9624d05d65e71c78ddfb7bd586845e107b9a1126
2468669485b9f049d7498470c33a096e6accc540
refs/heads/master
2021-01-01T05:40:57.757112
2011-09-14T12:32:15
2011-09-14T12:32:15
32,363,059
0
0
null
null
null
null
UTF-8
C++
false
false
841
h
/* * ReportView.h * * Created on: 2011-3-13 * Author: Administrator */ #ifndef REPORTVIEW_H_ #define REPORTVIEW_H_ #include <QWidget> #include <QListWidget> #include <QMenu> #include "../ui_ReportView.h" class ReportListWidget; class ReportView : public QWidget { Q_OBJECT public: ReportView(QWidget *parent = 0); private: void drawUi(); private: Ui::ReportViewClass ui; ReportListWidget* m_pRptList; }; class ReportListWidget: public QListWidget { Q_OBJECT public: ReportListWidget(QWidget *parent = 0) : QListWidget(parent) { m_pContainer = (ReportView*)parent; } protected: void contextMenuEvent(QContextMenuEvent *event){ m_pCtxMenu->exec(QCursor::pos()); } public: QMenu* m_pCtxMenu; ReportView* m_pContainer; }; #endif /* REPORTVIEW_H_ */
[ "yew1998@5ddc4e96-dffd-11de-b4b3-6d349e4f6f86" ]
[ [ [ 1, 53 ] ] ]
8a95e133281de6e32980b26a55685ee59e988e5c
496be1b38c9d03d478d02f4ccd54ce5c27aa689f
/7zip/CPP/7zip/Bundles/SFXSetup/Main.cpp
c9c57323093cc75a8294b6982f7dba562703c7dc
[]
no_license
ehsan/nouatest-crowdsource
d63af32cb86c6b4e7afec508146a6c55b6bb5673
43ce064c526368e0827f0679a86d3d30da52f33b
refs/heads/master
2016-09-05T10:41:11.670248
2011-12-08T21:55:23
2011-12-08T21:55:23
2,894,914
0
0
null
null
null
null
UTF-8
C++
false
false
9,175
cpp
// Main.cpp #include "StdAfx.h" #include <initguid.h> #include "Common/StringConvert.h" #include "Common/Random.h" #include "Common/TextConfig.h" #include "Common/CommandLineParser.h" #include "Windows/FileDir.h" #include "Windows/FileIO.h" #include "Windows/FileFind.h" #include "Windows/FileName.h" #include "Windows/DLL.h" #include "Windows/ResourceString.h" #include "../../IPassword.h" #include "../../ICoder.h" #include "../../Archive/IArchive.h" #include "../../UI/Explorer/MyMessages.h" // #include "../../UI/GUI/ExtractGUI.h" #include "ExtractEngine.h" #include "resource.h" using namespace NWindows; HINSTANCE g_hInstance; static LPCTSTR kTempDirPrefix = TEXT("7zS"); #define _SHELL_EXECUTE static bool ReadDataString(LPCWSTR fileName, LPCSTR startID, LPCSTR endID, AString &stringResult) { stringResult.Empty(); NFile::NIO::CInFile inFile; if (!inFile.Open(fileName)) return false; const int kBufferSize = (1 << 12); Byte buffer[kBufferSize]; int signatureStartSize = lstrlenA(startID); int signatureEndSize = lstrlenA(endID); UInt32 numBytesPrev = 0; bool writeMode = false; UInt64 posTotal = 0; for (;;) { if (posTotal > (1 << 20)) return (stringResult.IsEmpty()); UInt32 numReadBytes = kBufferSize - numBytesPrev; UInt32 processedSize; if (!inFile.Read(buffer + numBytesPrev, numReadBytes, processedSize)) return false; if (processedSize == 0) return true; UInt32 numBytesInBuffer = numBytesPrev + processedSize; UInt32 pos = 0; for (;;) { if (writeMode) { if (pos > numBytesInBuffer - signatureEndSize) break; if (memcmp(buffer + pos, endID, signatureEndSize) == 0) return true; char b = buffer[pos]; if (b == 0) return false; stringResult += b; pos++; } else { if (pos > numBytesInBuffer - signatureStartSize) break; if (memcmp(buffer + pos, startID, signatureStartSize) == 0) { writeMode = true; pos += signatureStartSize; } else pos++; } } numBytesPrev = numBytesInBuffer - pos; posTotal += pos; memmove(buffer, buffer + pos, numBytesPrev); } } static char kStartID[] = ",!@Install@!UTF-8!"; static char kEndID[] = ",!@InstallEnd@!"; class CInstallIDInit { public: CInstallIDInit() { kStartID[0] = ';'; kEndID[0] = ';'; }; } g_CInstallIDInit; class CCurrentDirRestorer { CSysString m_CurrentDirectory; public: CCurrentDirRestorer() { NFile::NDirectory::MyGetCurrentDirectory(m_CurrentDirectory); } ~CCurrentDirRestorer() { RestoreDirectory();} bool RestoreDirectory() { return BOOLToBool(::SetCurrentDirectory(m_CurrentDirectory)); } }; #ifndef _UNICODE bool g_IsNT = false; static inline bool IsItWindowsNT() { OSVERSIONINFO versionInfo; versionInfo.dwOSVersionInfoSize = sizeof(versionInfo); if (!::GetVersionEx(&versionInfo)) return false; return (versionInfo.dwPlatformId == VER_PLATFORM_WIN32_NT); } #endif int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE /* hPrevInstance */, LPSTR /* lpCmdLine */,int /* nCmdShow */) { g_hInstance = (HINSTANCE)hInstance; #ifndef _UNICODE g_IsNT = IsItWindowsNT(); #endif InitCommonControls(); UString archiveName, switches; #ifdef _SHELL_EXECUTE UString executeFile, executeParameters; #endif NCommandLineParser::SplitCommandLine(GetCommandLineW(), archiveName, switches); UString fullPath; NDLL::MyGetModuleFileName(g_hInstance, fullPath); switches.Trim(); bool assumeYes = false; if (switches.Left(2).CompareNoCase(UString(L"-y")) == 0) { assumeYes = true; switches = switches.Mid(2); switches.Trim(); } AString config; if (!ReadDataString(fullPath, kStartID, kEndID, config)) { if (!assumeYes) ShowErrorMessage(L"Can't load config info"); return 1; } UString dirPrefix = L"." WSTRING_PATH_SEPARATOR; UString appLaunched; bool showProgress = true; if (!config.IsEmpty()) { CObjectVector<CTextConfigPair> pairs; if (!GetTextConfig(config, pairs)) { if (!assumeYes) ShowErrorMessage(L"Config failed"); return 1; } UString friendlyName = GetTextConfigValue(pairs, L"Title"); UString installPrompt = GetTextConfigValue(pairs, L"BeginPrompt"); UString progress = GetTextConfigValue(pairs, L"Progress"); if (progress.CompareNoCase(L"no") == 0) showProgress = false; int index = FindTextConfigItem(pairs, L"Directory"); if (index >= 0) dirPrefix = pairs[index].String; if (!installPrompt.IsEmpty() && !assumeYes) { if (MessageBoxW(0, installPrompt, friendlyName, MB_YESNO | MB_ICONQUESTION) != IDYES) return 0; } appLaunched = GetTextConfigValue(pairs, L"RunProgram"); #ifdef _SHELL_EXECUTE executeFile = GetTextConfigValue(pairs, L"ExecuteFile"); executeParameters = GetTextConfigValue(pairs, L"ExecuteParameters") + switches; #endif } NFile::NDirectory::CTempDirectory tempDir; if (!tempDir.Create(kTempDirPrefix)) { if (!assumeYes) ShowErrorMessage(L"Can not create temp folder archive"); return 1; } CCodecs *codecs = new CCodecs; CMyComPtr<IUnknown> compressCodecsInfo = codecs; HRESULT result = codecs->Load(); if (result != S_OK) { ShowErrorMessage(L"Can not load codecs"); return 1; } UString tempDirPath = GetUnicodeString(tempDir.GetPath()); { bool isCorrupt = false; UString errorMessage; HRESULT result = ExtractArchive(codecs, fullPath, tempDirPath, showProgress, isCorrupt, errorMessage); if (result != S_OK) { if (!assumeYes) { if (result == S_FALSE || isCorrupt) { errorMessage = NWindows::MyLoadStringW(IDS_EXTRACTION_ERROR_MESSAGE); result = E_FAIL; } if (result != E_ABORT && !errorMessage.IsEmpty()) ::MessageBoxW(0, errorMessage, NWindows::MyLoadStringW(IDS_EXTRACTION_ERROR_TITLE), MB_ICONERROR); } return 1; } } CCurrentDirRestorer currentDirRestorer; if (!SetCurrentDirectory(tempDir.GetPath())) return 1; HANDLE hProcess = 0; #ifdef _SHELL_EXECUTE executeFile.Replace(L"%%T", tempDirPath); executeParameters.Replace(L"%%T", tempDirPath); if (!executeFile.IsEmpty()) { CSysString filePath = GetSystemString(executeFile); SHELLEXECUTEINFO execInfo; execInfo.cbSize = sizeof(execInfo); execInfo.fMask = SEE_MASK_NOCLOSEPROCESS | SEE_MASK_FLAG_DDEWAIT; execInfo.hwnd = NULL; execInfo.lpVerb = NULL; execInfo.lpFile = filePath; if (!switches.IsEmpty()) executeParameters += switches; CSysString parametersSys = GetSystemString(executeParameters); if (parametersSys.IsEmpty()) execInfo.lpParameters = NULL; else execInfo.lpParameters = parametersSys; execInfo.lpDirectory = tempDir.GetPath(); execInfo.nShow = SW_SHOWNORMAL; execInfo.hProcess = 0; /* BOOL success = */ ::ShellExecuteEx(&execInfo); UINT32 result = (UINT32)(UINT_PTR)execInfo.hInstApp; if(result <= 32) { if (!assumeYes) ShowErrorMessage(L"Can not open file"); return 1; } hProcess = execInfo.hProcess; } else #endif { if (appLaunched.IsEmpty()) { appLaunched = L"setup.exe"; if (!NFile::NFind::DoesFileExist(GetSystemString(appLaunched))) { if (!assumeYes) ShowErrorMessage(L"Can not find setup.exe"); return 1; } } { UString s2 = tempDirPath; NFile::NName::NormalizeDirPathPrefix(s2); appLaunched.Replace(L"%%T" WSTRING_PATH_SEPARATOR, s2); } appLaunched.Replace(L"%%T", tempDirPath); if (!switches.IsEmpty()) { appLaunched += L' '; appLaunched += switches; } STARTUPINFO startupInfo; startupInfo.cb = sizeof(startupInfo); startupInfo.lpReserved = 0; startupInfo.lpDesktop = 0; startupInfo.lpTitle = 0; startupInfo.dwFlags = 0; startupInfo.cbReserved2 = 0; startupInfo.lpReserved2 = 0; PROCESS_INFORMATION processInformation; CSysString appLaunchedSys = GetSystemString(dirPrefix + appLaunched); BOOL createResult = CreateProcess(NULL, (LPTSTR)(LPCTSTR)appLaunchedSys, NULL, NULL, FALSE, 0, NULL, NULL /*tempDir.GetPath() */, &startupInfo, &processInformation); if (createResult == 0) { if (!assumeYes) ShowLastErrorMessage(); return 1; } ::CloseHandle(processInformation.hThread); hProcess = processInformation.hProcess; } if (hProcess != 0) { WaitForSingleObject(hProcess, INFINITE); ::CloseHandle(hProcess); } return 0; }
[ [ [ 1, 344 ] ] ]
e57086c9d75321c5cb77f797c4241b2cb18b0267
27d5670a7739a866c3ad97a71c0fc9334f6875f2
/CPP/Targets/WayFinder/symbian-r6/ItineraryContainer.cpp
ef0797274b07b5f25189ae0806feaafda1ed2aaf
[ "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
24,887
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 FILES #include <eikclbd.h> #include <barsread.h> // for resource reader #include <aknlists.h> // for avrell style listbox #include <akniconarray.h> // for icon array #include <gulicon.h> #include "RsgInclude.h" #include "wficons.mbg" #include "GuiDataStore.h" #include "ItineraryView.h" #include "ItineraryContainer.h" #include "wayfinder.hrh" #include "WFTextUtil.h" #include "WFLayoutUtils.h" #include "DistancePrintingPolicy.h" // Definitions #define LISTBOX_POS TPoint(10, 15) // --------------------------------------------------------- // CItineraryContainer::ConstructL(const TRect& aRect) // EPOC two phased constructor // --------------------------------------------------------- // void CItineraryContainer::ConstructL( const TRect& aRect, CItineraryView* aView ) { CreateWindowL(); iView = aView; iPrevious = 1; GuiDataStore* gds = iView->GetGuiDataStore(); HBufC* wfmbmname = gds->iWayfinderMBMFilename; TResourceReader reader; iCoeEnv->CreateResourceReaderLC( reader, R_WAYFINDER_ITINERARY_LIST ); iListBox = new( ELeave ) CAknDoubleLargeStyleListBox(); LOGNEW(iListBox, CAknDoubleLargeStyleListBox); iListBox->SetContainerWindowL(*this); iListBox->ConstructFromResourceL(reader); iListBox->SetListBoxObserver( this ); iListBox->CreateScrollBarFrameL(ETrue); iListBox->ScrollBarFrame()->SetScrollBarVisibilityL(CEikScrollBarFrame::EOff, CEikScrollBarFrame::EAuto); iListBox->UpdateScrollBarsL(); iListBox->ItemDrawer()->FormattedCellData()->SetMarqueeParams(5, 3, 1000000, 200000); iListBox->ItemDrawer()->FormattedCellData()->EnableMarqueeL(ETrue); CleanupStack::PopAndDestroy(); // Resource reader // Creates gul icon. CArrayPtr<CGulIcon>* icons = new( ELeave ) CAknIconArray( 2 ); LOGNEW(icons, CAknIconArray); CleanupStack::PushL( icons ); #ifdef NAV2_CLIENT_SERIES60_V3 AddToIconList(icons, *wfmbmname, EMbmWficonsSm_turn_blank, EMbmWficonsSm_turn_blank_mask); AddToIconList(icons, *wfmbmname, EMbmWficonsSm_ferry, EMbmWficonsSm_ferry_mask); AddToIconList(icons, *wfmbmname, EMbmWficonsSm_reached_destination, EMbmWficonsSm_reached_destination_mask); AddToIconList(icons, *wfmbmname, EMbmWficonsSm_keep_left, EMbmWficonsSm_keep_left_mask); AddToIconList(icons, *wfmbmname, EMbmWficonsSm_keep_right, EMbmWficonsSm_keep_right_mask); AddToIconList(icons, *wfmbmname, EMbmWficonsSm_turn_left, EMbmWficonsSm_turn_left_mask); AddToIconList(icons, *wfmbmname, EMbmWficonsSm_multiway_roundabout_right, EMbmWficonsSm_multiway_roundabout_right_mask); AddToIconList(icons, *wfmbmname, EMbmWficonsSm_multiway_roundabout_left, EMbmWficonsSm_multiway_roundabout_left_mask); AddToIconList(icons, *wfmbmname, EMbmWficonsSm_parking_area, EMbmWficonsSm_parking_area_mask); AddToIconList(icons, *wfmbmname, EMbmWficonsSm_turn_right, EMbmWficonsSm_turn_right_mask); AddToIconList(icons, *wfmbmname, EMbmWficonsSm_start, EMbmWficonsSm_start_mask); AddToIconList(icons, *wfmbmname, EMbmWficonsSm_drive_straight_ahead1, EMbmWficonsSm_drive_straight_ahead1_mask); AddToIconList(icons, *wfmbmname, EMbmWficonsSm_uturn_right, EMbmWficonsSm_uturn_right_mask); AddToIconList(icons, *wfmbmname, EMbmWficonsSm_uturn_left, EMbmWficonsSm_uturn_left_mask); AddToIconList(icons, *wfmbmname, EMbmWficonsDetour_square, EMbmWficonsDetour_square_mask); AddToIconList(icons, *wfmbmname, EMbmWficonsSpeedcamera_square, EMbmWficonsSpeedcamera_square_mask); AddToIconList(icons, *wfmbmname, EMbmWficonsTickmarker, EMbmWficonsTickmarker_mask); #else // Appends graphic data. icons->AppendL( iEikonEnv->CreateIconL( *wfmbmname, EMbmWficonsMedium_blank, EMbmWficonsMedium_mask ) ); icons->AppendL( iEikonEnv->CreateIconL( *wfmbmname, EMbmWficonsMedium_ferry, EMbmWficonsMedium_mask ) ); icons->AppendL( iEikonEnv->CreateIconL( *wfmbmname, EMbmWficonsMedium_flag, EMbmWficonsMedium_flag_m ) ); icons->AppendL( iEikonEnv->CreateIconL( *wfmbmname, EMbmWficonsMedium_keep_left, EMbmWficonsMedium_mask ) ); icons->AppendL( iEikonEnv->CreateIconL( *wfmbmname, EMbmWficonsMedium_keep_right, EMbmWficonsMedium_mask ) ); icons->AppendL( iEikonEnv->CreateIconL( *wfmbmname, EMbmWficonsMedium_left_arrow, EMbmWficonsMedium_mask ) ); icons->AppendL( iEikonEnv->CreateIconL( *wfmbmname, EMbmWficonsMedium_multiway_rdbt, EMbmWficonsMedium_mask ) ); icons->AppendL( iEikonEnv->CreateIconL( *wfmbmname, EMbmWficonsMedium_multiway_rdbt_left, EMbmWficonsMedium_mask ) ); icons->AppendL( iEikonEnv->CreateIconL( *wfmbmname, EMbmWficonsMedium_park_car, EMbmWficonsMedium_mask ) ); icons->AppendL( iEikonEnv->CreateIconL( *wfmbmname, EMbmWficonsMedium_right_arrow, EMbmWficonsMedium_mask ) ); icons->AppendL( iEikonEnv->CreateIconL( *wfmbmname, EMbmWficonsMedium_start, EMbmWficonsMedium_start_m ) ); icons->AppendL( iEikonEnv->CreateIconL( *wfmbmname, EMbmWficonsMedium_straight_arrow, EMbmWficonsMedium_mask ) ); icons->AppendL( iEikonEnv->CreateIconL( *wfmbmname, EMbmWficonsMedium_u_turn, EMbmWficonsMedium_mask ) ); icons->AppendL( iEikonEnv->CreateIconL( *wfmbmname, EMbmWficonsMedium_u_turn_left, EMbmWficonsMedium_mask ) ); icons->AppendL( iEikonEnv->CreateIconL( *wfmbmname, EMbmWficonsMedium_detour, EMbmWficonsMedium_speedcam_detour_m ) ); icons->AppendL( iEikonEnv->CreateIconL( *wfmbmname, EMbmWficonsMedium_speedcam, EMbmWficonsMedium_speedcam_detour_m ) ); icons->AppendL( iEikonEnv->CreateIconL( *wfmbmname, EMbmWficonsTickmark, EMbmWficonsTickmark_m ) ); #endif // Sets graphics as ListBox icon. iListBox->ItemDrawer()->ColumnData()->SetIconArray( icons ); CleanupStack::Pop(); //icons iListBox->SetExtent( LISTBOX_POS, iListBox->MinimumSize() ); SetRect(aRect); ActivateL(); } // Destructor CItineraryContainer::~CItineraryContainer() { LOGDEL(iListBox); delete iListBox; iListBox = NULL; iView = NULL; } void CItineraryContainer::SetListArray( TBool aHasRoute ) { if ( iListBox ){ MDesCArray* itemList = iListBox->Model()->ItemTextArray(); CDesCArray* itemArray = STATIC_CAST( CDesCArray*, itemList ); itemArray->Reset(); iListBox->HandleItemRemovalL(); HBufC* item; if( aHasRoute ) { item = iCoeEnv->AllocReadResourceLC(R_WAYFINDER_ITINERARY_CREATE_ROUTE ); } else { item = iCoeEnv->AllocReadResourceLC(R_WAYFINDER_ITINERARY_NOROUTE ); } itemArray->AppendL( *item ); CleanupStack::PopAndDestroy(item); iListBox->HandleItemAdditionL(); } } // ---------------------------------------------------------------------------- // void CItineraryContainer::AddItemL() // Adds list item to the list. // ---------------------------------------------------------------------------- // void CItineraryContainer::AddItemL( TPictures aTurn, TBool aRightTraffic, TInt aDistance, TInt aAcumulatedDistance, TInt aExit, TDesC &aText) { TInt iconPos = 0; //Blank TBool multiwayRdbt = EFalse; switch( aTurn ) { case EFerry: iconPos = 1; // Ferry break; case EFinishArrow: case EFinishFlag: iconPos = 2; // Flag break; case EEnterHighWay: case EEnterMainRoad: if (aRightTraffic) { iconPos = 3; // KeepLeft } else{ iconPos = 4; //KeepRight } break; case EExitHighWay: case EExitMainRoad: if (aRightTraffic) { iconPos = 4; //KeepRight } else{ iconPos = 3; // KeepLeft } break; case EExitHighWayLeft: case EExitMainRoadLeft: case EKeepLeft: iconPos = 3; // KeepLeft break; case EExitHighWayRight: case EExitMainRoadRight: case EKeepRight: iconPos = 4; //KeepRight break; case E3WayLeft: case E3WayTeeLeft: case E4WayLeft: case ELeftArrow: case ERdbLeft: iconPos = 5; // LeftArrow break; case EMultiWayRdb: if (aRightTraffic) { iconPos = 6; // MultiWayRdb } else { iconPos = 7; // MultiWayRdbLeft } multiwayRdbt = ETrue; break; case EPark: iconPos = 8; // Park break; case E3WayRight: case E3WayTeeRight: case E4WayRight: case ERdbRight: case ERightArrow: iconPos = 9; // RightArrow break; case EStart: iconPos = 10; // Start break; case E4WayStraight: case EHighWayStraight: case EStraight: case EStraightArrow: case ERdbStraight: iconPos = 11; // StraightArrow break; case ERdbUTurn: case EUTurn: if (aRightTraffic) { iconPos = 12; // UTurn } else { iconPos = 13; // UTurnLeft } break; case EDetour: iconPos = 14; // Detour break; case ESpeedCam: iconPos = 15; // Speed camera break; case EOffTrack: case EWrongDirection: case ENoPicture: break; } TBuf<KBuf32Length> distance; if( aTurn == EStart ){ iCoeEnv->ReadResource( distance, R_WAYFINDER_ITINERARY_START ); } else if (aTurn == EDetour) { if (aRightTraffic) { /* Used as Begin. */ iCoeEnv->ReadResource( distance, R_WAYFINDER_ITINERARY_DETOUR_START); } else { /* Used as End. */ iCoeEnv->ReadResource( distance, R_WAYFINDER_ITINERARY_DETOUR_END); } } else if (aTurn == ESpeedCam) { if (aRightTraffic) { /* Used as Begin. */ iCoeEnv->ReadResource( distance, R_WAYFINDER_ITINERARY_SPEEDCAM_START); } else { /* Used as End. */ iCoeEnv->ReadResource( distance, R_WAYFINDER_ITINERARY_SPEEDCAM_END); } } else { GetDistance( aDistance, distance ); if( multiwayRdbt ){ distance.Append( _L(" ") ); distance.AppendNum( aExit ); TBuf<KBuf32Length> exit; iCoeEnv->ReadResource( exit, R_WAYFINDER_ITINERARY_EXIT ); distance.Append( exit ); } TBuf<KBuf32Length> acumulated; isab::DistancePrintingPolicy::DistanceMode mode = isab::DistancePrintingPolicy::DistanceMode(iView->GetDistanceMode()); char* tmp2 = isab::DistancePrintingPolicy::convertDistance( aAcumulatedDistance, mode, isab::DistancePrintingPolicy::Round); if (tmp2) { WFTextUtil::char2TDes(acumulated, tmp2); delete[] tmp2; } else { acumulated.Copy(_L(" ")); } distance.Append( _L("(")); distance.Append( acumulated ); distance.Append( _L(")")); } if ( iListBox ){ MDesCArray* itemList = iListBox->Model()->ItemTextArray(); CDesCArray* itemArray = STATIC_CAST( CDesCArray*, itemList ); TBuf<KBuf256Length> item( _L("") ); item.Num( iconPos ); item.Append( KTab ); item.Append( distance ); item.Append( KTab ); if( aText.Length() < item.MaxLength()-item.Length() ) item.Append( aText ); else item.Append( aText.Ptr(), item.MaxLength()-item.Length() ); itemArray->AppendL( item ); iListBox->HandleItemAdditionL(); // Updates listbox. } } // ---------------------------------------------------------------------------- // void CItineraryContainer::RemoveAllItemsL() // Remove all items. // ---------------------------------------------------------------------------- // void CItineraryContainer::RemoveAllItemsL() { if ( iListBox ){ MDesCArray* itemList = iListBox->Model()->ItemTextArray(); CDesCArray *itemArray = STATIC_CAST( CDesCArray*, itemList ); itemArray->Reset(); iListBox->HandleItemRemovalL(); // Updates listbox. // Actually, the HandleItemRemovalL does not provoke a redraw... iListBox->Reset(); } } void CItineraryContainer::SetSelection( TInt aCurrent, TInt aPrevious ) { if( iListBox ){ MDesCArray* itemList = iListBox->Model()->ItemTextArray(); CDesCArray* itemArray = STATIC_CAST( CDesCArray*, itemList ); aCurrent++; aPrevious++; if( aCurrent > 0 && aCurrent <= itemList->MdcaCount() ){ TInt currItem = itemList->MdcaCount() - aCurrent; TInt prevItem = itemList->MdcaCount() - iPrevious; if( iView->IsGpsAllowed()){ TBuf<KBuf256Length> item( _L("") ); item.Copy( itemArray->MdcaPoint( prevItem ) ); TInt idx = item.Find( _L("\t16") ); if( idx != KErrNotFound ){ item.SetLength( idx ); item.PtrZ(); itemArray->Delete( prevItem ); itemArray->InsertL( prevItem, item ); } _LIT(KSelectedItemEndText, "\t16"); if(itemArray->MdcaPoint(currItem).Length() <= item.MaxLength() - KSelectedItemEndText().Length()) item.Copy( itemArray->MdcaPoint( currItem ) ); else item.Copy( itemArray->MdcaPoint( currItem ).Ptr(), item.MaxLength() - KSelectedItemEndText().Length()); itemArray->Delete( currItem ); item.Append( KSelectedItemEndText ); itemArray->InsertL( currItem, item ); iListBox->HandleItemAdditionL(); iPrevious = aCurrent; } if( currItem != 0 ) { iListBox->ScrollToMakeItemVisible( currItem-1 ); } if( currItem != itemList->MdcaCount()-1 ) { iListBox->ScrollToMakeItemVisible( currItem+1 ); } iListBox->SetCurrentItemIndexAndDraw( currItem ); } else { /* Remove old. */ TInt prevItem = itemList->MdcaCount()-iPrevious; TBuf<KBuf256Length> item( _L("") ); item.Copy( itemArray->MdcaPoint( prevItem ) ); TInt idx = item.Find( _L("\t16") ); if( idx != KErrNotFound ){ item.SetLength( idx ); item.PtrZ(); itemArray->Delete( prevItem ); itemArray->InsertL( prevItem, item ); } iPrevious = 1; } } } TInt CItineraryContainer::GetCurrentTurn() { // Inverts the current selected item from the listbox, since the // turn list has start = 0 which is the last entry in the listbox // and the listbox's first entry is the last entry in the turn list. if (iListBox) { return iListBox->Model()->NumberOfItems() - 1 - iListBox->CurrentItemIndex(); } return 0; } void CItineraryContainer::GetDistance( TUint aDistance, TDes &aText ) { isab::DistancePrintingPolicy::DistanceMode mode = isab::DistancePrintingPolicy::DistanceMode(iView->GetDistanceMode()); char* tmp2 = isab::DistancePrintingPolicy::convertDistance(aDistance, mode, isab::DistancePrintingPolicy::Round); if (tmp2) { WFTextUtil::char2TDes(aText, tmp2); } else { aText.Copy(_L(" ")); } } // ---------------------------------------------------------------------------- // void CItineraryContainer::HandleListBoxEventL( CEikListBox*, // TListBoxEvent ) // Handles listbox event. // ---------------------------------------------------------------------------- void CItineraryContainer::HandleListBoxEventL( CEikListBox* aListBox, TListBoxEvent aEventType ) { if( aListBox == iListBox && aEventType == EEventEnterKeyPressed ){ } else if ( aListBox == iListBox && aEventType == EEventItemDoubleClicked) { //CEikonEnv::Static()->InfoMsg(_L("Double click")); } /*else if (aListBox == iListBox && aEventType == EEventItemClicked) { iView->SetCurrentTurn(iListBox->CurrentItemIndex()); }*/ } // --------------------------------------------------------- // CItineraryContainer::SizeChanged() // Called by framework when the view size is changed // --------------------------------------------------------- // void CItineraryContainer::SizeChanged() { if ( iListBox ){ iListBox->SetRect( Rect() ); // Sets rectangle of lstbox. } } // --------------------------------------------------------- // CItineraryContainer::CountComponentControls() const // --------------------------------------------------------- // TInt CItineraryContainer::CountComponentControls() const { return 1; // return nbr of controls inside this container } // --------------------------------------------------------- // CItineraryContainer::ComponentControl(TInt aIndex) const // --------------------------------------------------------- // CCoeControl* CItineraryContainer::ComponentControl(TInt aIndex) const { switch ( aIndex ) { case 0: return iListBox; default: return NULL; } } // --------------------------------------------------------- // CItineraryContainer::Draw(const TRect& aRect) const // --------------------------------------------------------- // void CItineraryContainer::Draw(const TRect& aRect) const { CWindowGc& gc = SystemGc(); // TODO: Add your drawing code here // example code... gc.SetPenStyle(CGraphicsContext::ENullPen); gc.SetBrushColor( TRgb( KBackgroundRed, KBackgroundGreen, KBackgroundBlue ) ); gc.SetBrushStyle(CGraphicsContext::ESolidBrush); gc.DrawRect(aRect); } // --------------------------------------------------------- // CItineraryContainer::HandleControlEventL( // CCoeControl* aControl,TCoeEvent aEventType) // --------------------------------------------------------- // void CItineraryContainer::HandleControlEventL( CCoeControl* /*aControl*/, TCoeEvent /*aEventType*/ ) { // TODO: Add your control event handler code here } // ---------------------------------------------------------------------------- // TKeyResponse CMyFavoritesContainer::OfferKeyEventL( const TKeyEvent&, // TEventCode ) // Handles the key events. // ---------------------------------------------------------------------------- // TKeyResponse CItineraryContainer::OfferKeyEventL( const TKeyEvent& aKeyEvent, TEventCode aType ) { if ( aType != EEventKey ){ // Is not key event? return EKeyWasNotConsumed; } switch ( aKeyEvent.iScanCode ) { // Switches tab. case EStdKeyLeftArrow: // Left key. case EStdKeyRightArrow: // Right Key. return EKeyWasNotConsumed; break; case EStdKeyUpArrow: if( iListBox->CurrentItemIndex() != 0 ) iView->UpdateCurrentTurn( ETrue ); if( iView->IsGpsAllowed()) return iListBox->OfferKeyEventL( aKeyEvent, aType ); return EKeyWasConsumed; break; case EStdKeyDownArrow: if( iListBox->CurrentItemIndex() != iListBox->Model()->NumberOfItems()-1 ) iView->UpdateCurrentTurn( EFalse ); if( iView->IsGpsAllowed()) return iListBox->OfferKeyEventL( aKeyEvent, aType ); return EKeyWasConsumed; break; // We dont want this functionality now. // case EStdKeyDevice3: // iView->HandleCommandL( EWayFinderCmdItineraryReroute ); // return EKeyWasConsumed; // break; // No hash for you, for now anyway // case EStdKeyHash: // iView->HandleCommandL( EWayFinderCmdMap ) ; // return EKeyWasConsumed; // break; } if ( iListBox ){ return iListBox->OfferKeyEventL( aKeyEvent, aType ); } else{ return EKeyWasNotConsumed; } } #ifdef NAV2_CLIENT_SERIES60_V3 void CItineraryContainer::AddToIconList(CArrayPtr<CGulIcon>* aIcons, const TDesC& aFilename, TInt aIconId, TInt aIconMaskId) { CFbsBitmap* bitmap; CFbsBitmap* mask; AknIconUtils::CreateIconL(bitmap, mask, aFilename, aIconId, aIconMaskId); // Determinate icon size // TSize iconSize; // iconSize.iWidth = iSizeOfCell.iWidth / 2; // iconSize.iHeight = iSizeOfCell.iHeight / 2; AknIconUtils::SetSize(bitmap, TSize(30,30)); //Initializes the icon to the given size. //Note that this call sets the sizes of both bitmap and mask // AknIconUtils::SetSize( iBitmap, iconSize ); // Append the icon to icon array aIcons->AppendL(CGulIcon::NewL(bitmap, mask)); } #endif void CItineraryContainer::HandleResourceChange(TInt aType) { CCoeControl::HandleResourceChange(aType); if (aType == KEikDynamicLayoutVariantSwitch) { SetRect(WFLayoutUtils::GetMainPaneRect()); iListBox->SetRect(Rect()); } } // End of File
[ [ [ 1, 683 ] ] ]
aff7dbfb583587fa87e51bc3a645733244889976
b505ef7eb1a6c58ebcb73267eaa1bad60efb1cb2
/sample/0130guitest/scrollersample.cpp
754a1fb3dbd5e188c5736ec01e9f57bee3427f00
[]
no_license
roxygen/maid2
230319e05d6d6e2f345eda4c4d9d430fae574422
455b6b57c4e08f3678948827d074385dbc6c3f58
refs/heads/master
2021-01-23T17:19:44.876818
2010-07-02T02:43:45
2010-07-02T02:43:45
38,671,921
0
0
null
null
null
null
UTF-8
C++
false
false
2,589
cpp
#include"scrollersample.h" using namespace Maid; void ScrollerSample::Initialize( Maid::GraphicsRender* r ) { m_pRender = r; m_hFont.Create( SIZE2DI(8,16), true ); } void ScrollerSample::OnInitialize( ID id, const IGUIParts& Parent ) { } void ScrollerSample::OnFinalize() { } const int BARSIZE_W = 200; const int BARSIZE_H = 10; bool ScrollerSample::IsBarCollision( const POINT2DI& pos, int len, float rad ) const { const RECT2DI rc( POINT2DI(-BARSIZE_W/2,-BARSIZE_H/2), SIZE2DI(BARSIZE_W,BARSIZE_H) ); return Collision<float>::PointRect( pos, rc, rad ); } const int BUTTONSIZE_W = 20; const int BUTTONSIZE_H = 20; bool ScrollerSample::IsButtonCollision( const POINT2DI& pos, int len, float rad ) const { const RECT2DI rc( POINT2DI(-BUTTONSIZE_W/2,-BUTTONSIZE_H/2), SIZE2DI(BUTTONSIZE_W,BUTTONSIZE_H) ); return Collision<float>::PointRect( pos, rc, rad ); } int ScrollerSample::GetBarLength() const { return BARSIZE_W; } void ScrollerSample::OnUpdateFrame() { } void ScrollerSample::OnUpdateDraw( const RenderTargetBase& Target, const IDepthStencil& Depth, const POINT2DI& pos ) { String str = MAIDTEXT("slider:"); const bool in = IsMouseIn(); const bool down = IsButtonDown(); const int vale = GetValue(); if( in ) { if( down ) { str += MAIDTEXT("押し中"); } else { str += MAIDTEXT("入った"); } }else { if( down ) { str += MAIDTEXT("押し中外"); } else { str += MAIDTEXT("通常"); } } { char buf[256]; sprintf( buf, "value:%03d", vale ); str += String::ConvertSJIStoMAID( buf ); } const float rot = GetRotate(); { const SIZE2DI barsize(BARSIZE_W,BARSIZE_H); const POINT2DI baroff(BARSIZE_W/2,BARSIZE_H/2); m_pRender->FillR( pos, COLOR_R32G32B32A32F(1,0,0,1), barsize, baroff, rot, VECTOR3DF(0,0,1) ); } { const SIZE2DI barsize(BUTTONSIZE_W,BUTTONSIZE_H); const POINT2DI baroff(BUTTONSIZE_H/2,BUTTONSIZE_H/2); const VECTOR2DI vec = CalcButtonOffset(); m_pRender->FillR( pos+vec, COLOR_R32G32B32A32F(0,1,0,1), barsize, baroff, rot, VECTOR3DF(0,0,1) ); } m_pRender->BltText( pos, m_hFont, str, COLOR_R32G32B32A32F(1,1,1,1) ); } void ScrollerSample::OnMouseMove( const POINT2DI& pos ) { } void ScrollerSample::OnMouseIn( const POINT2DI& pos ) { } void ScrollerSample::OnMouseOut( const POINT2DI& pos ) { } void ScrollerSample::OnButtonDown( const POINT2DI& pos ) { } void ScrollerSample::OnButtonUp( const POINT2DI& pos ) { }
[ [ [ 1, 115 ] ] ]
fb5a3e87e302a2ca17362b9a664e6ffd8272a8a7
27c6eed99799f8398fe4c30df2088f30ae317aff
/rtt-tool/qdoc3/cpptoqsconverter.cpp
f3bfe012a09b156e65295201f1bf74bff27661b2
[]
no_license
lit-uriy/ysoft
ae67cd174861e610f7e1519236e94ffb4d350249
6c3f077ff00c8332b162b4e82229879475fc8f97
refs/heads/master
2021-01-10T08:16:45.115964
2009-07-16T00:27:01
2009-07-16T00:27:01
51,699,806
0
0
null
null
null
null
UTF-8
C++
false
false
12,721
cpp
/**************************************************************************** ** ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). ** Contact: Qt Software Information ([email protected]) ** ** This file is part of the tools applications 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$ ** ****************************************************************************/ /* cpptoqsconverter.cpp */ #include "config.h" #include "cpptoqsconverter.h" QT_BEGIN_NAMESPACE #define CONFIG_QUICK "quick" #define CONFIG_INDENTSIZE "indentsize" void setTabSize( int size ); void setIndentSize( int size ); int columnForIndex( const QString& t, int index ); int indentForBottomLine( const QStringList& program, QChar typedIn ); static QString balancedParens = "(?:[^()]+|\\([^()]*\\))*"; QRegExp CppToQsConverter::qClassRegExp; QRegExp CppToQsConverter::addressOperatorRegExp; QRegExp CppToQsConverter::gulbrandsenRegExp; int CppToQsConverter::tabSize; ClassNode *CppToQsConverter::findClassNode( Tree *qsTree, const QString& qtName ) { ClassNode *classe = (ClassNode *) qsTree->findNode( QStringList(qtName), Node::Class ); if ( classe == 0 ) classe = (ClassNode *) qsTree->findNode( QStringList(qtName.mid(1)), Node::Class ); return classe; } QString CppToQsConverter::convertedDataType( Tree *qsTree, const QString& leftType, const QString& /* rightType */ ) { QString s = leftType; if ( s.startsWith("const ") ) s = s.mid( 6 ); while ( s.endsWith("*") || s.endsWith("&") || s.endsWith(" ") ) s.truncate( s.length() - 1 ); switch ( s[0].unicode() ) { case 'Q': if ( s == "QCString" ) { return "String"; } else { Node *node = findClassNode( qsTree, s ); if ( node == 0 ) { return ""; } else { return node->name(); } } break; case 'b': if ( s == "bool" ) return "Boolean"; break; case 'c': if ( s == "char" ) { if ( leftType == "const char *" ) { return "String"; } else { return "Number"; } } break; case 'd': if ( s == "double" ) return "Number"; break; case 'f': if ( s == "float" ) return "Number"; case 'i': if ( s == "int" ) return "Number"; break; case 'l': if ( s == "long" || s == "long int" || s == "long long" || s == "long long int" || s == "long double" ) return "Number"; break; case 's': if ( s == "short" || s == "short int" || s == "signed char" || s == "signed short" || s == "signed short int" || s == "signed" || s == "signed int" || s == "signed long" || s == "signed long int" ) return "Number"; break; case 'u': if ( s == "uchar" || s == "unsigned" || s == "unsigned char" || s == "ushort" || s == "unsigned short" || s == "unsigned short int" || s == "uint" || s == "unsigned int" || s == "ulong" || s == "unsigned long" || s == "unsigned long int" ) return "Number"; break; case 'v': if ( s == "void" ) return ""; } return s; } QString CppToQsConverter::convertedCode( Tree *qsTree, const QString& code, const QSet<QString>& classesWithNoQ ) { QString result; QStringList program; QStringList comments; int programWidth = 0; QStringList originalLines = code.split("\n"); QStringList::ConstIterator ol = originalLines.begin(); while ( ol != originalLines.end() ) { QString code = (*ol).trimmed(); QString comment; int slashSlash = code.indexOf( "//" ); if ( slashSlash != -1 ) { comment = code.mid( slashSlash ); code.truncate( slashSlash ); code = code.trimmed(); } code = convertCodeLine( qsTree, program, code, classesWithNoQ ); program.append( code ); comment = convertComment( qsTree, comment, classesWithNoQ ); comments.append( comment ); int n = indentForBottomLine( program, QChar::Null ); for ( int i = 0; i < n; i++ ) program.last().prepend( " " ); int width = columnForIndex( program.last(), program.last().length() ); if ( !comment.isEmpty() && width > programWidth ) programWidth = width; ++ol; } programWidth = ( (programWidth + (tabSize - 1) + 2) / tabSize ) * tabSize; QStringList::ConstIterator p = program.begin(); QStringList::ConstIterator c = comments.begin(); while ( c != comments.end() ) { if ( c != comments.begin() ) result += "\n"; if ( (*p).trimmed().isEmpty() ) { if ( !(*c).isEmpty() ) result += *p; } else { result += *p; if ( !(*c).isEmpty() ) { int i = columnForIndex( *p, (*p).length() ); while ( i++ < programWidth ) result += " "; } } result += *c; ++p; ++c; } return result; } void CppToQsConverter::initialize( const Config& config ) { qClassRegExp.setPattern( "\\bQ([A-Z][A-Za-z]+)\\b" ); addressOperatorRegExp.setPattern( "([(\\s])[*&]([a-zA-Z])" ); gulbrandsenRegExp.setPattern( "\\b::\\b|->" ); tabSize = config.getInt( CONFIG_TABSIZE ); setTabSize( tabSize ); int size = config.getInt( CONFIG_QUICK + Config::dot + CONFIG_INDENTSIZE ); if ( size > 0 ) setIndentSize( size ); } void CppToQsConverter::terminate() { } QString CppToQsConverter::convertCodeLine( Tree *qsTree, const QStringList& program, const QString& code, const QSet<QString>& classesWithNoQ ) { static QString dataTypeFmt = "(?!return)(?:const\\b\\s*)?[A-Za-z_]+(?:\\s*[*&])?"; static QRegExp funcPrototypeRegExp( "(" + dataTypeFmt + ")\\s*\\b([A-Z][a-zA-Z_0-9]*::)?" "([a-z][a-zA-Z_0-9]*)\\(([^);]*)(\\)?)(?:\\s*const)?" ); static QRegExp paramRegExp( "^\\s*(" + dataTypeFmt + ")\\s*\\b([a-z][a-zA-Z_0-9]*)\\s*(,)?\\s*" ); static QRegExp uninitVarRegExp( "(" + dataTypeFmt + ")\\s*\\b([a-z][a-zA-Z_0-9]*);" ); static QRegExp eqVarRegExp( dataTypeFmt + "\\s*\\b([a-z][a-zA-Z_0-9]*)\\s*=(\\s*)(.*)" ); static QRegExp ctorVarRegExp( "(" + dataTypeFmt + ")\\s*\\b([a-z][a-zA-Z_0-9]*)\\((.*)\\);" ); static QRegExp qdebugRegExp( "q(?:Debug|Warning|Fatal)\\(\\s*(\"(?:\\\\.|[^\"])*\")\\s*" "(?:,\\s*(\\S(?:[^,]*\\S)?))?\\s*\\);" ); static QRegExp coutRegExp( "c(?:out|err)\\b(.*);" ); static QRegExp lshiftRegExp( "\\s*<<\\s*" ); static QRegExp endlRegExp( "^endl$" ); if ( code.isEmpty() || code == "{" || code == "}" ) return code; QString result; if ( funcPrototypeRegExp.exactMatch(code) ) { QString returnType = funcPrototypeRegExp.cap( 1 ); QString className = funcPrototypeRegExp.cap( 2 ); QString funcName = funcPrototypeRegExp.cap( 3 ); QString params = funcPrototypeRegExp.cap( 4 ).trimmed(); bool toBeContinued = funcPrototypeRegExp.cap( 5 ).isEmpty(); // ### unused Q_UNUSED(toBeContinued); className.replace( "::", "." ); result = "function " + className + funcName + "("; if ( !params.isEmpty() && params != "void" ) { result += " "; int i = funcPrototypeRegExp.pos( 4 ); while ( (i = paramRegExp.indexIn(code, i, QRegExp::CaretAtOffset)) != -1 ) { QString dataType = paramRegExp.cap( 1 ); QString paramName = paramRegExp.cap( 2 ); QString comma = paramRegExp.cap( 3 ); result += paramName + " : " + convertedDataType( qsTree, dataType ); if ( comma.isEmpty() ) break; result += ", "; i += paramRegExp.matchedLength(); } result += " "; } result += ")"; returnType = convertedDataType( qsTree, returnType ); if ( !returnType.isEmpty() ) result += " : " + returnType; } else if ( uninitVarRegExp.exactMatch(code) ) { QString dataType = uninitVarRegExp.cap( 1 ); QString varName = uninitVarRegExp.cap( 2 ); result = "var " + varName; dataType = convertedDataType( qsTree, dataType ); if ( !dataType.isEmpty() ) result += " : " + dataType; result += ";"; } else if ( eqVarRegExp.exactMatch(code) ) { QString varName = eqVarRegExp.cap( 1 ); QString value = eqVarRegExp.cap( 3 ); value = convertExpr( qsTree, value, classesWithNoQ ); result += "var " + varName + " = " + value; } else if ( ctorVarRegExp.exactMatch(code) ) { QString dataType = ctorVarRegExp.cap( 1 ); QString varName = ctorVarRegExp.cap( 2 ); QString value = ctorVarRegExp.cap( 3 ).trimmed(); result += "var " + varName + " = "; dataType = convertedDataType( qsTree, dataType ); value = convertExpr( qsTree, value, classesWithNoQ ); if ( dataType.isEmpty() || dataType == "String" ) { if ( value.contains(",") ) { result += "..."; } else { result += value; } } else { result += "new " + dataType; if ( !value.isEmpty() ) result += "( " + value + " )"; } result += ";"; } else if ( qdebugRegExp.exactMatch(code) ) { QString fmt = qdebugRegExp.cap( 1 ); QString arg1 = qdebugRegExp.cap( 2 ); result += "println "; int i = 0; while ( i < (int) fmt.length() ) { if ( fmt[i] == '%' ) { int percent = i; i++; while ( i < (int) fmt.length() && QString("diouxXeEfFgGaAcsCSpn%\"").indexOf(fmt[i]) == -1 ) i++; if ( fmt[i] == '%' ) { result += fmt[i++]; } else if ( fmt[i] != '"' ) { if ( percent == 1 ) { result.truncate( result.length() - 1 ); } else { result += "\" + "; } i++; if ( arg1.endsWith(".latin1()") ) arg1.truncate( arg1.length() - 9 ); result += arg1; if ( i == (int) fmt.length() - 1 ) { i++; } else { result += " + \""; } } } else { result += fmt[i++]; } } result += ";"; } else if ( coutRegExp.exactMatch(code) && program.filter("var cout").isEmpty() ) { QStringList args = coutRegExp.cap(1).split(lshiftRegExp); args.replaceInStrings( endlRegExp, "\"\\n\"" ); if ( args.last() == "\"\\n\"" ) { args.erase( args.end() - 1 ); if ( args.isEmpty() ) args << "\"\""; result += "println "; } else { result += "print "; } result += args.join( " + " ) + ";"; } else { result = convertExpr( qsTree, code, classesWithNoQ ); } return result; } QString CppToQsConverter::convertComment( Tree * /* qsTree */, const QString& comment, const QSet<QString>& classesWithNoQ ) { QString result = comment; result.replace( "TRUE", "true" ); result.replace( "FALSE", "false" ); result.replace( addressOperatorRegExp, "\\1\\2" ); result.replace( gulbrandsenRegExp, "." ); int i = 0; while ( (i = result.indexOf(qClassRegExp, i)) != -1 ) { if ( classesWithNoQ.contains(qClassRegExp.cap(1)) ) result.remove( i, 1 ); i++; } return result; } QString CppToQsConverter::convertExpr( Tree *qsTree, const QString& expr, const QSet<QString>& classesWithNoQ ) { // suboptimal return convertComment( qsTree, expr, classesWithNoQ ); } QT_END_NAMESPACE
[ "lit-uriy@d7ba3245-3e7b-42d0-9cd4-356c8b94b330" ]
[ [ [ 1, 415 ] ] ]
bb53538c915aa14e010abf89c61a9e013c2bce0e
5a9924aff39460fa52f1f55ff387d9ab82c3470f
/tibia80/levelspy80/levelspy/levelspy.cpp
2b6e993b12dccffee90c67897cb22c659f0ef7db
[]
no_license
PimentelM/evremonde
170e4f1916b0a1007c6dbe52b578db53bc6e70de
6b56e8461a602ea56f0eae47a96d340487ba987d
refs/heads/master
2021-01-10T16:03:38.410644
2010-12-04T17:31:01
2010-12-04T17:31:01
48,460,569
0
1
null
null
null
null
UTF-8
C++
false
false
6,984
cpp
#include <sstream> #include <windows.h> #include "levelspy.h" #include "tibia.h" /* Level Spy by Evremonde for Tibia 8.0 */ // tibia class CTibia Tibia; /* toggle */ // toggle level spying void toggleLevelSpy() { // check if already enabled if (!Tibia.isLevelSpyEnabled()) { // enable level spying Tibia.setLevelSpy(true); // set statusbar Tibia.setStatusbar("Level Spy: On"); } else { // disable level spying Tibia.setLevelSpy(false); // set statusbar Tibia.setStatusbar("Level Spy: Off"); } } // toggle name spying void toggleNameSpy() { // check if already enabled if (!Tibia.isNameSpyEnabled()) { // enable name spying Tibia.setNameSpy(true); // set statusbar Tibia.setStatusbar("Name Spy: On"); } else { // disable name spying Tibia.setNameSpy(false); // set statusbar Tibia.setStatusbar("Name Spy: Off"); } } /* do */ void doLevelSpyUp() { // level spy must be enabled if (Tibia.isLevelSpyEnabled()) { // increase spy level Tibia.doLevelSpyUp(); // set statusbar Tibia.setStatusbar("Level Spy: Up"); } else { // note Tibia.setStatusbar("Please enable Level Spy first!"); } } void doLevelSpyDown() { // level spy must be enabled if (Tibia.isLevelSpyEnabled()) { // decrease spy level Tibia.doLevelSpyDown(); // set statusbar Tibia.setStatusbar("Level Spy: Down"); } else { // note Tibia.setStatusbar("Please enable Level Spy first!"); } } /* timer */ // hotkeys void timerHotkeys(HWND hwnd) { // restrict hotkeys to tibia and level spy by window focus HWND currentWindow = ::GetForegroundWindow(); HWND tibiaWindow = Tibia.getTibiaWindow(); if (currentWindow != tibiaWindow && currentWindow != hwnd) return; // increase spy level if (::GetAsyncKeyState(VK_PRIOR)) // page up { doLevelSpyUp(); Sleep(100); // wait } // decrease spy level if (::GetAsyncKeyState(VK_NEXT)) // page down { doLevelSpyDown(); Sleep(100); // wait } // toggle level spying if (::GetAsyncKeyState(VK_END)) // end { toggleLevelSpy(); Sleep(100); // wait } // toggle name spying if (::GetAsyncKeyState(VK_HOME)) // home { toggleNameSpy(); Sleep(100); // wait } } /* windows messages */ void onCreate(HWND hwnd) { // initialize timers ::SetTimer(hwnd, TMR_HOTKEYS, 10, 0); // speed is 10 milliseconds // loaded Tibia.setStatusbar("Level Spy for Tibia 8.0 loaded!"); } void onDestroy(HWND hwnd) { // disable level spying Tibia.setLevelSpy(false); // disable name spying Tibia.setNameSpy(false); // exit PostQuitMessage(0); } void onPaint(HWND hwnd) { // set drawing area RECT rect; rect.top = 10; // small margin rect.left = 10; // small margin rect.bottom = WINDOW_HEIGHT; rect.right = WINDOW_WIDTH; // begin paint HDC hdc; PAINTSTRUCT ps; hdc = ::BeginPaint(hwnd, &ps); // set text to windows font HFONT hfont = static_cast<HFONT>(::GetStockObject(ANSI_VAR_FONT)); ::SelectObject(hdc, hfont); // draw text on transparent background ::SetBkMode(hdc, TRANSPARENT); // level spy text std::stringstream buffer; buffer << "Level for Tibia 8.0" << std::endl << "by Evremonde" << std::endl << "Last updated on November 19th, 2007" << std::endl << std::endl << "Homepage:" << std::endl << "http://code.google.com/p/evremonde/" << std::endl << std::endl << "Hotkeys:" << std::endl << "Page Up\t\tLevel spy up" << std::endl << "Page Down\t\tLevel spy down" << std::endl << "End\t\t\t\tToggle level spy on/off" << std::endl << "Home\t\t\tToggle name spy on/off"; // draw the text DRAWTEXTPARAMS dtp; dtp.cbSize = sizeof(DRAWTEXTPARAMS); dtp.iLeftMargin = 0; dtp.iRightMargin = 0; dtp.iTabLength = 4; ::DrawTextEx( hdc, (char*)buffer.str().c_str(), -1, &rect, DT_TABSTOP | DT_EXPANDTABS, &dtp); //end paint ::EndPaint(hwnd, &ps); } void onTimer(HWND hwnd, WPARAM wParam, LPARAM lParam) { switch (wParam) { // hotkeys case TMR_HOTKEYS: timerHotkeys(hwnd); break; } } /* window messages handler */ LRESULT CALLBACK windowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { switch (msg) { case WM_CREATE: onCreate(hwnd); break; case WM_CLOSE: ::DestroyWindow(hwnd); break; case WM_DESTROY: onDestroy(hwnd); break; case WM_PAINT: onPaint(hwnd); case WM_TIMER: onTimer(hwnd, wParam, lParam); break; default: return ::DefWindowProc(hwnd, msg, wParam, lParam); } return 0; } /* main function */ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) { // find tibia window if (!Tibia.findTibia()) { ::MessageBox(0, "Tibia window not found!", "Error", MB_ICONERROR | MB_OK); return 0; // exit } // register window class WNDCLASSEX wc; wc.cbSize = sizeof(WNDCLASSEX); wc.style = 0; wc.lpfnWndProc = windowProc; // window messages handler wc.cbClsExtra = 0; wc.cbWndExtra = 0; wc.hInstance = hInstance; wc.hIcon = 0; wc.hCursor = ::LoadCursor(0, IDC_ARROW); wc.hbrBackground = static_cast<HBRUSH>(::CreateSolidBrush(RGB(236, 233, 216))); // window background color wc.lpszMenuName = 0; wc.lpszClassName = "levelspy"; wc.hIconSm = 0; if(!::RegisterClassEx(&wc)) { ::MessageBox(0, "Register Window Class failed!", "Error", MB_ICONERROR | MB_OK); return 0; // exit } // create window HWND hwnd; hwnd = ::CreateWindowEx( WS_EX_DLGMODALFRAME, //WS_EX_WINDOWEDGE, // icon "levelspy", "Level Spy - Tibia 8.0", // title WS_CAPTION | WS_MINIMIZEBOX | WS_SYSMENU, // window options CW_USEDEFAULT, CW_USEDEFAULT, WINDOW_WIDTH, WINDOW_HEIGHT, // window dimensions 0, 0, hInstance, 0); if(hwnd == 0) { ::MessageBox(0, "Create Window failed!", "Error", MB_ICONERROR | MB_OK); return 0; } // center window HWND desktopWindow = ::GetDesktopWindow(); RECT desktopRect; ::GetWindowRect(desktopWindow, &desktopRect); RECT hwndRect; ::GetWindowRect(hwnd, &hwndRect); hwndRect.left = desktopRect.left + ((desktopRect.right - desktopRect.left) - (hwndRect.right - hwndRect.left)) / 2; hwndRect.top = desktopRect.top + ((desktopRect.bottom - desktopRect.top) - (hwndRect.bottom - hwndRect.top)) / 2; ::SetWindowPos(hwnd, 0, hwndRect.left, hwndRect.top, 0, 0, SWP_NOACTIVATE | SWP_NOZORDER | SWP_NOSIZE); // show window ::ShowWindow(hwnd, nCmdShow); ::UpdateWindow(hwnd); // message loop MSG msg; while(::GetMessage(&msg, 0, 0, 0) > 0) { ::TranslateMessage(&msg); ::DispatchMessage(&msg); } return msg.wParam; }
[ "evretibia@cc901e99-3b3f-0410-afbc-77a0fa429cc7" ]
[ [ [ 1, 335 ] ] ]
a729477f7219be5867e99807d7ba31651df63c2b
5ac13fa1746046451f1989b5b8734f40d6445322
/minimangalore/Nebula2/code/mangalore/msg/gfxsetanimation.cc
2703abdc7cb29a43df407d7a4f509a291013a428
[]
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
439
cc
//------------------------------------------------------------------------------ // msg/gfxsetanimation.cc // (C) 2005 Radon Labs GmbH //------------------------------------------------------------------------------ #include "msg/gfxsetanimation.h" namespace Message { ImplementRtti(Message::GfxSetAnimation, Message::Msg); ImplementFactory(Message::GfxSetAnimation); ImplementMsgId(GfxSetAnimation); } // namespace Message
[ "BawooiT@d1c0eb94-fc07-11dd-a7be-4b3ef3b0700c" ]
[ [ [ 1, 12 ] ] ]
0fa7a724b8f787b4ee23d8d9a79f2e569dfacd45
fb8a3d68c676c977b9b6d3389debd785c2f25634
/Math/Include/Matrix.hpp
f3c1e5bd69e5fc50062709a1fb78a526a1733993
[]
no_license
skevy/CSC-350-Assignment2
ef1a1e5fae8c9b9ab4ca2b97390974751ad1dedb
98811d2cbbc221af9cc9aa601a990e7969920f7e
refs/heads/master
2021-01-01T20:35:26.246966
2011-02-17T01:57:03
2011-02-17T01:57:03
1,376,632
0
0
null
null
null
null
UTF-8
C++
false
false
3,308
hpp
//***************************************************************************// // Matrix Class Interface // // Created: April 6, 2007 // By: Jeremy M Miller // // Copyright (c) 2007 Jeremy M Miller. All rights reserved. // This source code module, and all information, data, and algorithms // associated with it, are part of BlueHabu technology (tm). // PROPRIETARY // Creative Commons Licensees are subject to the license found at // http://creativecommons.org/licenses/by-nc-nd/3.0/ // Other licensing options may be available. Contact [email protected]. //***************************************************************************// #ifndef HABU_MATH_MATRIX_HPP #define HABU_MATH_MATRIX_HPP #include "Vector.hpp" //#define LEFT_HAND //***************************************************************************// namespace HabuTech { //*************************************************************************// template <class T, unsigned char D> class Matrix { private: //***********************************************************************// Vector<T, D> mtMatrix[D]; //***********************************************************************// public: //***********************************************************************// //-----------------------------------------------------------------------// Matrix() { this->Identity(); } ~Matrix() {} //-----------------------------------------------------------------------// //-----------------------------------------------------------------------// // TODO Implement See Page 86 in Linear Algebra Book T Determinate() const; void Identity(); void Zero(); // TODO Test these void RotateAboutX(T& rtAngle); void RotateAboutY(T& rtAngle); void RotateAboutZ(T& rtAngle); void RotateAboutAxis(Vector<T, D>& rtAxis, T& rtAngle); // TODO Test these void Translate(T& rtX, T& rtY, T& rtZ); void Translate(Vector<T, D>& rtVector); // TODO Implement void Transpose(); void Perspective(T tVerticalFOV, T tAspect, T tNearClipPlane, T tFarClipPlane); void ColumnMajor(T pArray[D * D]) const; void RowMajor(T pArray[D * D]) const; //-----------------------------------------------------------------------// //-----------------------------------------------------------------------// T operator()(unsigned char ucRow, unsigned char ucColumn) const; Vector<T, D>& operator[](unsigned char ucRow); Matrix<T, D> operator*(const Matrix<T, D>& rhs) const; // Matrix Multiplication Matrix<T, D> operator*(const T& rhs) const; // Scalar Multiplication Matrix<T, D> operator+(const Matrix<T, D>& rhs) const; // Matrix Addition Matrix<T, D> operator-(const Matrix<T, D>& rhs) const; // Matrix Subtraction //-----------------------------------------------------------------------// //***********************************************************************// }; // End of class Matrix //*************************************************************************// } // End of namespace HabuTech //***************************************************************************// #endif HABU_MATH_MATRIX_HPP
[ [ [ 1, 81 ] ] ]
b2567092bc2c7f9a30fae0299ed5b2408875c1a8
fac8de123987842827a68da1b580f1361926ab67
/inc/math/HMVector3_64.h
3380dbeab04a7cd12d037f1c025c29200f7647ea
[]
no_license
blockspacer/transporter-game
23496e1651b3c19f6727712a5652f8e49c45c076
083ae2ee48fcab2c7d8a68670a71be4d09954428
refs/heads/master
2021-05-31T04:06:07.101459
2009-02-19T20:59:59
2009-02-19T20:59:59
null
0
0
null
null
null
null
SHIFT_JIS
C++
false
false
14,863
h
#ifndef HMVECTOR3_64_H #define HMVECTOR3_64_H #include "math/HMath.h" namespace hmath { class v3_64 { public : union { struct { f64 x; f64 y; f64 z; }; f64 val[3]; }; inline v3_64(){}; inline v3_64( const f64 fX, const f64 fY, const f64 fZ ); inline explicit v3_64( const i32 fX, const i32 fY, const i32 fZ ); inline explicit v3_64( const f64 vec[3] ); inline explicit v3_64( const i32 vec[3] ); inline explicit v3_64( f64* const r ); inline explicit v3_64( const f64 scaler ); inline v3_64( const v3_64& vec ); inline f64 operator [] ( const size_t i ) const; inline f64& operator [] ( const size_t i ); inline v3_64& operator = ( const v3_64& vec ); inline v3_64& operator = ( const f64 scaler ); inline bit operator == ( const v3_64& vec ) const; inline bit operator != ( const v3_64& vec ) const; inline v3_64 operator + ( const v3_64& vec ) const; inline v3_64 operator - ( const v3_64& vec ) const; inline v3_64 operator * ( const f64 scalar ) const; inline v3_64 operator * ( const v3_64& rhs) const; inline v3_64 operator / ( const f64 scalar ) const; inline v3_64 operator / ( const v3_64& rhs) const; inline v3_64 operator - () const; inline v3_64 operator + () const; inline v3_64& operator += ( const v3_64& vec ); inline v3_64& operator += ( const f64 scalar ); inline v3_64& operator -= ( const v3_64& vec ); inline v3_64& operator -= ( const f64 scalar ); inline v3_64& operator *= ( const f64 scalar ); inline v3_64& operator *= ( const v3_64& vec ); inline v3_64& operator /= ( const f64 scalar ); inline v3_64& operator /= ( const v3_64& vec ); inline bit operator < ( const v3_64& rhs ) const; inline bit operator > ( const v3_64& rhs ) const; inline f64 len () const; inline f64 sqlen () const; inline f64 dot(const v3_64& vec) const; inline f64 norm(); inline v3_64 cross( const v3_64& vec ) const; inline v3_64 reflect(const v3_64& normal) const; inline bit iszerolen(void) const; inline v3_64 up(void) const; inline v3_64 mid( const v3_64& vec ) const; inline void floor( const v3_64& cmp ); inline void ceil( const v3_64& cmp ); static const v3_64 zero; static const v3_64 unitX; static const v3_64 unitY; static const v3_64 unitZ; static const v3_64 neg_unitX; static const v3_64 neg_unitY; static const v3_64 neg_unitZ; static const v3_64 unit; quat getRotationTo(const v3_64& dest, const v3_64& fallbackAxis = v3_64::zero) const; }; //覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧 v3_64::v3_64( const f64 fX, const f64 fY, const f64 fZ ) : x( fX ), y( fY ), z( fZ ) { } //覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧 v3_64::v3_64( const i32 fX, const i32 fY, const i32 fZ ) { x = f64(fX); y = f64(fY); z = f64(fZ); } //覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧 v3_64::v3_64( const f64 vec[3] ) : x( vec[0] ), y( vec[1] ), z( vec[2] ) { } //覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧 v3_64::v3_64( const i32 vec[3] ) { x = (f64)vec[0]; y = (f64)vec[1]; z = (f64)vec[2]; } //覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧 v3_64::v3_64( f64* const r ) : x( r[0] ), y( r[1] ), z( r[2] ) { } //覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧 v3_64::v3_64( const f64 scaler ) : x( scaler ), y( scaler ), z( scaler ) { } //覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧 v3_64::v3_64( const v3_64& vec ) : x( vec.x ), y( vec.y ), z( vec.z ) { } //覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧 f64 v3_64::operator [] ( const size_t i ) const { // assert( i < 3 ); return *(&x+i); } //覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧 f64& v3_64::operator [] ( const size_t i ) { // assert( i < 3 ); return *(&x+i); } //覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧 v3_64& v3_64::operator = ( const v3_64& vec ) { x = vec.x; y = vec.y; z = vec.z; return *this; } //覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧 v3_64& v3_64::operator = ( const f64 scaler ) { x = scaler; y = scaler; z = scaler; return *this; } //覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧 bit v3_64::operator == ( const v3_64& vec ) const { return ( x == vec.x && y == vec.y && z == vec.z ); } //覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧 bit v3_64::operator != ( const v3_64& vec ) const { return ( x != vec.x || y != vec.y || z != vec.z ); } //覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧 v3_64 v3_64::operator + ( const v3_64& vec ) const { return v3_64(x + vec.x,y + vec.y,z + vec.z); } //覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧 v3_64 v3_64::operator - ( const v3_64& vec ) const { return v3_64(x - vec.x,y - vec.y,z - vec.z); } //覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧 v3_64 v3_64::operator * ( const f64 scalar ) const { return v3_64(x * scalar,y * scalar,z * scalar); } //覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧 v3_64 v3_64::operator * ( const v3_64& rhs) const { return v3_64(x * rhs.x,y * rhs.y, z * rhs.z); } //覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧 v3_64 v3_64::operator / ( const f64 scalar ) const { assert( scalar != 0.0 ); f64 fInv = f64(1.0) / scalar; return v3_64( x * fInv,y * fInv,z * fInv); } //覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧 v3_64 v3_64::operator / ( const v3_64& rhs) const { return v3_64(x / rhs.x, y / rhs.y, z / rhs.z); } //覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧 v3_64 v3_64::operator + () const { return *this; } //覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧 v3_64 v3_64::operator - () const { return v3_64(-x, -y, -z); } //覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧 static v3_64 operator * ( const f64 scalar, const v3_64& vec ) { return v3_64( scalar * vec.x, scalar * vec.y, scalar * vec.z); } //覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧 static v3_64 operator + (const v3_64& lhs, const f64 rhs) { return v3_64( lhs.x + rhs, lhs.y + rhs, lhs.z + rhs); } //覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧 static v3_64 operator + (const f64 lhs, const v3_64& rhs) { return v3_64( lhs + rhs.x, lhs + rhs.y,lhs + rhs.z); } //覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧 static v3_64 operator - (const v3_64& lhs, const f64 rhs) { return v3_64( lhs.x - rhs, lhs.y - rhs, lhs.z - rhs); } //覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧 static v3_64 operator - (const f64 lhs, const v3_64& rhs) { return v3_64(lhs - rhs.x,lhs - rhs.y,lhs - rhs.z); } //覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧 v3_64& v3_64::operator += ( const v3_64& vec ) { x += vec.x; y += vec.y; z += vec.z; return *this; } //覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧 v3_64& v3_64::operator += ( const f64 scalar ) { x += scalar; y += scalar; z += scalar; return *this; } //覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧 v3_64& v3_64::operator -= ( const v3_64& vec ) { x -= vec.x; y -= vec.y; z -= vec.z; return *this; } //覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧 v3_64& v3_64::operator -= ( const f64 scalar ) { x -= scalar; y -= scalar; z -= scalar; return *this; } //覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧 v3_64& v3_64::operator *= ( const f64 scalar ) { x *= scalar; y *= scalar; z *= scalar; return *this; } //覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧 v3_64& v3_64::operator *= ( const v3_64& vec ) { x *= vec.x; y *= vec.y; z *= vec.z; return *this; } //覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧 v3_64& v3_64::operator /= ( const f64 scalar ) { assert( scalar != 0.0 ); f64 fInv = f64(1.0) / scalar; x *= fInv; y *= fInv; z *= fInv; return *this; } //覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧 v3_64& v3_64::operator /= ( const v3_64& vec ) { x /= vec.x; y /= vec.y; z /= vec.z; return *this; } //覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧 bit v3_64::operator < ( const v3_64& rhs ) const { if( x < rhs.x && y < rhs.y && z < rhs.z ) return true; return false; } //覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧 bit v3_64::operator > ( const v3_64& rhs ) const { if( x > rhs.x && y > rhs.y && z > rhs.z ) return true; return false; } //覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧 f64 v3_64::len () const { return sqrt( x * x + y * y + z * z ); } //覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧 f64 v3_64::sqlen () const { return x * x + y * y + z * z; } //覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧 f64 v3_64::dot(const v3_64& vec) const { return x * vec.x + y * vec.y + z * vec.z; } //覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧 f64 v3_64::norm() { f64 fLength = len(); if ( fLength > 1e-08 ) { f64 fInvLength = f64(1.0) / fLength; x *= fInvLength; y *= fInvLength; z *= fInvLength; } return fLength; } //覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧 v3_64 v3_64::cross( const v3_64& vec ) const { return v3_64( y * vec.z - z * vec.y, z * vec.x - x * vec.z, x * vec.y - y * vec.x); } //覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧 v3_64 v3_64::reflect(const v3_64& normal) const { return v3_64( *this - ( 2 * this->dot(normal) * normal ) ); } //覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧 bit v3_64::iszerolen(void) const { f64 sqlen = (x * x) + (y * y) + (z * z); return (sqlen < (1e-06 * 1e-06)); } //覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧 v3_64 v3_64::up(void) const { static const f64 fSquareZero = f64(1e-06 * 1e-06); v3_64 perp = this->cross( v3_64::unitX ); if( perp.sqlen() < fSquareZero ) { perp = this->cross( v3_64::unitY ); } return perp; } //覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧 v3_64 v3_64::mid( const v3_64& vec ) const { return v3_64( ( x + vec.x ) * f64(0.5), ( y + vec.y ) * f64(0.5), ( z + vec.z ) * f64(0.5) ); } //覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧 void v3_64::floor( const v3_64& cmp ) { if( cmp.x < x ) x = cmp.x; if( cmp.y < y ) y = cmp.y; if( cmp.z < z ) z = cmp.z; } //覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧 void v3_64::ceil( const v3_64& cmp ) { if( cmp.x > x ) x = cmp.x; if( cmp.y > y ) y = cmp.y; if( cmp.z > z ) z = cmp.z; } } #endif
[ "uraymeiviar@bb790a93-564d-0410-8b31-212e73dc95e4" ]
[ [ [ 1, 492 ] ] ]
61e27c77f708de130f66125c9f2211469e707542
3472e587cd1dff88c7a75ae2d5e1b1a353962d78
/test/TestQt/ui_mainwindow.h
ea960f7ac88355125b6de37e423a52150c5280ed
[]
no_license
yewberry/yewtic
9624d05d65e71c78ddfb7bd586845e107b9a1126
2468669485b9f049d7498470c33a096e6accc540
refs/heads/master
2021-01-01T05:40:57.757112
2011-09-14T12:32:15
2011-09-14T12:32:15
32,363,059
0
0
null
null
null
null
UTF-8
C++
false
false
6,751
h
/******************************************************************************** ** Form generated from reading UI file 'mainwindow.ui' ** ** Created: Wed Sep 14 10:23:07 2011 ** by: Qt User Interface Compiler version 4.7.3 ** ** WARNING! All changes made in this file will be lost when recompiling UI file! ********************************************************************************/ #ifndef UI_MAINWINDOW_H #define UI_MAINWINDOW_H #include <QtCore/QVariant> #include <QtGui/QAction> #include <QtGui/QApplication> #include <QtGui/QButtonGroup> #include <QtGui/QGroupBox> #include <QtGui/QHeaderView> #include <QtGui/QMainWindow> #include <QtGui/QMenu> #include <QtGui/QMenuBar> #include <QtGui/QStatusBar> #include <QtGui/QToolBar> #include <QtGui/QWidget> QT_BEGIN_NAMESPACE class Ui_MainWindow { public: QAction *action_New; QAction *action_Save; QAction *actionFile_one; QAction *actionFile_two; QAction *actionFile_three; QAction *action_About; QWidget *centralwidget; QGroupBox *myGroupBox; QMenuBar *menubar; QMenu *menu_File; QMenu *menuOpen_recetly; QMenu *menu_Edit; QMenu *menu_Help; QStatusBar *statusbar; QToolBar *toolBar; void setupUi(QMainWindow *MainWindow) { if (MainWindow->objectName().isEmpty()) MainWindow->setObjectName(QString::fromUtf8("MainWindow")); MainWindow->resize(447, 269); action_New = new QAction(MainWindow); action_New->setObjectName(QString::fromUtf8("action_New")); QIcon icon; icon.addFile(QString::fromUtf8(":/images/new.png"), QSize(), QIcon::Normal, QIcon::Off); action_New->setIcon(icon); action_Save = new QAction(MainWindow); action_Save->setObjectName(QString::fromUtf8("action_Save")); QIcon icon1; icon1.addFile(QString::fromUtf8(":/images/save.png"), QSize(), QIcon::Normal, QIcon::Off); action_Save->setIcon(icon1); actionFile_one = new QAction(MainWindow); actionFile_one->setObjectName(QString::fromUtf8("actionFile_one")); actionFile_two = new QAction(MainWindow); actionFile_two->setObjectName(QString::fromUtf8("actionFile_two")); actionFile_three = new QAction(MainWindow); actionFile_three->setObjectName(QString::fromUtf8("actionFile_three")); action_About = new QAction(MainWindow); action_About->setObjectName(QString::fromUtf8("action_About")); QIcon icon2; icon2.addFile(QString::fromUtf8(":/images/gotocell.png"), QSize(), QIcon::Normal, QIcon::Off); action_About->setIcon(icon2); centralwidget = new QWidget(MainWindow); centralwidget->setObjectName(QString::fromUtf8("centralwidget")); myGroupBox = new QGroupBox(centralwidget); myGroupBox->setObjectName(QString::fromUtf8("myGroupBox")); myGroupBox->setGeometry(QRect(260, 40, 120, 80)); MainWindow->setCentralWidget(centralwidget); menubar = new QMenuBar(MainWindow); menubar->setObjectName(QString::fromUtf8("menubar")); menubar->setGeometry(QRect(0, 0, 447, 18)); menu_File = new QMenu(menubar); menu_File->setObjectName(QString::fromUtf8("menu_File")); menuOpen_recetly = new QMenu(menu_File); menuOpen_recetly->setObjectName(QString::fromUtf8("menuOpen_recetly")); menu_Edit = new QMenu(menubar); menu_Edit->setObjectName(QString::fromUtf8("menu_Edit")); menu_Help = new QMenu(menubar); menu_Help->setObjectName(QString::fromUtf8("menu_Help")); MainWindow->setMenuBar(menubar); statusbar = new QStatusBar(MainWindow); statusbar->setObjectName(QString::fromUtf8("statusbar")); MainWindow->setStatusBar(statusbar); toolBar = new QToolBar(MainWindow); toolBar->setObjectName(QString::fromUtf8("toolBar")); MainWindow->addToolBar(Qt::TopToolBarArea, toolBar); menubar->addAction(menu_File->menuAction()); menubar->addAction(menu_Edit->menuAction()); menubar->addAction(menu_Help->menuAction()); menu_File->addAction(action_New); menu_File->addAction(action_Save); menu_File->addSeparator(); menu_File->addAction(menuOpen_recetly->menuAction()); menuOpen_recetly->addAction(actionFile_one); menuOpen_recetly->addAction(actionFile_two); menuOpen_recetly->addAction(actionFile_three); menu_Help->addAction(action_About); toolBar->addAction(action_New); toolBar->addAction(action_Save); toolBar->addSeparator(); retranslateUi(MainWindow); QMetaObject::connectSlotsByName(MainWindow); } // setupUi void retranslateUi(QMainWindow *MainWindow) { MainWindow->setWindowTitle(QApplication::translate("MainWindow", "MainWindow", 0, QApplication::UnicodeUTF8)); action_New->setText(QApplication::translate("MainWindow", "&New", 0, QApplication::UnicodeUTF8)); action_New->setShortcut(QApplication::translate("MainWindow", "Ctrl+N", 0, QApplication::UnicodeUTF8)); action_Save->setText(QApplication::translate("MainWindow", "&Save", 0, QApplication::UnicodeUTF8)); action_Save->setShortcut(QApplication::translate("MainWindow", "Ctrl+S", 0, QApplication::UnicodeUTF8)); actionFile_one->setText(QApplication::translate("MainWindow", "file one", 0, QApplication::UnicodeUTF8)); actionFile_two->setText(QApplication::translate("MainWindow", "file two", 0, QApplication::UnicodeUTF8)); actionFile_three->setText(QApplication::translate("MainWindow", "file three", 0, QApplication::UnicodeUTF8)); action_About->setText(QApplication::translate("MainWindow", "&About", 0, QApplication::UnicodeUTF8)); myGroupBox->setTitle(QApplication::translate("MainWindow", "GroupBox", 0, QApplication::UnicodeUTF8)); menu_File->setTitle(QApplication::translate("MainWindow", "&File", 0, QApplication::UnicodeUTF8)); menuOpen_recetly->setTitle(QApplication::translate("MainWindow", "Open recetly", 0, QApplication::UnicodeUTF8)); menu_Edit->setTitle(QApplication::translate("MainWindow", "&Edit", 0, QApplication::UnicodeUTF8)); menu_Help->setTitle(QApplication::translate("MainWindow", "&Help", 0, QApplication::UnicodeUTF8)); toolBar->setWindowTitle(QApplication::translate("MainWindow", "toolBar", 0, QApplication::UnicodeUTF8)); } // retranslateUi }; namespace Ui { class MainWindow: public Ui_MainWindow {}; } // namespace Ui QT_END_NAMESPACE #endif // UI_MAINWINDOW_H
[ "yew1998@5ddc4e96-dffd-11de-b4b3-6d349e4f6f86" ]
[ [ [ 1, 145 ] ] ]
c5f62593160947e7389af5c33dcc32d8ca265393
ae239aeeb8dcf7212d432791b959ef709888f99a
/v1.0/GameLoader.h
96c86346287d7ea009e6c0986d8578af359547d1
[]
no_license
arunaupul/merrimack-college-csc4910-sp2010
6a9fff2280494048997728b36a214271a2a8f8fc
a77d9fbb00538c98b7d61a61e91854e2dee1e748
refs/heads/master
2016-08-07T19:18:11.144431
2010-05-04T23:44:38
2010-05-04T23:44:38
35,337,837
0
0
null
null
null
null
UTF-8
C++
false
false
465
h
#ifndef _GAME_LOADER_H_ #define _GAME_LOADER_H_ #include <list> #include <string> #include "WorldObject.h" #include "LevelObject.h" #include "GameStructs.h" namespace GameLoader { bool RunLoader( const std::wstring & worldsFileName , std::list<WorldObject *> & list , GameDude * dude ); bool LoadLevel( const std::wstring & levelFileName , LevelObject * level ); Square GameGridToCoords( double x , double y ); }; #endif /* _GAME_LOADER_H_ */
[ "rfleming71@06d672e2-d70c-11de-b7b1-656321ec08b8" ]
[ [ [ 1, 17 ] ] ]
9729827bf727eb25586268f50536fdf82bb10df5
43626054205d6048ec98c76db5641ce8e42b8237
/source/WinMain.cpp
9f6a8cc27c0b9f8a34a3c8a7b6780f3b54b9b4d0
[]
no_license
Wazoobi/whitewings
b700da98b855a64442ad7b7c4b0be23427b0ee23
a53fdb832cfb1ce8605209c9af47f36b01c44727
refs/heads/master
2021-01-10T19:33:22.924792
2009-08-05T18:30:07
2009-08-05T18:30:07
32,119,981
0
0
null
null
null
null
UTF-8
C++
false
false
7,695
cpp
////////////////////////////////////////////////////////////////////////////////////////////// // File : "WinMain.cpp" // // Author : David Brown (DB) // Based in part on: // -Window code from the book: "Physics for Game Developers" by David M. Bourg. // -The previous WinMain.cpp by Jensen Rivera. // // Last Modified : 3/31/2009 // // Purpose : To provide a basic window framework for student games. // ////////////////////////////////////////////////////////////////////////////////////////////// #include <windows.h> // Needed for Windows Applications. #include "CGame.h" #include <ctime> #include <vld.h> const char* g_szWINDOW_CLASS_NAME = "WhiteWingsWindowClass"; // Window Class Name. const char* g_szWINDOW_TITLE = "Ping Attack"; // Window Title. const int g_nWINDOW_WIDTH = 800; // Window Width. const int g_nWINDOW_HEIGHT = 600; // Window Height. // Windowed or Full screen depending on project setting #ifdef _DEBUG const BOOL g_bIS_WINDOWED = TRUE; #else const BOOL g_bIS_WINDOWED = FALSE; #endif LRESULT CALLBACK WindowProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) { // This is the main message handler of the system. PAINTSTRUCT ps; // Used in WM_PAINT. HDC hdc; // Handle to a device context. // What is the message switch(msg) { // To skip ALT pop up menu (system menu) case WM_SYSKEYUP: case WM_SYSCHAR: return(0); break; // Handle ALT+F4 case WM_CLOSE: { // Sends us a WM_DESTROY DestroyWindow(hWnd); } break; // and lose/gain focus case WM_ACTIVATE: { // gaining focus if (LOWORD(wParam) != WA_INACTIVE) { // unpause game code here } else // losing focus { // pause game code here } } break; case WM_CREATE: { // Do initialization here return(0); } break; case WM_PAINT: { // Start painting hdc = BeginPaint(hWnd,&ps); // End painting EndPaint(hWnd,&ps); return(0); } break; case WM_DESTROY: { // Kill the application PostQuitMessage(0); return(0); } break; default: break; } // Process any messages that we didn't take care of return (DefWindowProc(hWnd, msg, wParam, lParam)); } // Checks to see if the game was already running in another window. // // NOTE: Don't call this function if your game needs to have more // than one instance running on the same computer (i.e. client/server) BOOL CheckIfAlreadyRunning(void) { // Find a window of the same window class name and window title HWND hWnd = FindWindow(g_szWINDOW_CLASS_NAME, g_szWINDOW_TITLE); // If one was found if (hWnd) { // If it was minimized if (IsIconic(hWnd)) // restore it ShowWindow(hWnd, SW_RESTORE); // Bring it to the front SetForegroundWindow(hWnd); return TRUE; } // No other copies found running return FALSE; } BOOL RegisterWindowClass(HINSTANCE hInstance) { WNDCLASSEX winClassEx; // This will describe the window class we will create. // First fill in the window class structure winClassEx.cbSize = sizeof(winClassEx); winClassEx.style = CS_DBLCLKS | CS_OWNDC | CS_HREDRAW | CS_VREDRAW; winClassEx.lpfnWndProc = WindowProc; winClassEx.cbClsExtra = 0; winClassEx.cbWndExtra = 0; winClassEx.hInstance = hInstance; winClassEx.hIcon = LoadIcon(NULL, IDI_APPLICATION); winClassEx.hIconSm = NULL; winClassEx.hCursor = LoadCursor(NULL, IDC_ARROW); winClassEx.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH); winClassEx.lpszMenuName = NULL; winClassEx.lpszClassName = g_szWINDOW_CLASS_NAME; // Register the window class return RegisterClassEx(&winClassEx); } // Creates and sizes the window appropriately depending on if // the application is windowed or full screen. HWND MakeWindow(HINSTANCE hInstance) { // Setup window style flags DWORD dwWindowStyleFlags = WS_VISIBLE; if (g_bIS_WINDOWED) { dwWindowStyleFlags |= WS_OVERLAPPEDWINDOW; } else { dwWindowStyleFlags |= WS_POPUP; ShowCursor(FALSE); // Stop showing the mouse cursor } // Setup the desired client area size RECT rWindow; rWindow.left = 0; rWindow.top = 0; rWindow.right = g_nWINDOW_WIDTH; rWindow.bottom = g_nWINDOW_HEIGHT; // Get the dimensions of a window that will have a client rect that // will really be the resolution we're looking for. AdjustWindowRectEx(&rWindow, dwWindowStyleFlags, FALSE, WS_EX_APPWINDOW); // Calculate the width/height of that window's dimensions int nWindowWidth = rWindow.right - rWindow.left; int nWindowHeight = rWindow.bottom - rWindow.top; // Create the window return CreateWindowEx(WS_EX_APPWINDOW, // Extended Style flags. g_szWINDOW_CLASS_NAME, // Window Class Name. g_szWINDOW_TITLE, // Title of the Window. dwWindowStyleFlags, // Window Style Flags. (GetSystemMetrics(SM_CXSCREEN)/2) - (nWindowWidth/2), // Window Start Point (x, y). (GetSystemMetrics(SM_CYSCREEN)/2) - (nWindowHeight/2), // -Does the math to center the window over the desktop. nWindowWidth, // Width of Window. nWindowHeight, // Height of Window. NULL, // Handle to parent window. NULL, // Handle to menu. hInstance, // Application Instance. NULL); // Creation parameters. } ////////////////////////// // WinMain // ////////////////////////// int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) { srand(unsigned int(time(0))); MSG msg; // Generic message. HWND hWnd; // Main Window Handle. // Don't let more than one instance of the application exist // // NOTE: Comment out the following section of code if your game needs to have more // than one instance running on the same computer (i.e. client/server) //////////////////////////////////////////////////////////////////////// if (!hPrevInstance) { if (CheckIfAlreadyRunning()) return FALSE; } //////////////////////////////////////////////////////////////////////// // Register the window class if (!RegisterWindowClass(hInstance)) return 0; // Create the window hWnd = MakeWindow(hInstance); if (!hWnd) return 0; ShowWindow(hWnd, nCmdShow); UpdateWindow(hWnd); ////////////////////////////////////////// // Initialize Game here ////////////////////////////////////////// CGame *pGame = CGame::GetInstance(); pGame->Initialize(hWnd, hInstance, g_nWINDOW_WIDTH, g_nWINDOW_HEIGHT, g_bIS_WINDOWED); ////////////////////////////////////////// // Enter main event loop while (TRUE) { if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) { // Test if this is a quit if (msg.message == WM_QUIT) break; // Translate any accelerator keys TranslateMessage(&msg); // Send the message to the window proc DispatchMessage(&msg); } ////////////////////////////////// // Put Game Logic Here ////////////////////////////////// if(!pGame->Main()) break; ////////////////////////////////// } ///////////////////////////////////////// // Shutdown Game Here ///////////////////////////////////////// pGame->Shutdown(); ///////////////////////////////////////// // Unregister the window class UnregisterClass(g_szWINDOW_CLASS_NAME, hInstance); // Return to Windows like this. return (int)(msg.wParam); }
[ "Juno05@1cfc0206-7002-11de-8585-3f51e31374b7" ]
[ [ [ 1, 291 ] ] ]
9d217fdd97572258cdee31c2811527ed26424e4c
91b964984762870246a2a71cb32187eb9e85d74e
/SRC/OFFI SRC!/_Network/Misc/Include/mymap.h
09bfaa41f8bce98697fd37b2d59cdfe5cdaa532f
[]
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
16,436
h
#ifndef __MYMAP_H__ #define __MYMAP_H__ #pragma once #include <stack> #include <list> using namespace std; #define INVALID_KEY (DWORD)0xFFFFFFFF #ifdef __VERIFY_LOOP041010 #undef INIT_LOOP #undef VERIFY_LOOP #define INIT_LOOP(n) int __loop = (n); #define VERIFY_LOOP(file, line) if( --__loop == 0 ) { FILEOUT( "..\\mymap.txt", "%s, %d", file, line ); } #else #undef INIT_LOOP #undef VERIFY_LOOP #define INIT_LOOP(n) ((void)0); #define VERIFY_LOOP(file, line) ((void)0); #endif /*--------------------------------------------------------------------------------*/ #ifndef __STL_0402 template <class T> class CMyBucket { public: DWORD m_dwKey; T m_value; CMyBucket<T>* m_pNext; // map CMyBucket<T>* pPrevious; // list CMyBucket<T>* pNext; public: // Constructions CMyBucket(); virtual ~CMyBucket(); // Operations void Empty( void ); BOOL IsEqual( DWORD dwKey ); BOOL IsEmpty( void ); }; template <class T> CMyBucket<T>::CMyBucket() { m_dwKey = INVALID_KEY; m_pNext = NULL; // map pPrevious = pNext = NULL; // list } template <class T> CMyBucket<T>::~CMyBucket() { } template <class T> inline void CMyBucket<T>::Empty( void ) { m_dwKey = INVALID_KEY; } template <class T> inline BOOL CMyBucket<T>::IsEqual( DWORD dwKey ) { return( dwKey == m_dwKey ); } template <class T> inline BOOL CMyBucket<T>::IsEmpty( void ) { return( m_dwKey == INVALID_KEY ); } /*--------------------------------------------------------------------------------*/ template <class T> class CMyBucket2 { public: char m_pKey[64]; size_t m_nSize; T m_value; CMyBucket2<T>* m_pNext; // map CMyBucket2<T>* pPrevious; // list CMyBucket2<T>* pNext; public: // Constructions CMyBucket2(); virtual ~CMyBucket2(); // Operations void Empty( void ); BOOL IsEqual( const char* pKey, size_t nSize ); BOOL IsEmpty( void ); }; template <class T> CMyBucket2<T>::CMyBucket2() { m_nSize = 0; m_pNext = NULL; pPrevious = pNext = NULL; } template <class T> CMyBucket2<T>::~CMyBucket2() { } template <class T> inline void CMyBucket2<T>::Empty( void ) { m_nSize = 0; } template <class T> inline BOOL CMyBucket2<T>::IsEqual( const char *pKey, size_t nSize ) { if( nSize == m_nSize ) return !memcmp( pKey, m_pKey, nSize ); return FALSE; } template <class T> inline BOOL CMyBucket2<T>::IsEmpty( void ) { return( !m_nSize ); } /*--------------------------------------------------------------------------------*/ template <class T> class CMyPool { private: stack<T*> m_stackData; list<T*> m_listBlock; size_t m_nGrowSize; size_t m_nInitialSize; public: // Constructions CMyPool(); CMyPool( size_t nInitialSize, size_t nGrowSize ); virtual ~CMyPool(); // Operations void Clear( void ); void SetSize( size_t nInitialSize, size_t nGrowSize ); T* Pop( void ); void Push( T* lpMem ); size_t GetInitialSize( void ); size_t GetGrowSize( void ); private: // Operations void Grow( size_t nGrowSize ); }; template <class T> CMyPool<T>::CMyPool() { m_nInitialSize = m_nGrowSize = 0; } template <class T> CMyPool<T>::CMyPool( size_t nInitialSize, size_t nGrowSize ) { SetSize( nInitialSize, nGrowSize ); } template <class T> CMyPool<T>::~CMyPool() { Clear(); } template <class T> void CMyPool<T>::Clear( void ) { INIT_LOOP(1000); for( list<T*>::iterator i = m_listBlock.begin(); i != m_listBlock.end(); ++i ) { VERIFY_LOOP( __FILE__, __LINE__ ); safe_delete_array( *i ); } m_listBlock.clear(); { INIT_LOOP(1000); while( !m_stackData.empty() ) { VERIFY_LOOP( __FILE__, __LINE__ ); m_stackData.pop(); } } m_nInitialSize = m_nGrowSize = 0; } template <class T> void CMyPool<T>::SetSize( size_t nInitialSize, size_t nGrowSize ) { ASSERT( nInitialSize ); ASSERT( nGrowSize ); Clear(); Grow( m_nInitialSize = nInitialSize ); m_nGrowSize = nGrowSize; } template <class T> inline T* CMyPool<T>::Pop( void ) { ASSERT( m_nGrowSize > 0 ); if( m_stackData.empty() ) Grow( m_nGrowSize ); T* lpMem = m_stackData.top(); m_stackData.pop(); return lpMem; } template <class T> inline void CMyPool<T>::Push( T* lpMem ) { ASSERT( m_nGrowSize > 0 ); m_stackData.push( lpMem ); } template <class T> inline size_t CMyPool<T>::GetInitialSize( void ) { return m_nInitialSize; } template <class T> inline size_t CMyPool<T>::GetGrowSize( void ) { return m_nGrowSize; } template <class T> inline void CMyPool<T>::Grow( size_t nGrowSize ) { ASSERT( nGrowSize > 0 ); T* pBlock = new T[nGrowSize]; m_listBlock.push_back( pBlock ); INIT_LOOP(5000); for( size_t i = 0; i < nGrowSize; i++ ) { VERIFY_LOOP( __FILE__, __LINE__ ); m_stackData.push( &pBlock[i] ); } } /*--------------------------------------------------------------------------------*/ template <class T> class CMyMap { private: CMyBucket<T>* m_pBuckets; CMyPool< CMyBucket<T> > m_pool; CMyBucket<T>* m_pFirstActive; // list size_t m_nHashSize; u_long m_nTotal; public: CMclCritSec m_AddRemoveLock; public: // Constructions CMyMap(); CMyMap( size_t nHashSize, size_t nInitialSize, size_t nGrowSize ); virtual ~CMyMap(); // Operations int GetCount( void ); void SetSize( size_t nHashSize, size_t nInitialSize, size_t nGrowSize = 1 ); BOOL Lookup( DWORD dwKey, T &value ); T operator[]( DWORD dwKey ); void SetAt( DWORD dwKey, const T & value ); void RemoveAll( void ); BOOL RemoveKey( DWORD dwKey ); void AddItToActiveList( CMyBucket<T>* pBucket ); void RemoveItFromActiveList( CMyBucket<T>* pBucket ); CMyBucket<T>* GetFirstActive( void ); void ClearActiveList( void ); void Lock( void ); void Unlock( void ); private: // Operations }; template <class T> CMyMap<T>::CMyMap() { m_pBuckets = NULL; m_nHashSize = 0; m_nTotal = 0; m_pFirstActive = NULL; } template <class T> CMyMap<T>::CMyMap( size_t nHashSize, size_t nInitialSize, size_t nGrowSize ) { SetSize( nHashSize, nInitialSize, nGrowSize ); } template <class T> CMyMap<T>::~CMyMap() { SAFE_DELETE_ARRAY( m_pBuckets ); } template <class T> inline int CMyMap<T>::GetCount( void ) { return (int)m_nTotal; } template <class T> void CMyMap<T>::SetSize( size_t nHashSize, size_t nInitialSize, size_t nGrowSize ) { SAFE_DELETE_ARRAY( m_pBuckets ); m_pFirstActive = NULL; INIT_LOOP(10000); int i; for( i = (int)nHashSize; ; i++ ) { VERIFY_LOOP( __FILE__, __LINE__ ); if( IsPrime( i ) ) break; } m_pBuckets = new CMyBucket<T>[m_nHashSize=i]; m_nTotal = 0; m_pool.SetSize( nInitialSize, nGrowSize ); } template <class T> inline BOOL CMyMap<T>::Lookup( DWORD dwKey, T & value ) { ASSERT( m_nHashSize > 0 ); if( dwKey == INVALID_KEY ) return FALSE; INIT_LOOP(1000); CMyBucket<T>* pBucket = &m_pBuckets[IDHash( dwKey, m_nHashSize )]; while( pBucket ) { VERIFY_LOOP( __FILE__, __LINE__ ); if( pBucket->IsEqual( dwKey ) ) { value = pBucket->m_value; return TRUE; } pBucket = pBucket->m_pNext; } return FALSE; } template <class T> inline T CMyMap<T>::operator []( DWORD dwKey ) { T value; Lookup( dwKey, value ); return value; } template <class T> inline void CMyMap<T>::SetAt( DWORD dwKey, const T & value ) { ASSERT( m_nHashSize > 0 ); CMyBucket<T> *pBucket, *pBucketPrev; m_nTotal++; INIT_LOOP(1000); for( pBucket = &m_pBuckets[(int)IDHash( dwKey, m_nHashSize )]; pBucket != NULL; pBucket = pBucket->m_pNext ) { VERIFY_LOOP( __FILE__, __LINE__ ); if( pBucket->IsEmpty() ) { pBucket->m_dwKey = dwKey; pBucket->m_value = value; AddItToActiveList( pBucket ); return; } pBucketPrev = pBucket; } // Collision pBucket = pBucketPrev-> m_pNext = m_pool.Pop(); pBucket->m_dwKey = dwKey; pBucket->m_value = value; AddItToActiveList( pBucket ); } template <class T> void CMyMap<T>::RemoveAll( void ) { m_pFirstActive = NULL; CMyBucket<T>* pBucket, *pNext; INIT_LOOP(1000); int i; for( i = 0; i < (int)( m_nHashSize ); i++ ) { VERIFY_LOOP( __FILE__, __LINE__ ); pBucket = &m_pBuckets[i]; if( !pBucket->IsEmpty() ) pBucket->Empty(); int __loop2 = 1000; while( pBucket->m_pNext ) { if( --__loop2 == 0 ) { FILEOUT( "mymap.txt", "%s, %d", __FILE__, __LINE__ ); } pNext = pBucket->m_pNext; pBucket->m_pNext = NULL; pBucket = pNext; m_pool.Push( pBucket ); } } m_nTotal = 0; } template <class T> inline BOOL CMyMap<T>::RemoveKey( DWORD dwKey ) { ASSERT( m_nHashSize > 0 ); CMyBucket<T> *pBucket = &m_pBuckets[(int)IDHash( dwKey, m_nHashSize )], *pBucketPrev; if( pBucket->IsEqual( dwKey ) ) { pBucket->Empty(); RemoveItFromActiveList( pBucket ); m_nTotal--; return TRUE; } INIT_LOOP(1000); while( TRUE ) { VERIFY_LOOP( __FILE__, __LINE__ ); pBucketPrev = pBucket; pBucket = pBucket->m_pNext; if( !pBucket ) return FALSE; if( pBucket->IsEqual( dwKey ) ) { pBucketPrev->m_pNext = pBucket->m_pNext; pBucket->m_pNext = NULL; RemoveItFromActiveList( pBucket ); m_pool.Push( pBucket ); m_nTotal--; return TRUE; } } return FALSE; } template <class T> inline void CMyMap<T>::AddItToActiveList( CMyBucket<T>* pBucket ) { // Add it to the active list if( m_pFirstActive ) m_pFirstActive->pPrevious = pBucket; pBucket->pNext = m_pFirstActive; pBucket->pPrevious = NULL; m_pFirstActive = pBucket; } template <class T> inline void CMyMap<T>::RemoveItFromActiveList( CMyBucket<T>* pBucket ) { // Remove it from active list if( pBucket->pPrevious ) pBucket->pPrevious->pNext = pBucket->pNext; if( pBucket->pNext ) pBucket->pNext->pPrevious = pBucket->pPrevious; if( m_pFirstActive == pBucket ) m_pFirstActive = pBucket->pNext; } template <class T> inline CMyBucket<T>* CMyMap<T>::GetFirstActive( void ) { return m_pFirstActive; } template <class T> inline void CMyMap<T>::ClearActiveList( void ) { m_pFirstActive = NULL; } template <class T> inline void CMyMap<T>::Lock( void ) { m_AddRemoveLock.Enter(); } template <class T> inline void CMyMap<T>::Unlock( void ) { m_AddRemoveLock.Leave(); } /*--------------------------------------------------------------------------------*/ template <class T> class CMyMap2 { private: CMyBucket2<T>* m_pBuckets; CMyPool< CMyBucket2<T> > m_pool; CMyBucket2<T>* m_pFirstActive; // list UINT m_nHashSize; UINT m_nTotal; public: CMclCritSec m_AddRemoveLock; public: // Constructions CMyMap2(); CMyMap2( size_t nHashSize, size_t nInitialSize, size_t nGrowSize ); virtual ~CMyMap2(); // Operations int GetCount( void ); void SetSize( size_t nHashSize, size_t nInitialSize, size_t nGrowSize = 1 ); BOOL Lookup( const char* pKey, T & value ); void SetAt( const char* pKey, const T & value ); void RemoveAll( void ); BOOL RemoveKey( const char* pKey ); void AddItToActiveList( CMyBucket2<T>* pBucket ); void RemoveItFromActiveList( CMyBucket2<T>* pBucket ); CMyBucket2<T>* GetFirstActive( void ); void ClearActiveList( void ); void Lock( void ); void Unlock( void ); private: // Operations DWORD MAKESTR2DWORD( const char* pKey, size_t nSize ); }; template <class T> CMyMap2<T>::CMyMap2() { m_pBuckets = NULL; m_nHashSize = 0; m_nTotal = 0; m_pFirstActive = NULL; } template <class T> CMyMap2<T>::CMyMap2( size_t nHashSize, size_t nInitialSize, size_t nGrowSize ) { SetSize( nHashSize, nInitialSize, nGrowSize ); } template <class T> CMyMap2<T>::~CMyMap2() { SAFE_DELETE_ARRAY( m_pBuckets ); } template <class T> inline int CMyMap2<T>::GetCount( void ) { return (int)m_nTotal; } template <class T> void CMyMap2<T>::SetSize( size_t nHashSize, size_t nInitialSize, size_t nGrowSize ) { SAFE_DELETE_ARRAY( m_pBuckets ); m_pFirstActive = NULL; INIT_LOOP(10000); int i; for( i = (int)nHashSize; ; i++ ) { VERIFY_LOOP( __FILE__, __LINE__ ); if( IsPrime( i ) ) break; } m_pBuckets = new CMyBucket2<T>[m_nHashSize=i]; m_nTotal = 0; m_pool.SetSize( nInitialSize, nGrowSize ); } template <class T> inline BOOL CMyMap2<T>::Lookup( const char* pKey, T & value ) { ASSERT( m_nHashSize > 0 ); if( pKey == NULL ) return FALSE; size_t nSize = strlen( pKey ); CMyBucket2<T>* pBucket = &m_pBuckets[(int)IDHash( MAKESTR2DWORD( pKey, nSize ), m_nHashSize )]; INIT_LOOP(1000); while( pBucket ) { VERIFY_LOOP( __FILE__, __LINE__ ); if( pBucket->IsEqual( pKey, nSize ) ) { value = pBucket->m_value; return TRUE; } pBucket = pBucket->m_pNext; } return FALSE; } template <class T> inline void CMyMap2<T>::SetAt( const char* pKey, const T & value ) { ASSERT( m_nHashSize > 0 ); CMyBucket2<T> *pBucket, *pBucketPrev; size_t nSize = strlen( pKey ); m_nTotal++; INIT_LOOP(10000); for( pBucket = &m_pBuckets[(int)IDHash( MAKESTR2DWORD( pKey, nSize ), m_nHashSize )]; pBucket != NULL; pBucket = pBucket->m_pNext ) { VERIFY_LOOP( __FILE__, __LINE__ ); if( pBucket->IsEmpty() ) { strcpy( pBucket->m_pKey, pKey ); pBucket->m_nSize = nSize; pBucket->m_value = value; AddItToActiveList( pBucket ); return; } pBucketPrev = pBucket; } pBucket = pBucketPrev->m_pNext = m_pool.Pop(); strcpy( pBucket->m_pKey, pKey ); pBucket->m_nSize = nSize; pBucket->m_value = value; AddItToActiveList( pBucket ); } template <class T> void CMyMap2<T>::RemoveAll( void ) { m_pFirstActive = NULL; CMyBucket2<T> *pBucket, *pNext; INIT_LOOP(1000); int i; for( i = 0; i < m_nHashSize; i++ ) { VERIFY_LOOP( __FILE__, __LINE__ ); pBucket = &m_pBuckets[i]; if( !pBucket->IsEmpty() ) pBucket->Empty(); int __loop2 = 1000; while( pBucket->m_pNext ) { if( --__loop2 == 0 ) { FILEOUT( "mymap.txt", "%s, %d", __FILE__, __LINE__ ); } pNext = pBucket->m_pNext; pBucket->m_pNext = NULL; pBucket = pNext; m_pool.Push( pBucket ); } } m_nTotal = 0; } template <class T> inline BOOL CMyMap2<T>::RemoveKey( const char* pKey ) { ASSERT( m_nHashSize > 0 ); size_t nSize = strlen( pKey ); CMyBucket2<T> *pBucket = &m_pBuckets[(int)IDHash( MAKESTR2DWORD( pKey, nSize ), m_nHashSize )], *pBucketPrev; if( pBucket->IsEqual( pKey, nSize ) ) { pBucket->Empty(); RemoveItFromActiveList( pBucket ); m_nTotal--; return TRUE; } INIT_LOOP(1000); while( TRUE ) { VERIFY_LOOP( __FILE__, __LINE__ ); pBucketPrev = pBucket; pBucket = pBucket->m_pNext; if( !pBucket ) return FALSE; if( pBucket->IsEqual( pKey, nSize ) ) { pBucketPrev->m_pNext = pBucket->m_pNext; pBucket->m_pNext = NULL; RemoveItFromActiveList( pBucket ); m_pool.Push( pBucket ); m_nTotal--; return TRUE; } } return FALSE; } template <class T> inline void CMyMap2<T>::AddItToActiveList( CMyBucket2<T>* pBucket ) { // Add it to the active list if( m_pFirstActive ) m_pFirstActive->pPrevious = pBucket; pBucket->pNext = m_pFirstActive; pBucket->pPrevious = NULL; m_pFirstActive = pBucket; } template <class T> inline void CMyMap2<T>::RemoveItFromActiveList( CMyBucket2<T>* pBucket ) { // Remove it from active list if( pBucket->pPrevious ) pBucket->pPrevious->pNext = pBucket->pNext; if( pBucket->pNext ) pBucket->pNext->pPrevious = pBucket->pPrevious; if( m_pFirstActive == pBucket ) m_pFirstActive = pBucket->pNext; } template <class T> inline CMyBucket2<T>* CMyMap2<T>::GetFirstActive( void ) { return m_pFirstActive; } template <class T> inline void CMyMap2<T>::ClearActiveList( void ) { m_pFristActive = NULL; } template <class T> inline void CMyMap2<T>::Lock( void ) { m_AddRemoveLock.Enter(); } template <class T> inline void CMyMap2<T>::Unlock( void ) { m_AddRemoveLock.Leave(); } template <class T> inline DWORD CMyMap2<T>::MAKESTR2DWORD( const char* pKey, size_t nSize ) { DWORD x = 0, y = 0; int i; for( i =0; ( i + sizeof(DWORD) ) < nSize; i += sizeof(DWORD) ) x += *(LPDWORD)( pKey + i ); for(; i < nSize; i++ ) y += *(char*)( pKey + i ); return ( x + y ); } #endif // __STL_0402 #endif // __MYMAP_H__
[ "[email protected]@e2c90bd7-ee55-cca0-76d2-bbf4e3699278" ]
[ [ [ 1, 728 ] ] ]
5d42556afb802ca469142a4cc350bc454e10f1e7
c2153dcfa8bcf5b6d7f187e5a337b904ad9f91ac
/depends/LuaPlus/LuaStackObject.inl
a7b84b3db35d1f8c9b5d3be0619ccddf4330a1ae
[]
no_license
ptrefall/smn6200fluidmechanics
841541a26023f72aa53d214fe4787ed7f5db88e1
77e5f919982116a6cdee59f58ca929313dfbb3f7
refs/heads/master
2020-08-09T17:03:59.726027
2011-01-13T22:39:03
2011-01-13T22:39:03
32,448,422
1
0
null
null
null
null
UTF-8
C++
false
false
19,303
inl
/////////////////////////////////////////////////////////////////////////////// // This source file is part of the LuaPlus source distribution and is Copyright // 2001-2005 by Joshua C. Jensen ([email protected]). // // The latest version may be obtained from http://wwhiz.com/LuaPlus/. // // The code presented in this file may be used in any environment it is // acceptable to use Lua. /////////////////////////////////////////////////////////////////////////////// #ifdef _MSC_VER #pragma once #endif // _MSC_VER #ifndef LUASTACKOBJECT_INL #define LUASTACKOBJECT_INL /////////////////////////////////////////////////////////////////////////////// // namespace LuaPlus /////////////////////////////////////////////////////////////////////////////// namespace LuaPlus { /** Constructor. **/ LUAPLUS_INLINE LuaStackObject::LuaStackObject( LuaState* state, int stackIndex ) : m_state( state ), m_stackIndex( stackIndex ) { } /** Constructor. **/ LUAPLUS_INLINE LuaStackObject::LuaStackObject( LuaState& state, int stackIndex ) : m_state( &state ), m_stackIndex( stackIndex ) { } /** **/ LUAPLUS_INLINE bool LuaStackObject::operator==(const LuaStackObject& right) const { return m_state->Equal((int)*this, (int)right) != 0; } /** **/ LUAPLUS_INLINE LuaState* LuaStackObject::GetState() const { return m_state; } LUAPLUS_INLINE lua_State* LuaStackObject::GetCState() const { return m_state->GetCState(); } /** Retrieves the type name. Corresponds to the information presented in section 4.5 of the Lua manual. **/ LUAPLUS_INLINE const char* LuaStackObject::GetTypeName() const { return lua_typename( GetCState(), GetType() ); } /** Returns one of the LUA_T* constants, based on the type. Corresponds to section 4.5 of the Lua manual. \return Returns one of the following constants: LUA_TNIL, LUA_TINTEGER, LUA_TNUMBER, LUA_TSTRING, LUA_TBOOLEAN, LUA_TTABLE, LUA_TFUNCTION, LUA_TUSERDATA, LUA_TLIGHTUSERDATA, LUA_TWSTRING **/ LUAPLUS_INLINE int LuaStackObject::GetType() const { return lua_type( GetCState(), m_stackIndex ); } /** \return Returns true if the object is nil. **/ LUAPLUS_INLINE bool LuaStackObject::IsNil() const { return lua_isnil( GetCState(), m_stackIndex ); } /** \return Returns true if the object is a table. **/ LUAPLUS_INLINE bool LuaStackObject::IsTable() const { return lua_istable( GetCState(), m_stackIndex ); } /** \return Returns true if the object is user data, including light user data. **/ LUAPLUS_INLINE bool LuaStackObject::IsUserData() const { return lua_isuserdata( GetCState(), m_stackIndex ) != 0; } /** \return Returns true if the object is a C function callback. **/ LUAPLUS_INLINE bool LuaStackObject::IsCFunction() const { return lua_iscfunction( GetCState(), m_stackIndex ) != 0; } /** \return Returns true if the object is a number. **/ LUAPLUS_INLINE bool LuaStackObject::IsInteger() const { return lua_type( GetCState(), m_stackIndex ) == LUA_TNUMBER; } /** \return Returns true if the object is a number. **/ LUAPLUS_INLINE bool LuaStackObject::IsNumber() const { return lua_type( GetCState(), m_stackIndex ) == LUA_TNUMBER; } /** \return Returns true if the object is a string. **/ LUAPLUS_INLINE bool LuaStackObject::IsString() const { return lua_isstring( GetCState(), m_stackIndex ) != 0; } /** \return Returns true if the object is a wide character string. **/ #if LUA_WIDESTRING LUAPLUS_INLINE bool LuaStackObject::IsWString() const { return lua_iswstring( GetCState(), m_stackIndex ) != 0; } #endif /* LUA_WIDESTRING */ /** \return Returns true if the object is a Lua function. **/ LUAPLUS_INLINE bool LuaStackObject::IsFunction() const { return lua_isfunction( GetCState(), m_stackIndex ); } /** \return Returns true if the object is none. **/ LUAPLUS_INLINE bool LuaStackObject::IsNone() const { return !m_state || lua_isnone( GetCState(), m_stackIndex ); } /** \return Returns true if the object is light user data (that is, the object is just a pointer. **/ LUAPLUS_INLINE bool LuaStackObject::IsLightUserData() const { return lua_islightuserdata( GetCState(), m_stackIndex ) != 0; } /** \return Returns true if the object is a boolean. **/ LUAPLUS_INLINE bool LuaStackObject::IsBoolean() const { return lua_isboolean( GetCState(), m_stackIndex ); } /** \return Returns true if the object is a thread. **/ LUAPLUS_INLINE bool LuaStackObject::IsThread() const { return lua_isthread( GetCState(), m_stackIndex ); } /** **/ LUAPLUS_INLINE float LuaStackObject::GetFloat() const { return (float)lua_tonumber( GetCState(), m_stackIndex); } LUAPLUS_INLINE double LuaStackObject::GetDouble() const { return (double)lua_tonumber( GetCState(), m_stackIndex ); } LUAPLUS_INLINE int LuaStackObject::GetInteger() const { return (int)lua_tonumber( GetCState(), m_stackIndex ); } LUAPLUS_INLINE lua_Number LuaStackObject::GetNumber() const { return lua_tonumber( GetCState(), m_stackIndex ); } LUAPLUS_INLINE const char* LuaStackObject::GetString() const { const char* str = lua_tostring( GetCState(), m_stackIndex ); luaplus_assert(str); return str; } #if LUA_WIDESTRING LUAPLUS_INLINE const lua_WChar* LuaStackObject::GetWString() const { const lua_WChar* str = (const lua_WChar*)lua_towstring( GetCState(), m_stackIndex ); luaplus_assert(str); return str; } #endif /* LUA_WIDESTRING */ LUAPLUS_INLINE int LuaStackObject::StrLen() const { return (int)lua_strlen( GetCState(), m_stackIndex ); } LUAPLUS_INLINE lua_CFunction LuaStackObject::GetCFunction() const { luaplus_assert( lua_iscfunction( GetCState(), m_stackIndex ) ); return lua_tocfunction( GetCState(), m_stackIndex ); } LUAPLUS_INLINE void* LuaStackObject::GetUserData() const { luaplus_assert( lua_isuserdata( GetCState(), m_stackIndex ) ); return lua_touserdata( GetCState(), m_stackIndex ); } LUAPLUS_INLINE const void* LuaStackObject::GetLuaPointer() const { return lua_topointer( GetCState(), m_stackIndex ); } LUAPLUS_INLINE void* LuaStackObject::GetLightUserData() const { luaplus_assert( lua_islightuserdata( GetCState(), m_stackIndex )); return (void*)lua_touserdata( GetCState(), m_stackIndex ); } LUAPLUS_INLINE bool LuaStackObject::GetBoolean() const { luaplus_assert( lua_isboolean( GetCState(), m_stackIndex ) || lua_isnil( GetCState(), m_stackIndex ) ); return (int)lua_toboolean( GetCState(), m_stackIndex ) != 0; } LUAPLUS_INLINE lua_State* LuaStackObject::GetThread() const { luaplus_assert( lua_isthread( GetCState(), m_stackIndex ) || lua_isnil( GetCState(), m_stackIndex ) ); return lua_tothread( GetCState(), m_stackIndex ); } LUAPLUS_INLINE void LuaStackObject::Push() { lua_pushvalue( GetCState(), m_stackIndex ); } // This is a dangerous function, as it can affect the stack placement of other LuaObjects. LUAPLUS_INLINE void LuaStackObject::Pop() { lua_remove( GetCState(), m_stackIndex ); } LUAPLUS_INLINE int LuaStackObject::Ref( int lock ) { Push(); return m_state->Ref( lock ); } LUAPLUS_INLINE LuaStackObject LuaStackObject::GetMetaTable() { lua_getmetatable( GetCState(), m_stackIndex ); return LuaStackObject( GetState(), lua_gettop( GetCState() ) ); } LUAPLUS_INLINE void LuaStackObject::SetMetaTable() { lua_setmetatable( GetCState(), m_stackIndex ); } LUAPLUS_INLINE void LuaStackObject::SetMetaTable( LuaStackObject value ) { value.Push(); lua_setmetatable( GetCState(), m_stackIndex ); } LUAPLUS_INLINE void LuaStackObject::SetTable() { lua_settable( GetCState(), m_stackIndex ); } LUAPLUS_INLINE int LuaStackObject::GetCount() { return lua_objlen( GetCState(), m_stackIndex ); } /** Creates a table called [name] within the current LuaStackObject. @param name The name of the table to create. @param size The size of the table. @return Returns the object representing the newly created table. **/ LUAPLUS_INLINE LuaStackObject LuaStackObject::CreateTable( const char* name, int narray, int lnhash ) { (void)narray; (void)lnhash; //jj lua_newtablesize(m_state, narray, lnhash); // T lua_newtable( GetCState() ); // T lua_pushstring( GetCState(), name ); // T name lua_pushvalue( GetCState(), lua_gettop( GetCState() ) - 1 ); // T name T lua_settable( GetCState(), m_stackIndex ); return LuaStackObject( GetState(), lua_gettop( GetCState() ) ); } /** Creates a table called [key] within the current LuaStackObject. @param index The index of the table to create. @param size The size of the table. @return Returns the object representing the newly created table. **/ LUAPLUS_INLINE LuaStackObject LuaStackObject::CreateTable(int index, int narray, int lnhash ) { (void)narray; (void)lnhash; //jj lua_newtablesize(m_state, narray, lnhash); // T lua_newtable( GetCState() ); // T lua_pushnumber( GetCState(), index ); // T name lua_pushvalue( GetCState(), lua_gettop( GetCState() ) - 1 ); // T name T lua_settable( GetCState(), m_stackIndex ); return LuaStackObject( GetState(), lua_gettop( GetCState() ) ); } /** Assigns the table key [name] to nil. @param name The name of the object to make nil. **/ LUAPLUS_INLINE void LuaStackObject::SetNil( const char* name ) { lua_pushstring( GetCState(), name ); lua_pushnil( GetCState() ); lua_settable( GetCState(), m_stackIndex ); } /** Assigns the table key [index] to nil. @param key The index of the object to make nil. **/ LUAPLUS_INLINE void LuaStackObject::SetNil( int index ) { lua_pushnumber( GetCState(), index ); lua_pushnil( GetCState() ); lua_settable( GetCState(), m_stackIndex ); } /** Creates (or reassigns) the object called [name] to [value]. @param name The name of the object to assign the value to. @param value The value to assign to [name]. **/ LUAPLUS_INLINE void LuaStackObject::SetBoolean( const char* name, bool value ) { lua_pushstring( GetCState(), name ); lua_pushboolean( GetCState(), value ); lua_settable( GetCState(), m_stackIndex ); } /** Creates (or reassigns) the object called [index] to [value]. @param index The index of the object to assign the value to. @param value The value to assign to [index]. **/ LUAPLUS_INLINE void LuaStackObject::SetBoolean( int index, bool value ) { lua_pushnumber( GetCState(), index ); lua_pushboolean( GetCState(), value ); lua_settable( GetCState(), m_stackIndex ); } /** Creates (or reassigns) the object called [name] to [value]. @param name The name of the object to assign the value to. @param value The value to assign to [name]. **/ LUAPLUS_INLINE void LuaStackObject::SetInteger( const char* name, int value ) { lua_pushstring( GetCState(), name ); lua_pushnumber( GetCState(), value ); lua_settable( GetCState(), m_stackIndex ); } /** Creates (or reassigns) the object called [index] to [value]. @param index The index of the object to assign the value to. @param value The value to assign to [index]. **/ LUAPLUS_INLINE void LuaStackObject::SetInteger( int index, int value ) { lua_pushnumber( GetCState(), index ); lua_pushnumber( GetCState(), value ); lua_settable( GetCState(), m_stackIndex ); } /** Creates (or reassigns) the object called [name] to [value]. @param name The name of the object to assign the value to. @param value The value to assign to [name]. **/ LUAPLUS_INLINE void LuaStackObject::SetNumber( const char* name, lua_Number value ) { lua_pushstring( GetCState(), name ); lua_pushnumber( GetCState(), value ); lua_settable( GetCState(), m_stackIndex ); } /** Creates (or reassigns) the object called [index] to [value]. @param index The index of the object to assign the value to. @param value The value to assign to [index]. **/ LUAPLUS_INLINE void LuaStackObject::SetNumber( int index, lua_Number value ) { lua_pushnumber( GetCState(), index ); lua_pushnumber( GetCState(), value ); lua_settable( GetCState(), m_stackIndex ); } /** Creates (or reassigns) the object called [name] to [value]. @param name The name of the object to assign the value to. @param value The value to assign to [name]. **/ LUAPLUS_INLINE void LuaStackObject::SetString( const char* name, const char* value ) { lua_pushstring( GetCState(), name ); lua_pushstring( GetCState(), value ); lua_settable( GetCState(), m_stackIndex ); } /** Creates (or reassigns) the object called [index] to [value]. @param index The index of the object to assign the value to. @param value The value to assign to [index]. **/ LUAPLUS_INLINE void LuaStackObject::SetString( int index, const char* value ) { lua_pushnumber( GetCState(), index ); lua_pushstring( GetCState(), value ); lua_settable( GetCState(), m_stackIndex ); } /** Creates (or reassigns) the object called [name] to [value]. @param name The name of the object to assign the value to. @param value The value to assign to [name]. **/ #if LUA_WIDESTRING LUAPLUS_INLINE void LuaStackObject::SetWString( const char* name, const lua_WChar* value ) { lua_pushstring( GetCState(), name ); lua_pushwstring( GetCState(), value ); lua_settable( GetCState(), m_stackIndex ); } #endif /* LUA_WIDESTRING */ /** Creates (or reassigns) the object called [index] to [value]. @param index The index of the object to assign the value to. @param value The value to assign to [index]. **/ #if LUA_WIDESTRING LUAPLUS_INLINE void LuaStackObject::SetWString( int index, const lua_WChar* value ) { lua_pushnumber( GetCState(), index ); lua_pushwstring( GetCState(), value ); lua_settable( GetCState(), m_stackIndex ); } #endif /* LUA_WIDESTRING */ /** Creates (or reassigns) the object called [name] to [value]. @param name The name of the object to assign the value to. @param value The value to assign to [name]. **/ LUAPLUS_INLINE void LuaStackObject::SetUserData( const char* name, void* value ) { lua_pushstring( GetCState(), name ); (*(void **)(lua_newuserdata(GetCState(), sizeof(void *))) = (value)); lua_settable( GetCState(), m_stackIndex ); } /** Creates (or reassigns) the object called [index] to [value]. @param index The index of the object to assign the value to. @param value The value to assign to [index]. **/ LUAPLUS_INLINE void LuaStackObject::SetUserData( int index, void* value ) { lua_pushnumber( GetCState(), index ); (*(void **)(lua_newuserdata(GetCState(), sizeof(void *))) = (value)); lua_settable( GetCState(), m_stackIndex ); } /** Creates (or reassigns) the object called [name] to [value]. @param name The name of the object to assign the value to. @param value The value to assign to [name]. **/ LUAPLUS_INLINE void LuaStackObject::SetLightUserData( int index, void* value ) { lua_pushnumber( GetCState(), index ); lua_pushlightuserdata( GetCState(), value ); lua_settable( GetCState(), m_stackIndex ); } /** Creates (or reassigns) the object called [name] to [value]. @param name The name of the object to assign the value to. @param value The value to assign to [name]. **/ LUAPLUS_INLINE void LuaStackObject::SetLightUserData( const char* name, void* value ) { lua_pushstring( GetCState(), name ); lua_pushlightuserdata( GetCState(), value ); lua_settable( GetCState(), m_stackIndex ); } /** Creates (or reassigns) the object called [name] to [value]. @param name The name of the object to assign the value to. @param value The value to assign to [name]. **/ LUAPLUS_INLINE void LuaStackObject::SetObject( const char* name, LuaStackObject& value ) { lua_pushstring( GetCState(), name ); lua_pushvalue( GetCState(), value ); lua_settable( GetCState(), m_stackIndex ); } /** Creates (or reassigns) the object called [index] to [value]. @param index The index of the object to assign the value to. @param value The value to assign to [index]. **/ LUAPLUS_INLINE void LuaStackObject::SetObject( int index, LuaStackObject& value ) { lua_pushnumber( GetCState(), index ); lua_pushvalue( GetCState(), value ); lua_settable( GetCState(), m_stackIndex ); } /** Assuming the current object is a table, retrieves the table entry called [name]. @param name The name of the entry from the current table to retrieve. @return Returns an LuaStackObject representing the retrieved entry. **/ LUAPLUS_INLINE LuaStackObject LuaStackObject::GetByName( const char* name ) { lua_pushstring( GetCState(), name ); lua_gettable( GetCState(), m_stackIndex ); return LuaStackObject( GetState(), lua_gettop( GetCState() ) ); } /** Assuming the current object is a table, retrieves the table entry at [index]. @param index The numeric name of a table entry. @return Returns an LuaStackObject representing the retrieved entry. **/ LUAPLUS_INLINE LuaStackObject LuaStackObject::GetByIndex( int index ) { lua_rawgeti( GetCState(), m_stackIndex, index ); return LuaStackObject( GetState(), lua_gettop( GetCState() ) ); } /** Assuming the current object is a table, retrieves the table entry called [name]. @param name The name of the entry from the current table to retrieve. @return Returns an LuaStackObject representing the retrieved entry. **/ LUAPLUS_INLINE LuaStackObject LuaStackObject::GetByObject( LuaStackObject& obj ) { lua_pushvalue( GetCState(), obj ); lua_rawget( GetCState(), m_stackIndex ); return LuaStackObject( GetState(), lua_gettop( GetCState() ) ); } /** **/ LUAPLUS_INLINE LuaStackObject LuaStackObject::operator[]( const char* name ) const { lua_pushstring( GetCState(), name ); lua_rawget( GetCState(), m_stackIndex ); return LuaStackObject( GetState(), lua_gettop( GetCState() ) ); } /** **/ LUAPLUS_INLINE LuaStackObject LuaStackObject::operator[]( int index ) const { lua_rawgeti( GetCState(), m_stackIndex, index ); return LuaStackObject( GetState(), lua_gettop( GetCState() ) ); } /** **/ LUAPLUS_INLINE LuaStackObject LuaStackObject::operator[]( LuaStackObject& obj ) const { lua_pushvalue( GetCState(), obj ); lua_rawget( GetCState(), m_stackIndex ); return LuaStackObject( GetState(), lua_gettop( GetCState() ) ); } LUAPLUS_INLINE const LuaAutoObject& LuaAutoObject::operator=( const LuaStackObject& src ) { lua_remove( GetCState(), m_stackIndex ); m_state = src.m_state; m_stackIndex = src.m_stackIndex; return *this; } LUAPLUS_INLINE LuaAutoObject::~LuaAutoObject() { lua_remove( GetCState(), m_stackIndex ); } LUAPLUS_INLINE LuaStack::LuaStack(LuaState* state) : m_state(state) { m_numStack = state->GetTop(); } LUAPLUS_INLINE LuaStack::LuaStack(lua_State* L) : m_state(LuaState::CastState(L)) { } LUAPLUS_INLINE LuaStack::~LuaStack() { } LUAPLUS_INLINE LuaStackObject LuaStack::operator[](int index) { // luaplus_assert(index <= m_numStack); return LuaStackObject(m_state, index); } } // namespace LuaPlus #endif // LUASTACKOBJECT_INL
[ "[email protected]@c628178a-a759-096a-d0f3-7c7507b30227" ]
[ [ [ 1, 608 ] ] ]
3c7dda4a06ac00e5d580f965b0ee846b2afe90a2
fa609a5b5a0e7de3344988a135b923a0f655f59e
/Tests/Source/TestFunction.cpp
0f2cbfaea4d70d40e8028cd8cb1d2f57effe76cd
[ "MIT" ]
permissive
Sija/swift
3edfd70e1c8d9d54556862307c02d1de7d400a7e
dddedc0612c0d434ebc2322fc5ebded10505792e
refs/heads/master
2016-09-06T09:59:35.416041
2007-08-30T02:29:30
2007-08-30T02:29:30
null
0
0
null
null
null
null
UTF-8
C++
false
false
2,401
cpp
#include "stdafx.h" #include <cppunit/extensions/HelperMacros.h> #include "../../Source/stdafx.h" #include "../../Source/Function.h" #include "../../Source/Globals.h" #include "../../Source/values/String.h" #include "../../Source/values/Int.h" #include "../../Source/values/Void.h" using namespace Swift; class TestFunction : public CPPUNIT_NS::TestFixture { public: CPPUNIT_TEST_SUITE(TestFunction); CPPUNIT_TEST(testGetValue); CPPUNIT_TEST_SUITE_END(); public: void setUp() { } void tearDown() { } protected: void testGetValue() { Param* param; Function* func = new Function("test"); Function* func1 = new Function("test1"); param = new Param(0); param->add("x", operatorNone, operatorNone); func1->addParam(param); param = new Param(0); param->add("y", operatorNone, operatorNone); func1->addParam(param); Function* func2 = new Function("test2"); Function* func3 = new Function("test2"); param = new Param(0); param->add("a", operatorNone, operatorNone); func3->addParam(param); param = new Param(0); param->add(120, operatorNone, operatorNone); func3->addParam(param); try { CPPUNIT_ASSERT(func->getValue()); } catch (Stamina::Exception& e) { } Globals::get()->addFunction("test", bind(&TestFunction::testFunction, this, _1)); Globals::get()->addFunction("test1", bind(&TestFunction::testFunction1, this, _1)); Globals::get()->addFunction("test2", bind(&TestFunction::testFunction2, this, _1)); CPPUNIT_ASSERT(func->getValue() >> String() == "noargs"); CPPUNIT_ASSERT(func1->getValue() >> String() == "arg"); CPPUNIT_ASSERT(func2->getValue()->getID() == Values::Void::id); CPPUNIT_ASSERT(func3->getValue() >> int() == 120); Globals::get()->clearFunctions(); delete func; delete func1; delete func2; delete func3; } private: oValue testFunction(const Globals::tFuncArguments& args) { CPPUNIT_ASSERT(!args.size()); return "noargs"; } oValue testFunction1(const Globals::tFuncArguments& args) { CPPUNIT_ASSERT(args.size()); return "arg"; } oValue testFunction2(const Globals::tFuncArguments& args) { return args.size() ? args[args.size() - 1] : Values::Void(); } }; CPPUNIT_TEST_SUITE_REGISTRATION(TestFunction);
[ [ [ 1, 88 ] ] ]
a9999482bd1fb7b6f881118a62b69d53d25514d5
dadf8e6f3c1adef539a5ad409ce09726886182a7
/airplay/modules/box2d/trunk/Box2D/Testbed/Tests/Tiles.h
05b9e1163c7c52ecb83dd4bf1641c55c4732bb6f
[]
no_license
sarthakpandit/toe
63f59ea09f2c1454c1270d55b3b4534feedc7ae3
196aa1e71e9f22f2ecfded1c3da141e7a75b5c2b
refs/heads/master
2021-01-10T04:04:45.575806
2011-06-09T12:56:05
2011-06-09T12:56:05
53,861,788
0
0
null
null
null
null
UTF-8
C++
false
false
3,668
h
/* * Copyright (c) 2006-2009 Erin Catto http://www.box2d.org * * This software is provided 'as-is', without any express or implied * warranty. In no event will the authors be held liable for any damages * arising from the use of this software. * Permission is granted to anyone to use this software for any purpose, * including commercial applications, and to alter it and redistribute it * freely, subject to the following restrictions: * 1. The origin of this software must not be misrepresented; you must not * claim that you wrote the original software. If you use this software * in a product, an acknowledgment in the product documentation would be * appreciated but is not required. * 2. Altered source versions must be plainly marked as such, and must not be * misrepresented as being the original software. * 3. This notice may not be removed or altered from any source distribution. */ #ifndef TILES_H #define TILES_H /// This stress tests the dynamic tree broad-phase. This also shows that tile /// based collision is _not_ smooth due to Box2D not knowing about adjacency. class Tiles : public Test { public: enum { e_count = 20 }; Tiles() { m_fixtureCount = 0; b2Timer timer; { float32 a = 0.5f; b2BodyDef bd; bd.position.y = -a; b2Body* ground = m_world->CreateBody(&bd); #if 1 int32 N = 200; int32 M = 10; b2Vec2 position; position.y = 0.0f; for (int32 j = 0; j < M; ++j) { position.x = -N * a; for (int32 i = 0; i < N; ++i) { b2PolygonShape shape; shape.SetAsBox(a, a, position, 0.0f); ground->CreateFixture(&shape, 0.0f); ++m_fixtureCount; position.x += 2.0f * a; } position.y -= 2.0f * a; } #else int32 N = 200; int32 M = 10; b2Vec2 position; position.x = -N * a; for (int32 i = 0; i < N; ++i) { position.y = 0.0f; for (int32 j = 0; j < M; ++j) { b2PolygonShape shape; shape.SetAsBox(a, a, position, 0.0f); ground->CreateFixture(&shape, 0.0f); position.y -= 2.0f * a; } position.x += 2.0f * a; } #endif } { float32 a = 0.5f; b2PolygonShape shape; shape.SetAsBox(a, a); b2Vec2 x(-7.0f, 0.75f); b2Vec2 y; b2Vec2 deltaX(0.5625f, 1.25f); b2Vec2 deltaY(1.125f, 0.0f); for (int32 i = 0; i < e_count; ++i) { y = x; for (int32 j = i; j < e_count; ++j) { b2BodyDef bd; bd.type = b2_dynamicBody; bd.position = y; b2Body* body = m_world->CreateBody(&bd); body->CreateFixture(&shape, 5.0f); ++m_fixtureCount; y += deltaY; } x += deltaX; } } m_createTime = timer.GetMilliseconds(); } void Step(Settings* settings) { const b2ContactManager& cm = m_world->GetContactManager(); int32 height = cm.m_broadPhase.GetTreeHeight(); int32 leafCount = cm.m_broadPhase.GetProxyCount(); int32 minimumNodeCount = 2 * leafCount - 1; float32 minimumHeight = ceilf(logf(float32(minimumNodeCount)) / logf(2.0f)); m_debugDraw.DrawString(5, m_textLine, "dynamic tree height = %d, min = %d", height, int32(minimumHeight)); m_textLine += 15; Test::Step(settings); m_debugDraw.DrawString(5, m_textLine, "create time = %6.2f ms, fixture count = %d", m_createTime, m_fixtureCount); m_textLine += 15; //b2DynamicTree* tree = &m_world->m_contactManager.m_broadPhase.m_tree; //if (m_stepCount == 400) //{ // tree->RebuildBottomUp(); //} } static Test* Create() { return new Tiles; } int32 m_fixtureCount; float32 m_createTime; }; #endif
[ [ [ 1, 146 ] ] ]
47065f8fa3cd3cc7eb8029acb3ffe49824c6bcfc
9534a57673ec895f75061a0ca0d8069e3ca7f084
/samples/pstattachment/main.cpp
b41d7a4b2eaa77f9b8bc58b7282db631cf18a9bd
[]
no_license
emk/pstsdk
be9482348a26b331747da34b17212739cdc3e556
21c7d2d57bd09555afd0a08adc966f9b3779cb19
refs/heads/master
2016-08-05T18:18:02.261135
2010-07-16T02:58:43
2010-07-16T02:58:43
724,405
12
8
null
null
null
null
UTF-8
C++
false
false
4,787
cpp
// A sample application to extract all image attachments, i.e. attachments // with any of the extensions gif, jpg or png. // All image attachments are saved in the current working directory, with care // taken not to overwrite any existing files. #include <pstsdk/pst.h> #include <fstream> #include <iostream> #include <sstream> #include <string> const std::wstring gifExtn = L"gif"; const std::wstring jpgExtn = L"jpg"; const std::wstring pngExtn = L"png"; void saveAttachment(const pstsdk::attachment& attch) { std::wstring fname(attch.get_filename()); // Not sure if this is safe or not std::string filenameFull(fname.begin(), fname.end()); // OK to directly use rfind without checking the result as we have already // ensured that a '.' is present in the filename in processAttachment. size_t pos = filenameFull.rfind("."); std::string filenameBase(filenameFull.substr(0, pos)); std::string filenameExtn(filenameFull.substr(pos)); bool done = false; unsigned int i = 1; std::stringstream ss; ss << filenameFull; do { // Check if the file already exists std::ifstream testImgFile(ss.str().c_str(), std::ios::in | std::ios::binary); if(testImgFile.is_open()) { testImgFile.close(); // File with the name of current attachment already exits. // Do not overwrite the existing file, instead use a different name // for this file. ss.str(std::string()); ss.clear(); ss << filenameBase; ss << "(" << i++ << ")"; ss << filenameExtn; } else { done = true; } } while(!done); std::cout << "Saving image attachment to '" << ss.str() << "'\n"; std::ofstream imgFile(ss.str().c_str(), std::ios::out | std::ios::binary); imgFile << attch; imgFile.close(); } void processAttachment(const pstsdk::attachment& attch) { // Parse out the extension from the file name std::wstring filename = attch.get_filename(); size_t dotPos = filename.find_last_of('.'); // Only consider files with an extension if(dotPos != filename.npos) { // Extract the file extension std::wstring extn(filename, dotPos + 1, filename.length()); // Shortcut: // Since we know that we are looking for 3 character extensions, reject // on basis of extension length before doing string comparision. // Might not hold true in the future and may need to be removed. if(extn.length() != 3) { return; } std::wstring lowerExtn(extn); // Convert to lower case for comparision purposes transform(extn.begin(), extn.end(), lowerExtn.begin(), tolower); // Only process certain, recognised image extensions if((lowerExtn == gifExtn) || (lowerExtn == jpgExtn) || (lowerExtn ==pngExtn)) { saveAttachment(attch); } } } void processMessage(const pstsdk::message& msg) { // Ensure that there is atleast one attachment to the current message if(msg.get_attachment_count() > 0) { for(pstsdk::message::attachment_iterator iter = msg.attachment_begin(); iter != msg.attachment_end(); ++iter) { processAttachment(*iter); } } } void traverseAllMessages(const pstsdk::pst& pstFile) { // Iterate through all the folders in the given PST object. for(pstsdk::pst::folder_iterator i = pstFile.folder_begin(); i != pstFile.folder_end(); ++i) { pstsdk::folder currFolder = *i; // Process all messages in the current folder. if(currFolder.get_message_count() > 0) { for(pstsdk::folder::message_iterator j = currFolder.message_begin(); j != currFolder.message_end(); ++j) { processMessage(*j); } } } } void printUsage(const char* program) { std::cout << "Usage\n"; std::cout << "\t" << program << " [PST file]\n"; } int main(int argc, char* argv[]) { if(argc != 2) { printUsage(argv[0]); exit(-1); } std::string pstF(argv[1]); // Check if the file exists std::ifstream pfile(argv[1]); if(pfile.is_open()) { pfile.close(); } else { std::cout << "The specified PST file argument is incorrect. " << "Either it is not a file or the file does not exist\n"; exit(-1); } std::wstring pstFile(pstF.begin(), pstF.end()); pstsdk::pst myFile(pstFile); traverseAllMessages(myFile); }
[ "SND\\nikkul_cp@c102de6d-fbcd-4082-88ef-c2bab1378b82" ]
[ [ [ 1, 151 ] ] ]
509adb80547127f8fe341b64c98c51614aa3cb86
ea1090bc3cbebd289256e28a4b4c0578e9c912c2
/ATmega88/ds18x20_demo/onewire.c
db8ca40b45138da2901f72d6a7f1b2775575d97f
[]
no_license
AkashGutha/avr
0a44a9db9c02827ffbeecb4f461696bc0e17ce1b
58c67ca43acc91c2271a5b687f8f473576cd052a
refs/heads/master
2016-09-05T22:38:36.049072
2011-12-16T13:07:50
2011-12-16T13:07:50
33,775,265
6
0
null
null
null
null
UTF-8
C++
false
false
6,652
c
/* Access Dallas 1-Wire Devices with ATMEL AVRs Author of the initial code: Peter Dannegger (danni(at)specs.de) modified by Martin Thomas (mthomas(at)rhrk.uni-kl.de) 9/2004 - use of delay.h, optional bus configuration at runtime 10/2009 - additional delay in ow_bit_io for recovery 5/2010 - timing modifcations, additonal config-values and comments, use of atomic.h macros, internal pull-up support 7/2010 - added method to skip recovery time after last bit transfered via ow_command_skip_last_recovery */ #include <avr/io.h> #include <util/delay.h> #include <util/atomic.h> #include "onewire.h" #ifdef OW_ONE_BUS #define OW_GET_IN() ( OW_IN & (1<<OW_PIN)) #define OW_OUT_LOW() ( OW_OUT &= (~(1 << OW_PIN)) ) #define OW_OUT_HIGH() ( OW_OUT |= (1 << OW_PIN) ) #define OW_DIR_IN() ( OW_DDR &= (~(1 << OW_PIN )) ) #define OW_DIR_OUT() ( OW_DDR |= (1 << OW_PIN) ) #else /* set bus-config with ow_set_bus() */ uint8_t OW_PIN_MASK; volatile uint8_t* OW_IN; volatile uint8_t* OW_OUT; volatile uint8_t* OW_DDR; #define OW_GET_IN() ( *OW_IN & OW_PIN_MASK ) #define OW_OUT_LOW() ( *OW_OUT &= (uint8_t) ~OW_PIN_MASK ) #define OW_OUT_HIGH() ( *OW_OUT |= (uint8_t) OW_PIN_MASK ) #define OW_DIR_IN() ( *OW_DDR &= (uint8_t) ~OW_PIN_MASK ) #define OW_DIR_OUT() ( *OW_DDR |= (uint8_t) OW_PIN_MASK ) void ow_set_bus(volatile uint8_t* in, volatile uint8_t* out, volatile uint8_t* ddr, uint8_t pin) { OW_DDR=ddr; OW_OUT=out; OW_IN=in; OW_PIN_MASK = (1 << pin); ow_reset(); } #endif uint8_t ow_input_pin_state() { return OW_GET_IN(); } void ow_parasite_enable(void) { OW_OUT_HIGH(); OW_DIR_OUT(); } void ow_parasite_disable(void) { OW_DIR_IN(); #if (!OW_USE_INTERNAL_PULLUP) OW_OUT_LOW(); #endif } uint8_t ow_reset(void) { uint8_t err; OW_OUT_LOW(); OW_DIR_OUT(); // pull OW-Pin low for 480us _delay_us(480); ATOMIC_BLOCK(ATOMIC_RESTORESTATE) { // set Pin as input - wait for clients to pull low OW_DIR_IN(); // input #if OW_USE_INTERNAL_PULLUP OW_OUT_HIGH(); #endif _delay_us(64); // was 66 err = OW_GET_IN(); // no presence detect // if err!=0: nobody pulled to low, still high } // after a delay the clients should release the line // and input-pin gets back to high by pull-up-resistor _delay_us(480 - 64); // was 480-66 if( OW_GET_IN() == 0 ) { err = 1; // short circuit, expected low but got high } return err; } /* Timing issue when using runtime-bus-selection (!OW_ONE_BUS): The master should sample at the end of the 15-slot after initiating the read-time-slot. The variable bus-settings need more cycles than the constant ones so the delays had to be shortened to achive a 15uS overall delay Setting/clearing a bit in I/O Register needs 1 cyle in OW_ONE_BUS but around 14 cyles in configureable bus (us-Delay is 4 cyles per uS) */ static uint8_t ow_bit_io_intern( uint8_t b, uint8_t with_parasite_enable ) { ATOMIC_BLOCK(ATOMIC_RESTORESTATE) { #if OW_USE_INTERNAL_PULLUP OW_OUT_LOW(); #endif OW_DIR_OUT(); // drive bus low _delay_us(2); // T_INT > 1usec accoding to timing-diagramm if ( b ) { OW_DIR_IN(); // to write "1" release bus, resistor pulls high #if OW_USE_INTERNAL_PULLUP OW_OUT_HIGH(); #endif } // "Output data from the DS18B20 is valid for 15usec after the falling // edge that initiated the read time slot. Therefore, the master must // release the bus and then sample the bus state within 15ussec from // the start of the slot." _delay_us(15-2-OW_CONF_DELAYOFFSET); if( OW_GET_IN() == 0 ) { b = 0; // sample at end of read-timeslot } _delay_us(60-15-2+OW_CONF_DELAYOFFSET); #if OW_USE_INTERNAL_PULLUP OW_OUT_HIGH(); #endif OW_DIR_IN(); if ( with_parasite_enable ) { ow_parasite_enable(); } } /* ATOMIC_BLOCK */ _delay_us(OW_RECOVERY_TIME); // may be increased for longer wires return b; } uint8_t ow_bit_io( uint8_t b ) { return ow_bit_io_intern( b & 1, 0 ); } uint8_t ow_byte_wr( uint8_t b ) { uint8_t i = 8, j; do { j = ow_bit_io( b & 1 ); b >>= 1; if( j ) { b |= 0x80; } } while( --i ); return b; } uint8_t ow_byte_wr_with_parasite_enable( uint8_t b ) { uint8_t i = 8, j; do { if ( i != 1 ) { j = ow_bit_io_intern( b & 1, 0 ); } else { j = ow_bit_io_intern( b & 1, 1 ); } b >>= 1; if( j ) { b |= 0x80; } } while( --i ); return b; } uint8_t ow_byte_rd( void ) { // read by sending only "1"s, so bus gets released // after the init low-pulse in every slot return ow_byte_wr( 0xFF ); } uint8_t ow_rom_search( uint8_t diff, uint8_t *id ) { uint8_t i, j, next_diff; uint8_t b; if( ow_reset() ) { return OW_PRESENCE_ERR; // error, no device found <--- early exit! } ow_byte_wr( OW_SEARCH_ROM ); // ROM search command next_diff = OW_LAST_DEVICE; // unchanged on last device i = OW_ROMCODE_SIZE * 8; // 8 bytes do { j = 8; // 8 bits do { b = ow_bit_io( 1 ); // read bit if( ow_bit_io( 1 ) ) { // read complement bit if( b ) { // 0b11 return OW_DATA_ERR; // data error <--- early exit! } } else { if( !b ) { // 0b00 = 2 devices if( diff > i || ((*id & 1) && diff != i) ) { b = 1; // now 1 next_diff = i; // next pass 0 } } } ow_bit_io( b ); // write bit *id >>= 1; if( b ) { *id |= 0x80; // store bit } i--; } while( --j ); id++; // next byte } while( i ); return next_diff; // to continue search } static void ow_command_intern( uint8_t command, uint8_t *id, uint8_t with_parasite_enable ) { uint8_t i; ow_reset(); if( id ) { ow_byte_wr( OW_MATCH_ROM ); // to a single device i = OW_ROMCODE_SIZE; do { ow_byte_wr( *id ); id++; } while( --i ); } else { ow_byte_wr( OW_SKIP_ROM ); // to all devices } if ( with_parasite_enable ) { ow_byte_wr_with_parasite_enable( command ); } else { ow_byte_wr( command ); } } void ow_command( uint8_t command, uint8_t *id ) { ow_command_intern( command, id, 0); } void ow_command_with_parasite_enable( uint8_t command, uint8_t *id ) { ow_command_intern( command, id, 1 ); }
[ "[email protected]@f96d22c5-9466-f0a8-b727-92a628e432d3" ]
[ [ [ 1, 287 ] ] ]
0d42c3cee80f309203486cb4a417289e756af2da
2d1d1db23023ce078e2553cb088fed3d40e67afc
/UdpServerSocket.cpp
8443ec812aa2256f088669b60717d7f8e31ef501
[]
no_license
liuxw7/ippyproxy
f964c8bfe8d4f710e320bdc5447c0414e3b15b08
daab0f961c8fb4da239a71d7a106d39a5b682567
refs/heads/master
2021-06-15T02:34:44.071400
2008-05-13T21:28:30
2008-05-13T21:28:30
null
0
0
null
null
null
null
WINDOWS-1252
C++
false
false
2,824
cpp
//////////////////////////////////////////////////////////////////////////////////////////////////// // IpPyProxy // // Copyright ©2008 Liam Kirton <[email protected]> //////////////////////////////////////////////////////////////////////////////////////////////////// // UdpServerSocket.cpp // // Created: 15/03/2008 //////////////////////////////////////////////////////////////////////////////////////////////////// #include "UdpServerSocket.h" #include <iostream> #include "UdpClientSocket.h" #include "PyInstance.h" //////////////////////////////////////////////////////////////////////////////////////////////////// UdpServerSocket::UdpServerSocket(UdpClientSocket *udpClientSocket, unsigned int ip, unsigned short port) : Socket(), udpClientSocket_(udpClientSocket), ip_(ip), port_(port) { udpClientSocket_->AddRef(); socketProtocol_ = IPPROTO_UDP; socketType_ = SOCK_DGRAM; socketConnected_ = true; } //////////////////////////////////////////////////////////////////////////////////////////////////// UdpServerSocket::~UdpServerSocket() { } //////////////////////////////////////////////////////////////////////////////////////////////////// Socket *UdpServerSocket::OnAccept(SOCKET hSocket) { throw SocketException(this, "Error: UdpServerSocket::OnAccept() Not Supported."); } //////////////////////////////////////////////////////////////////////////////////////////////////// void UdpServerSocket::OnConnect() { } //////////////////////////////////////////////////////////////////////////////////////////////////// void UdpServerSocket::OnDisconnect() { if(udpClientSocket_ != NULL) { udpClientSocket_->Disconnect(); udpClientSocket_->Release(); udpClientSocket_ = NULL; } } //////////////////////////////////////////////////////////////////////////////////////////////////// void UdpServerSocket::OnReceive(unsigned char *buffer, unsigned int length, unsigned int ip, unsigned short port) { if(udpClientSocket_ != NULL) { unsigned char *modifiedBuffer = NULL; unsigned int modifiedBufferLength = 0; PyInstance::GetInstance()->ServerRecv(buffer, length, &modifiedBuffer, &modifiedBufferLength); if(modifiedBuffer != NULL) { udpClientSocket_->Send(modifiedBuffer, modifiedBufferLength, udpClientSocket_->lastIp_, udpClientSocket_->lastPort_); delete [] modifiedBuffer; } else { udpClientSocket_->Send(buffer, length); } } } //////////////////////////////////////////////////////////////////////////////////////////////////// void UdpServerSocket::OnSendCompletion(DWORD dwNumberOfBytes) { } ////////////////////////////////////////////////////////////////////////////////////////////////////
[ [ [ 1, 96 ] ] ]
7627f9edb11c3ed613ccf63abf8dbef0f0332397
3276915b349aec4d26b466d48d9c8022a909ec16
/数据结构/练习/p45-9.cpp
3a7e3deb3b8f4a143b2981a478634eecce40f569
[]
no_license
flyskyosg/3dvc
c10720b1a7abf9cf4fa1a66ef9fc583d23e54b82
0279b1a7ae097b9028cc7e4aa2dcb67025f096b9
refs/heads/master
2021-01-10T11:39:45.352471
2009-07-31T13:13:50
2009-07-31T13:13:50
48,670,844
0
0
null
null
null
null
GB18030
C++
false
false
2,938
cpp
#include<iostream.h> //输入两个单链表,要求使用另外的表c储存这两个表的元素,并且要按照由大到小的顺序排列,要求c使用原有的两个表的存储空间,允许由重复的元素 typedef struct node { int data; struct node *next; }Node; typedef struct list { Node *head; int length; }List; void initlist(List &l) { l.head=NULL; l.length=0; } void creatlist(List &l) { int i=1,j;Node *p,*q; cout<<"输入您要存储的数据,输入0结束操作:"<<endl; while(i!=0) { if(l.head==NULL) { p=new Node; cin>>j; if(j==0) break; p->data=j; p->next=NULL; l.head=q=p; } else { p=new Node; cin>>j; if(j==0) break; p->data=j; p->next=NULL; q->next=p; q=p; } l.length++; } } void add(List &a,List &b,int *p) //将输入的两个线性表存储在一个数组中// { int i,j=0;Node *ah=a.head,*bh=b.head; for(i=1;i<=a.length;i++) { p[j]=ah->data; j++; ah=ah->next; } for(i=1;i<=b.length;i++) { p[j]=bh->data; j++; bh=bh->next; } } void px(int *p,int i) //将得到的数组进行排序// { int t; for(int j=1;j<i;j++) for(int k=0;k<i-j;k++) { if(p[k]<p[k+1]) {t=p[k+1];p[k+1]=p[k];p[k]=t;}; } } void link(List &a,List &b,List &c) //将表c的头指针连接到第一个表的头上,使c表指向a雨b的存储空间; { int i=1;Node *ah=a.head, *bh=b.head; c.head=ah;c.length=a.length+b.length; for(;i<a.length;i++) { ah=ah->next; } ah->next=b.head; } void exchange(List &l,int *p) //将排序后的元素存于表c所指向的原来的a与b 的存储空间. { Node *q=l.head; for(int i=0;i<l.length;i++) { q->data=p[i]; q=q->next; } } void disp(List &l) //将链表的元素显示在显示器上// { Node *p;p=l.head; for(int i=1;i<=l.length;i++) { cout<<p->data; cout<<' '; p=p->next; } cout<<endl; } void main() { List l1,l2,l3;int *p; initlist(l1);initlist(l2);initlist(l3); cout<<"创建表一:"<<endl; creatlist(l1);disp(l1); cout<<"创建表二:"<<endl; creatlist(l2);disp(l2); p=new int [l1.length+l2.length];//p指针用来暂存a与b的元素,也可一直接在两个线性表中直接进行排序,不需要在开辟存储空间,但速度较慢.这里牺牲空间提高速度,但不违背要求,使用原有的空间存储表c. add(l1,l2,p); //将表a与表b的元素暂存与p中, px(p,l1.length+l2.length);//将p中的元素进行排序. link(l1,l2,l3); //将c表连到表a的头节点上, exchange(l3,p);//将p中已经排序的元素存储在原有的空间中// cout<<"表三:"<<endl; disp(l3); }
[ [ [ 1, 161 ] ] ]
953522b4d49f5a915e98cf25b6f939cdef2994e7
77aa13a51685597585abf89b5ad30f9ef4011bde
/dep/src/boost/boost/type_traits/is_base_and_derived.hpp
d28203f085e3cf3db0635d5192976242fe2be728
[]
no_license
Zic/Xeon-MMORPG-Emulator
2f195d04bfd0988a9165a52b7a3756c04b3f146c
4473a22e6dd4ec3c9b867d60915841731869a050
refs/heads/master
2021-01-01T16:19:35.213330
2009-05-13T18:12:36
2009-05-14T03:10:17
200,849
8
10
null
null
null
null
UTF-8
C++
false
false
8,270
hpp
// (C) Copyright Rani Sharoni 2003. // Use, modification and distribution are subject to the Boost Software License, // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt). // // See http://www.boost.org/libs/type_traits for most recent version including documentation. #ifndef BOOST_TT_IS_BASE_AND_DERIVED_HPP_INCLUDED #define BOOST_TT_IS_BASE_AND_DERIVED_HPP_INCLUDED #include <boost/type_traits/intrinsics.hpp> #ifndef BOOST_IS_BASE_OF #include <boost/type_traits/is_class.hpp> #include <boost/type_traits/is_same.hpp> #include <boost/type_traits/is_convertible.hpp> #include <boost/type_traits/detail/ice_and.hpp> #include <boost/type_traits/remove_cv.hpp> #include <boost/config.hpp> #include <boost/static_assert.hpp> #endif // should be the last #include #include <boost/type_traits/detail/bool_trait_def.hpp> namespace boost { namespace detail { #ifndef BOOST_IS_BASE_OF #if !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x581)) \ && !BOOST_WORKAROUND(__SUNPRO_CC , <= 0x540) \ && !BOOST_WORKAROUND(__EDG_VERSION__, <= 243) \ && !BOOST_WORKAROUND(__DMC__, BOOST_TESTED_AT(0x840)) // The EDG version number is a lower estimate. // It is not currently known which EDG version // exactly fixes the problem. /************************************************************************* This version detects ambiguous base classes and private base classes correctly, and was devised by Rani Sharoni. Explanation by Terje Slettebo and Rani Sharoni. Let's take the multiple base class below as an example, and the following will also show why there's not a problem with private or ambiguous base class: struct B {}; struct B1 : B {}; struct B2 : B {}; struct D : private B1, private B2 {}; is_base_and_derived<B, D>::value; First, some terminology: SC - Standard conversion UDC - User-defined conversion A user-defined conversion sequence consists of an SC, followed by an UDC, followed by another SC. Either SC may be the identity conversion. When passing the default-constructed Host object to the overloaded check_sig() functions (initialization 8.5/14/4/3), we have several viable implicit conversion sequences: For "static no_type check_sig(B const volatile *, int)" we have the conversion sequences: C -> C const (SC - Qualification Adjustment) -> B const volatile* (UDC) C -> D const volatile* (UDC) -> B1 const volatile* / B2 const volatile* -> B const volatile* (SC - Conversion) For "static yes_type check_sig(D const volatile *, T)" we have the conversion sequence: C -> D const volatile* (UDC) According to 13.3.3.1/4, in context of user-defined conversion only the standard conversion sequence is considered when selecting the best viable function, so it only considers up to the user-defined conversion. For the first function this means choosing between C -> C const and C -> C, and it chooses the latter, because it's a proper subset (13.3.3.2/3/2) of the former. Therefore, we have: C -> D const volatile* (UDC) -> B1 const volatile* / B2 const volatile* -> B const volatile* (SC - Conversion) C -> D const volatile* (UDC) Here, the principle of the "shortest subsequence" applies again, and it chooses C -> D const volatile*. This shows that it doesn't even need to consider the multiple paths to B, or accessibility, as that possibility is eliminated before it could possibly cause ambiguity or access violation. If D is not derived from B, it has to choose between C -> C const -> B const volatile* for the first function, and C -> D const volatile* for the second function, which are just as good (both requires a UDC, 13.3.3.2), had it not been for the fact that "static no_type check_sig(B const volatile *, int)" is not templated, which makes C -> C const -> B const volatile* the best choice (13.3.3/1/4), resulting in "no". Also, if Host::operator B const volatile* hadn't been const, the two conversion sequences for "static no_type check_sig(B const volatile *, int)", in the case where D is derived from B, would have been ambiguous. See also http://groups.google.com/groups?selm=df893da6.0301280859.522081f7%40posting. google.com and links therein. *************************************************************************/ template <typename B, typename D> struct bd_helper { // // This VC7.1 specific workaround stops the compiler from generating // an internal compiler error when compiling with /vmg (thanks to // Aleksey Gurtovoy for figuring out the workaround). // #if !BOOST_WORKAROUND(BOOST_MSVC, == 1310) template <typename T> static type_traits::yes_type check_sig(D const volatile *, T); static type_traits::no_type check_sig(B const volatile *, int); #else static type_traits::yes_type check_sig(D const volatile *, long); static type_traits::no_type check_sig(B const volatile * const&, int); #endif }; template<typename B, typename D> struct is_base_and_derived_impl2 { #if BOOST_WORKAROUND(_MSC_FULL_VER, >= 140050000) #pragma warning(push) #pragma warning(disable:6334) #endif // // May silently do the wrong thing with incomplete types // unless we trap them here: // BOOST_STATIC_ASSERT(sizeof(B) != 0); BOOST_STATIC_ASSERT(sizeof(D) != 0); struct Host { #if !BOOST_WORKAROUND(BOOST_MSVC, == 1310) operator B const volatile *() const; #else operator B const volatile * const&() const; #endif operator D const volatile *(); }; BOOST_STATIC_CONSTANT(bool, value = sizeof(bd_helper<B,D>::check_sig(Host(), 0)) == sizeof(type_traits::yes_type)); #if BOOST_WORKAROUND(_MSC_FULL_VER, >= 140050000) #pragma warning(pop) #endif }; #else // // broken version: // template<typename B, typename D> struct is_base_and_derived_impl2 { BOOST_STATIC_CONSTANT(bool, value = (::boost::is_convertible<D*,B*>::value)); }; #define BOOST_BROKEN_IS_BASE_AND_DERIVED #endif template <typename B, typename D> struct is_base_and_derived_impl3 { BOOST_STATIC_CONSTANT(bool, value = false); }; template <bool ic1, bool ic2, bool iss> struct is_base_and_derived_select { template <class T, class U> struct rebind { typedef is_base_and_derived_impl3<T,U> type; }; }; template <> struct is_base_and_derived_select<true,true,false> { template <class T, class U> struct rebind { typedef is_base_and_derived_impl2<T,U> type; }; }; template <typename B, typename D> struct is_base_and_derived_impl { typedef typename remove_cv<B>::type ncvB; typedef typename remove_cv<D>::type ncvD; typedef is_base_and_derived_select< ::boost::is_class<B>::value, ::boost::is_class<D>::value, ::boost::is_same<B,D>::value> selector; typedef typename selector::template rebind<ncvB,ncvD> binder; typedef typename binder::type bound_type; BOOST_STATIC_CONSTANT(bool, value = bound_type::value); }; #else template <typename B, typename D> struct is_base_and_derived_impl { BOOST_STATIC_CONSTANT(bool, value = BOOST_IS_BASE_OF(B,D)); }; #endif } // namespace detail BOOST_TT_AUX_BOOL_TRAIT_DEF2( is_base_and_derived , Base , Derived , (::boost::detail::is_base_and_derived_impl<Base,Derived>::value) ) #ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION BOOST_TT_AUX_BOOL_TRAIT_PARTIAL_SPEC2_2(typename Base,typename Derived,is_base_and_derived,Base&,Derived,false) BOOST_TT_AUX_BOOL_TRAIT_PARTIAL_SPEC2_2(typename Base,typename Derived,is_base_and_derived,Base,Derived&,false) BOOST_TT_AUX_BOOL_TRAIT_PARTIAL_SPEC2_2(typename Base,typename Derived,is_base_and_derived,Base&,Derived&,false) #endif #if BOOST_WORKAROUND(__CODEGEARC__, BOOST_TESTED_AT(0x610)) BOOST_TT_AUX_BOOL_TRAIT_PARTIAL_SPEC2_1(typename Base,is_base_and_derived,Base,Base,false) #endif } // namespace boost #include <boost/type_traits/detail/bool_trait_undef.hpp> #endif // BOOST_TT_IS_BASE_AND_DERIVED_HPP_INCLUDED
[ "pepsi1x1@a6a5f009-272a-4b40-a74d-5f9816a51f88" ]
[ [ [ 1, 251 ] ] ]
d4ec1d41faedef731fd9eef9f183789097a2f8f6
c7120eeec717341240624c7b8a731553494ef439
/src/cplusplus/freezone-samp/src/player_ban_serial_item.hpp
68a1bc013450b7daa7af766e5f7ba4a1296851c2
[]
no_license
neverm1ndo/gta-paradise-sa
d564c1ed661090336621af1dfd04879a9c7db62d
730a89eaa6e8e4afc3395744227527748048c46d
refs/heads/master
2020-04-27T22:00:22.221323
2010-09-04T19:02:28
2010-09-04T19:02:28
174,719,907
1
0
null
2019-03-09T16:44:43
2019-03-09T16:44:43
null
UTF-8
C++
false
false
1,166
hpp
#ifndef PLAYER_BAN_SERIAL_ITEM_HPP #define PLAYER_BAN_SERIAL_ITEM_HPP #include "basic_types.hpp" #include "core/module_h.hpp" struct player_ban_serial_item_t { int as_num; std::string serial; player_ban_serial_item_t(); player_ban_serial_item_t(int as_num, std::string const& serial); player_ban_serial_item_t(player_ptr_t const& player_ptr); bool operator<(player_ban_serial_item_t const& right) const { if (as_num == right.as_num) return serial < right.serial; return as_num < right.as_num; } void dump_to_params(messages_params& params) const; }; template <class char_t, class traits_t> inline std::basic_istream<char_t, traits_t>& operator>>(std::basic_istream<char_t, traits_t>& is, player_ban_serial_item_t& item) { is>>item.as_num>>item.serial; if (!is.eof()) { is.setstate(std::ios_base::failbit); } return is; } #include "core/serialization/is_streameble.hpp" namespace serialization { template <> struct is_streameble_read <player_ban_serial_item_t>: std::tr1::true_type {}; } // namespace serialization { #endif // PLAYER_BAN_SERIAL_ITEM_HPP
[ "dimonml@19848965-7475-ded4-60a4-26152d85fbc5" ]
[ [ [ 1, 33 ] ] ]
dc37fa733ce9e3de2699e9370ef0a941671acb7a
036205456b03f717177170d91cc3e75080548aaa
/base.h
c1ea7e4d0c2cea98a5fe5a45e7cba634ea0c6306
[]
no_license
androidsercan/experimental-toolkit-in-c
e877e051fc9546048eaf4287e49865192890d91c
ac545219ed3fcca865c147b0f53e13bff5829fd1
refs/heads/master
2016-08-12T05:04:36.608456
2011-12-14T15:18:04
2011-12-14T15:18:04
43,951,774
0
0
null
null
null
null
UTF-8
C++
false
false
948
h
// $Id: base.h 4340 2011-10-15 05:13:27Z haowu $ #ifndef _ETC_BASE_H_ #define _ETC_BASE_H_ #ifdef _WIN32 #define _CRT_SECURE_NO_WARNINGS #endif #include <cassert> #include <ctime> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> // #include <set> #include <map> #include <queue> #include <vector> #include <string> // #include <algorithm> #include <functional> // #include <iostream> #include <fstream> #include <sstream> using namespace std; // // // typedef int Flag; // const Flag SUCCESS = 0; const Flag FAILURE = -1; // const int MAX_STRING_LENGTH = 512; const int MAX_KEYWORD_LENGTH = 32; #ifdef _WIN32 #ifdef _MSC_VER #include <hash_set> using namespace stdext; typedef hash_set<int> HashSet; #else #include <tr1/unordered_map> #include <tr1/unordered_set> using namespace tr1; typedef unordered_set<int> HashSet; #endif #endif // // // #endif
[ [ [ 1, 62 ] ] ]
87e75fc0760e7655e2a975578f740ed7a75d3014
6dac9369d44799e368d866638433fbd17873dcf7
/src/branches/06112002/Include/Sound/FMODSampleBuffer.h
9f7bf0579759e51468afb9f6205493c6e82ff146
[]
no_license
christhomas/fusionengine
286b33f2c6a7df785398ffbe7eea1c367e512b8d
95422685027bb19986ba64c612049faa5899690e
refs/heads/master
2020-04-05T22:52:07.491706
2006-10-24T11:21:28
2006-10-24T11:21:28
null
0
0
null
null
null
null
UTF-8
C++
false
false
832
h
#ifndef _FMODSAMPLEBUFFER_H_ #define _FMODSAMPLEBUFFER_H_ #include <fmod/fmod.h> #include <Sound/ISoundBuffer.h> /** @ingroup FMOD_Sound_Group * @brief Derived ISoundBuffer class for playing WAV Samples */ class FMODSampleBuffer: public ISoundBuffer{ protected: /** @var FSOUND_SAMPLE *m_sample * @brief FMOD handle to the Sound sample */ FSOUND_SAMPLE *m_sample; public: FMODSampleBuffer (); virtual ~FMODSampleBuffer (); virtual bool Load (char *filename); virtual bool Close (void); virtual int Play (void); virtual bool Pause (bool pause); virtual bool Stop (void); virtual bool SetPosition (int position); virtual bool Volume (unsigned char volume); virtual bool IsPlaying (void); }; #endif // #ifndef _FMODSAMPLEBUFFER_H_
[ "chris_a_thomas@1bf15c89-c11e-0410-aefd-b6ca7aeaabe7", "(no author)@1bf15c89-c11e-0410-aefd-b6ca7aeaabe7" ]
[ [ [ 1, 28 ] ], [ [ 29, 29 ] ] ]
bf58194b138a1c3bd64b79c89ab3f33a380d9666
9eb49222299e0e92722b38959272c0489d20fab7
/CopyPathX.h
98dc747b3f7327657bb40558579f38359094992f
[]
no_license
kerolldev/copypathx
f86a4bc7f89dff294e012a951bcdba0faa52c437
8d76ab1704014fe4e800e69da46ca9bb27971270
refs/heads/master
2021-01-10T19:58:53.262997
2011-10-28T02:35:32
2011-10-28T02:35:32
2,509,231
2
0
null
null
null
null
SHIFT_JIS
C++
false
false
2,368
h
#pragma once #include "_CopyPathX_i.c" // このモジュール属性は、DllMain、DllRegisterServer および DllUnregisterServer を自動的に実装します。 [ module(dll, uuid = "{D45236A6-A91C-4539-AE9F-29BD86B5A2D6}", name = "CopyPathX", helpstring = "CopyPathX 1.0 タイプ ライブラリ", resource_name = "IDR_COPYPATHX") ] class CMyModule { public : // レジストリ設定 HRESULT DllRegisterServer(BOOL bRegTypeLib = TRUE ) { _TCHAR strCLSID[50]; OLECHAR strWideCLSID[50]; CRegKey key; USES_CONVERSION; // オブジェクト、タイプ ライブラリおよびタイプ ライブラリ内の全てのインターフェイスを登録します HRESULT hr = __super::DllRegisterServer(bRegTypeLib); if (SUCCEEDED(hr)) { if (::StringFromGUID2(CLSID_CCopyPathContextMenu, strWideCLSID, 50) > 0) { _tcscpy(strCLSID, OLE2CT(strWideCLSID)); hr = key.SetValue(HKEY_CLASSES_ROOT, _T("*\\shellex\\ContextMenuHandlers\\CopyPathX\\"), strCLSID); hr = key.SetValue(HKEY_CLASSES_ROOT, _T("directory\\shellex\\ContextMenuHandlers\\CopyPathX\\"), strCLSID); hr = key.SetValue(HKEY_CLASSES_ROOT, _T("drive\\shellex\\ContextMenuHandlers\\CopyPathX\\"), strCLSID); } } return hr; } // DllUnregisterServer - エントリをレジストリから削除します。 HRESULT DllUnregisterServer(BOOL bUnRegTypeLib = TRUE ) { HRESULT hr = __super::DllUnregisterServer(bUnRegTypeLib); CRegKey key; if (SUCCEEDED(hr)) { if (key.Open(HKEY_CLASSES_ROOT, _T("*\\shellex\\ContextMenuHandlers\\")) == ERROR_SUCCESS) { hr = key.DeleteValue(NULL); if (hr != ERROR_SUCCESS && hr != ERROR_FILE_NOT_FOUND) return hr; hr = key.DeleteSubKey(_T("CopyPathX")); if (hr != ERROR_SUCCESS && hr != ERROR_FILE_NOT_FOUND) return hr; } if (key.Open(HKEY_CLASSES_ROOT, _T("directory\\shellex\\ContextMenuHandlers\\")) == ERROR_SUCCESS) { hr = key.DeleteSubKey(_T("CopyPathX")); if (hr != ERROR_SUCCESS && hr != ERROR_FILE_NOT_FOUND) return hr; } if (key.Open(HKEY_CLASSES_ROOT, _T("drive\\shellex\\ContextMenuHandlers\\")) == ERROR_SUCCESS) { hr = key.DeleteSubKey(_T("CopyPathX")); if (hr != ERROR_SUCCESS && hr != ERROR_FILE_NOT_FOUND) return hr; } } return hr; } };
[ [ [ 1, 70 ] ] ]
dfe26b6ef48601072b539b91332532937d44bafe
983101adb04a097154ab07618cfcc9ea4e2e1d8e
/complex.h
7139f7cfd82257499e983bf38e0c08d35a89d680
[]
no_license
jrbedard/fractal-viewer
ab866ca6cb3dbe967bca2a15730d0e2e5d63d97a
9e60f4d3d5c5ab70314346a459a7cea4a06796df
refs/heads/master
2021-01-22T23:43:40.911028
2008-12-19T20:24:10
2008-12-19T20:24:10
93,488
1
0
null
null
null
null
UTF-8
C++
false
false
974
h
// Author: Jean-Rene Bedard ([email protected]) 2001 //thanks for C. Dutoit for the algorithms #ifndef COMPLEX_H #define COMPLEX_H class Complex { public: // constructors Complex(); // 0 + i*0 Complex(double a, double b); // a + i*b Complex(double a); // a + i*0 // friends //friend ostream& operator<<(ostream&, Complex); // print as <re,im> friend Complex operator+(Complex,Complex); // addition of two Complex numbers friend Complex operator-(Complex,Complex); // subtraction of two Complex numbers friend Complex operator*(Complex,Complex); // multiplication of two Complex numbers // members Complex operator-(); // return <-re,-im> double modulus(); // return sqrt(re*re+im*im) double real(); // return re double imag(); // return im Complex root(); // return the sqrt(re + i*im) private: // real and imaginary parts double re; double im; }; const Complex i(0,1); #endif
[ [ [ 1, 40 ] ] ]
4aade63c10c93560368de6b872a612de4b751211
3949d20551a203cf29801d888844d83d297d8118
/Sources/LudoRenderer/LudoTexture.cpp
056b9f328e785e9063345b3716aa81c5629ab02d
[]
no_license
Cuihuo/sorgamedev
2197cf5f19a6e8b3b7bba51d46ebc1f8c1f5731e
fa6eb43a586b0e175ac291e8cd583343c0f7a337
refs/heads/master
2021-01-10T17:38:50.996616
2008-11-28T17:13:19
2008-11-28T17:13:19
49,120,070
0
0
null
null
null
null
UTF-8
C++
false
false
5,535
cpp
/////////////////////////////// // Filename: LudoTexture.cpp // Description: wrapper for a texture // Created on: 23/10/2007 /////////////////////////////// #include "LudoCore/LudoGlobal.h" #include "LudoTexture.h" #include "LudoRenderer.h" #include "LudoEngine/LudoEngine.h" #include "LudoCore/FileReader.h" #include "LudoCore/ErrorLogger.h" #include <Dxerr.h> using std::string; LudoTexture::LudoTexture() { m_Texture = NULL; m_TextureLoaded = false; m_Name = ""; m_Width = 0; m_Height = 0; } LudoTexture::LudoTexture(string filename) { m_Name = filename; m_TextureLoaded = false; m_Texture = NULL; m_Width = 0; m_Height = 0; LoadTexture(); } LudoTexture::~LudoTexture() { UnloadTexture(); } LPDIRECT3DTEXTURE9 LudoTexture::GetTexture() { if (m_Texture == NULL) { return 0; } return m_Texture; } void LudoTexture::SetTextureFile(string filename) { m_Name = filename; LoadTexture(); } void LudoTexture::SetSize(int height, int width) { m_Height = height; m_Width = width; } string LudoTexture::GetTextureFile() { return m_Name; } void LudoTexture::LoadTexture() { if (LudoEngine::GetInstance()->GetRender()->GetpDevice() != NULL) { UnloadTexture(); FileReader fr(m_Name.c_str()); int size = 0; char *memblock = (char *)fr.GetFileData(size); LPDIRECT3DDEVICE9 d3dDevice = LudoEngine::GetInstance()->GetRender()->GetpDevice(); if ( memblock && d3dDevice ) { if (m_Name.find(".png") != -1 || m_Name.find(".PNG") != -1) { m_Width = ((byte)memblock[16] << 24) + ((byte)memblock[17] << 16) + ((byte)memblock[18] << 8) + ((byte)memblock[19]); m_Height = ((byte)memblock[20] << 24) + ((byte)memblock[21] << 16) + ((byte)memblock[22] << 8) + ((byte)memblock[23]); } else if (m_Name.find(".jpg") != -1 || m_Name.find(".JPG") != -1) { // Check for valid JPEG header (null terminated JFIF) if(((byte)memblock[0]) == 0xFF && ((byte)memblock[1]) == 0xD8 && ((byte)memblock[2]) == 0xFF && ((byte)memblock[3]) == 0xE0 && memblock[6] == 'J' && memblock[7] == 'F' && memblock[8] == 'I' && memblock[9] == 'F' && memblock[10] == 0x00) { int i = 4; unsigned short block_length = ((byte)memblock[i]) * 256 + ((byte)memblock[i+1]); while(i < size) { i += block_length; if(i < size && ((byte)memblock[i]) == 0xFF) { if (((byte)memblock[i+1]) == 0xC0) { m_Height = ((byte)memblock[i+5]*256) + ((byte)memblock[i+6]); m_Width = ((byte)memblock[i+7]*256) + ((byte)memblock[i+8]); } else { i += 2; //Skip the block marker block_length = ((byte)memblock[i]) * 256 + ((byte)memblock[i+1]); //Go to the next block } } } } if (m_Width == 0 && m_Height == 0) { ErrorLogger::GetInstance()->LogError("Invalid JPEG!",false); LUDO_DELETE[] memblock; return; } } else { ErrorLogger::GetInstance()->LogError("Unsupported texture!",false); LUDO_DELETE[] memblock; return; } HRESULT result = D3DXCreateTextureFromFileInMemoryEx(d3dDevice, memblock, size, m_Width, //width m_Height, //height 1, //mip levels NULL, //usage D3DFMT_UNKNOWN, //texture color format D3DPOOL_MANAGED, //memory class D3DX_FILTER_TRIANGLE | D3DX_FILTER_DITHER | D3DX_FILTER_MIRROR, //filter D3DX_DEFAULT, //mip filter 0, //deactivate color key ( NEW ) NULL, //source info NULL, //pallette &m_Texture); //texture object if (result != S_OK) { const char *c = DXGetErrorDescription(result); ErrorLogger::GetInstance()->LogError(c,false); LUDO_DELETE[] memblock; return; } m_TextureLoaded = true; LUDO_DELETE[] memblock; } } } void LudoTexture::UnloadTexture() { if(m_Texture) { m_Texture->Release(); m_Texture = NULL; m_TextureLoaded = false; m_Width = 0; m_Height = 0; } } int LudoTexture::GetWidth() { return m_Width; } int LudoTexture::GetHeight() { return m_Height; }
[ "sikhan.ariel.lee@a3e5f5c2-bd6c-11dd-94c0-21daf384169b" ]
[ [ [ 1, 176 ] ] ]
6ef1d34d4729f35a556e9eb2642602038d424ab4
fd3f2268460656e395652b11ae1a5b358bfe0a59
/srchybrid/MuleListCtrl.cpp
9dc78cf0b32efd951b230c90a43593e1c9dc0c56
[]
no_license
mikezhoubill/emule-gifc
e1cc6ff8b1bb63197bcfc7e67c57cfce0538ff60
46979cf32a313ad6d58603b275ec0b2150562166
refs/heads/master
2021-01-10T20:37:07.581465
2011-08-13T13:58:37
2011-08-13T13:58:37
32,465,033
4
2
null
null
null
null
UTF-8
C++
false
false
66,122
cpp
//this file is part of eMule //Copyright (C)2002-2008 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / http://www.emule-project.net ) // //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., 675 Mass Ave, Cambridge, MA 02139, USA. #include "stdafx.h" #include "emule.h" #include "MemDC.h" #include "MuleListCtrl.h" #include "Ini2.h" #include "SharedFilesCtrl.h" #include "SearchListCtrl.h" #include "KadContactListCtrl.h" #include "KadSearchListCtrl.h" #include "DownloadListCtrl.h" #include "UploadListCtrl.h" #include "DownloadClientsCtrl.h" #include "QueueListCtrl.h" #include "ClientListCtrl.h" #include "FriendListCtrl.h" #include "ServerListCtrl.h" #include "MenuCmds.h" #include "OtherFunctions.h" #include "ListViewSearchDlg.h" #include <atlimage.h> // ==> Design Settings [eWombat/Stulle] - Stulle #include "Preferences.h" #include "UpDownClient.h" #include "PartFile.h" #include "ShareableFile.h" #include "KnownFile.h" // <== Design Settings [eWombat/Stulle] - Stulle #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif #define MAX_SORTORDERHISTORY 4 #define MLC_BLEND(A, B, X) ((A + B * (X-1) + ((X+1)/2)) / X) #define MLC_RGBBLEND(A, B, X) ( \ RGB(MLC_BLEND(GetRValue(A), GetRValue(B), X), \ MLC_BLEND(GetGValue(A), GetGValue(B), X), \ MLC_BLEND(GetBValue(A), GetBValue(B), X)) \ ) #define MLC_IDC_MENU 4875 #define MLC_IDC_UPDATE (MLC_IDC_MENU - 1) //a value that's not a multiple of 4 and uncommon #define MLC_MAGIC 0xFEEBDEEF //used for very slow assertions //#define MLC_ASSERT(f) ASSERT(f) #define MLC_ASSERT(f) ((void)0) ////////////////////////////////// // CMuleListCtrl // Be carefull with that offsets, they are supposed to match *exactly* the Windows built-in metric. // If it does not match that value, column auto-sizeing (double clicking on header divider) will // give inaccurate results. const int CMuleListCtrl::sm_iIconOffset = 4; // Offset from left window border to icon (of 1st column) const int CMuleListCtrl::sm_iLabelOffset = 2; // Offset between right icon border and item text (of 1st column) const int CMuleListCtrl::sm_iSubItemInset = 4; // Offset from left and right column border to item text IMPLEMENT_DYNAMIC(CMuleListCtrl, CListCtrl) BEGIN_MESSAGE_MAP(CMuleListCtrl, CListCtrl) ON_NOTIFY_REFLECT(LVN_GETINFOTIP, OnLvnGetInfoTip) ON_WM_DRAWITEM() ON_WM_ERASEBKGND() ON_WM_KEYDOWN() ON_WM_MEASUREITEM_REFLECT() ON_WM_SYSCOLORCHANGE() // ==> XP Style Menu [Xanatos] - Stulle ON_WM_MEASUREITEM() ON_WM_MENUCHAR() // <== XP Style Menu [Xanatos] - Stulle END_MESSAGE_MAP() CMuleListCtrl::CMuleListCtrl(PFNLVCOMPARE pfnCompare, DWORD dwParamSort) { m_SortProc = pfnCompare; m_dwParamSort = dwParamSort; UpdateSortHistory(m_dwParamSort, 0); // SLUGFILLER: multiSort - fail-safe, ensure it's in the sort history(no inverse check) m_bCustomDraw = false; m_iCurrentSortItem = -1; m_iColumnsTracked = 0; m_aColumns = NULL; m_iRedrawCount = 0; //just in case m_crWindow = 0; m_crWindowText = 0; m_crWindowTextBk = m_crWindow; m_crHighlight = 0; m_crHighlightText = m_crWindowText; m_crGlow=0; m_crFocusLine = 0; m_crNoHighlight = 0; m_crNoFocusLine = 0; m_bGeneralPurposeFind = false; m_bCanSearchInAllColumns = false; m_bFindMatchCase = false; m_iFindDirection = 1; m_iFindColumn = 0; m_hAccel = NULL; m_uIDAccel = IDR_LISTVIEW; m_eUpdateMode = lazy; m_iAutoSizeWidth = LVSCW_AUTOSIZE; } CMuleListCtrl::~CMuleListCtrl() { delete[] m_aColumns; } int CMuleListCtrl::SortProc(LPARAM /*lParam1*/, LPARAM /*lParam2*/, LPARAM /*lParamSort*/) { return 0; } void CMuleListCtrl::SetPrefsKey(LPCTSTR lpszName) { m_Name = lpszName; } DWORD CMuleListCtrl::SetExtendedStyle(DWORD dwNewStyle) { return CListCtrl::SetExtendedStyle(dwNewStyle | LVS_EX_HEADERDRAGDROP); } void CMuleListCtrl::PreSubclassWindow() { SetColors(); CListCtrl::PreSubclassWindow(); // Win98: Explicitly set to Unicode to receive Unicode notifications. SendMessage(CCM_SETUNICODEFORMAT, TRUE); SetExtendedStyle(LVS_EX_HEADERDRAGDROP); // Vista: Reduce flickering in header control ModifyStyle(0, WS_CLIPCHILDREN); // If we want to handle the VK_RETURN key, we have to do that via accelerators! if (m_uIDAccel != (UINT)-1) { m_hAccel = ::LoadAccelerators(AfxGetResourceHandle(), MAKEINTRESOURCE(m_uIDAccel)); ASSERT(m_hAccel); } // DEFAULT_GUI_FONT: Vista: "MS Shell Dlg" with 8 pts (regardless of system applet settings !!!) // SYSTEM_FONT: Vista: Good old Windows 3.11 System Font // NULL Vista: Font ('Symbol') with the face and size which is configured in System applet. if (thePrefs.GetUseSystemFontForMainControls()) SendMessage(WM_SETFONT, NULL, FALSE); } int CMuleListCtrl::IndexToOrder(CHeaderCtrl* pHeader, int iIndex) { int iCount = pHeader->GetItemCount(); int *piArray = new int[iCount]; Header_GetOrderArray( pHeader->m_hWnd, iCount, piArray); for(int i=0; i < iCount; i++ ) { if(piArray[i] == iIndex) { delete[] piArray; return i; } } delete[] piArray; return -1; } void CMuleListCtrl::HideColumn(int iColumn) { CHeaderCtrl* pHeaderCtrl = GetHeaderCtrl(); int iCount = pHeaderCtrl->GetItemCount(); //Xman //>>> WiZaRd::FiX //needs a rework, sometimes more columns are loaded than inserted (older/corrupt prefs) /* if(iColumn < 1 || iColumn >= iCount || m_aColumns[iColumn].bHidden) */ if(iColumn < 1 || iColumn >= iCount || iColumn >= m_iColumnsTracked || m_aColumns[iColumn].bHidden) //<<< WiZaRd::FiX return; //stop it from redrawing SetRedraw(FALSE); //shrink width to 0 HDITEM item; item.mask = HDI_WIDTH; pHeaderCtrl->GetItem(iColumn, &item); m_aColumns[iColumn].iWidth = item.cxy; item.cxy = 0; pHeaderCtrl->SetItem(iColumn, &item); //move to front of list INT *piArray = new INT[m_iColumnsTracked]; pHeaderCtrl->GetOrderArray(piArray, m_iColumnsTracked); int iFrom = m_aColumns[iColumn].iLocation; for(int i = 0; i < m_iColumnsTracked; i++) if(m_aColumns[i].iLocation > m_aColumns[iColumn].iLocation && m_aColumns[i].bHidden) iFrom++; for(int i = iFrom; i > 0; i--) piArray[i] = piArray[i - 1]; piArray[0] = iColumn; pHeaderCtrl->SetOrderArray(m_iColumnsTracked, piArray); delete[] piArray; //update entry m_aColumns[iColumn].bHidden = true; //redraw SetRedraw(TRUE); Invalidate(FALSE); } void CMuleListCtrl::ShowColumn(int iColumn) { CHeaderCtrl* pHeaderCtrl = GetHeaderCtrl(); int iCount = pHeaderCtrl->GetItemCount(); //Xman //>>> WiZaRd::FiX //needs a rework, sometimes more columns are loaded than inserted (older/corrupt prefs) /* if(iColumn < 1 || iColumn >= iCount || !m_aColumns[iColumn].bHidden) */ if(iColumn < 1 || iColumn >= iCount || iColumn >= m_iColumnsTracked || !m_aColumns[iColumn].bHidden) //<<< WiZaRd::FiX return; //stop it from redrawing SetRedraw(FALSE); //restore position in list //Xman //>>> WiZaRd::FiX - just to be sure! /* INT *piArray = new INT[m_iColumnsTracked]; pHeaderCtrl->GetOrderArray(piArray, m_iColumnsTracked); int iCurrent = IndexToOrder(pHeaderCtrl, iColumn); */ int iCurrent = IndexToOrder(pHeaderCtrl, iColumn); if(iCurrent == -1) return; INT *piArray = new INT[m_iColumnsTracked]; pHeaderCtrl->GetOrderArray(piArray, m_iColumnsTracked); //<<< WiZaRd::FiX - just to be sure! for(; iCurrent < IndexToOrder(pHeaderCtrl, 0) && iCurrent < m_iColumnsTracked - 1; iCurrent++ ) piArray[iCurrent] = piArray[iCurrent + 1]; //Xman //>>> WiZaRd::FiX //first, test the validity of iCurrent before accessing an element! /* for(; m_aColumns[iColumn].iLocation > m_aColumns[pHeaderCtrl->OrderToIndex(iCurrent + 1)].iLocation && iCurrent < m_iColumnsTracked - 1; iCurrent++) */ for(; iCurrent < m_iColumnsTracked - 1 && m_aColumns[iColumn].iLocation > m_aColumns[pHeaderCtrl->OrderToIndex(iCurrent + 1)].iLocation; iCurrent++) //<<< WiZaRd::FiX piArray[iCurrent] = piArray[iCurrent + 1]; piArray[iCurrent] = iColumn; pHeaderCtrl->SetOrderArray(m_iColumnsTracked, piArray); delete[] piArray; //and THEN restore original width HDITEM item; item.mask = HDI_WIDTH; item.cxy = m_aColumns[iColumn].iWidth; pHeaderCtrl->SetItem(iColumn, &item); //update entry m_aColumns[iColumn].bHidden = false; //redraw SetRedraw(TRUE); Invalidate(FALSE); } void CMuleListCtrl::SaveSettings() { ASSERT(!m_Name.IsEmpty()); ASSERT(GetHeaderCtrl()->GetItemCount() == m_iColumnsTracked); //Xman possible fix /* if (m_Name.IsEmpty() || GetHeaderCtrl()->GetItemCount() != m_iColumnsTracked) */ ASSERT(this->m_hWnd!=NULL); if (this->m_hWnd==NULL || m_Name.IsEmpty() || GetHeaderCtrl()->GetItemCount() != m_iColumnsTracked) //Xman end return; CIni ini(thePrefs.GetConfigFile(), _T("ListControlSetup")); ShowWindow(SW_HIDE); // SLUGFILLER: multiSort - store unlimited sorts /* int* piSortHist = new int[MAX_SORTORDERHISTORY]; int i=0; POSITION pos1, pos2; for (pos1 = m_liSortHistory.GetHeadPosition();( pos2 = pos1 ) != NULL;) { m_liSortHistory.GetNext(pos1); piSortHist[i++]=m_liSortHistory.GetAt(pos2)+1; } ini.SerGet(false, piSortHist, i, m_Name + _T("SortHistory")); */ int i; CString strSortHist; POSITION pos = m_liSortHistory.GetTailPosition(); if (pos != NULL) { strSortHist.Format(_T("%d"), m_liSortHistory.GetPrev(pos)); while (pos != NULL) { strSortHist.AppendChar(_T(',')); strSortHist.AppendFormat(_T("%d"), m_liSortHistory.GetPrev(pos)); } } ini.WriteString(m_Name + _T("SortHistory"), strSortHist); // SLUGFILLER: multiSort // store additional settings ini.WriteInt(m_Name + _T("TableSortItem"), GetSortItem()); ini.WriteInt(m_Name + _T("TableSortAscending"), GetSortType(m_atSortArrow)); int* piColWidths = new int[m_iColumnsTracked]; int* piColHidden = new int[m_iColumnsTracked]; INT *piColOrders = new INT[m_iColumnsTracked]; for(i = 0; i < m_iColumnsTracked; i++) { piColWidths[i] = GetColumnWidth(i); piColHidden[i] = IsColumnHidden(i); ShowColumn(i); } GetHeaderCtrl()->GetOrderArray(piColOrders, m_iColumnsTracked); ini.SerGet(false, piColWidths, m_iColumnsTracked, m_Name + _T("ColumnWidths")); ini.SerGet(false, piColHidden, m_iColumnsTracked, m_Name + _T("ColumnHidden")); ini.SerGet(false, piColOrders, m_iColumnsTracked, m_Name + _T("ColumnOrders")); for(i = 0; i < m_iColumnsTracked; i++) if (piColHidden[i]==1) HideColumn(i); ShowWindow(SW_SHOW); // SLUGFILLER: multiSort remove - unused /* delete[] piSortHist; */ // SLUGFILLER: multiSort remove - unused delete[] piColOrders; delete[] piColWidths; delete[] piColHidden; } int CMuleListCtrl::GetSortType(ArrowType at){ switch(at) { case arrowDown : return 0; case arrowUp : return 1; case arrowDoubleDown : return 2; case arrowDoubleUp : return 3; } return 0; } CMuleListCtrl::ArrowType CMuleListCtrl::GetArrowType(int iat) { switch (iat){ case 0: return arrowDown; case 1: return arrowUp; case 2: return arrowDoubleDown; case 3: return arrowDoubleUp; } return arrowDown; } void CMuleListCtrl::LoadSettings() { ASSERT(!m_Name.IsEmpty()); if (m_Name.IsEmpty()) return; CIni ini(thePrefs.GetConfigFile(), _T("ListControlSetup")); CHeaderCtrl* pHeaderCtrl = GetHeaderCtrl(); // sort history // SLUGFILLER: multiSort - read unlimited sorts /* int* piSortHist = new int[MAX_SORTORDERHISTORY]; ini.SerGet(true, piSortHist, MAX_SORTORDERHISTORY, m_Name + _T("SortHistory")); m_liSortHistory.RemoveAll(); for (int i = 0; i < MAX_SORTORDERHISTORY; i++) if (piSortHist[i] > 0) m_liSortHistory.AddTail(piSortHist[i]-1); else break; */ CString strSortHist = ini.GetString(m_Name + _T("SortHistory")); int nOffset = 0; CString strTemp; nOffset = ini.Parse(strSortHist, nOffset, strTemp); while (!strTemp.IsEmpty()) { UpdateSortHistory((int)_tstoi(strTemp), 0); // avoid duplicates(cannot detect inverse, but it does half the job) nOffset = ini.Parse(strSortHist, nOffset, strTemp); } // SLUGFILLER: multiSort m_iCurrentSortItem = ini.GetInt(m_Name + _T("TableSortItem"), 0); m_atSortArrow = GetArrowType(ini.GetInt(m_Name + _T("TableSortAscending"), 1)); if (m_liSortHistory.IsEmpty()) m_liSortHistory.AddTail(m_iCurrentSortItem); // columns settings int* piColWidths = new int[m_iColumnsTracked]; int* piColHidden = new int[m_iColumnsTracked]; INT* piColOrders = new int[m_iColumnsTracked]; ini.SerGet(true, piColWidths, m_iColumnsTracked, m_Name + _T("ColumnWidths")); ini.SerGet(true, piColHidden, m_iColumnsTracked, m_Name + _T("ColumnHidden"), 0, -1); ini.SerGet(true, piColOrders, m_iColumnsTracked, m_Name + _T("ColumnOrders")); // apply columnwidths and verify sortorder INT *piArray = new INT[m_iColumnsTracked]; for (int i = 0; i < m_iColumnsTracked; i++) { piArray[i] = i; if (piColWidths[i] >= 2) // don't allow column widths of 0 and 1 -- just because it looks very confusing in GUI SetColumnWidth(i, piColWidths[i]); int iOrder = piColOrders[i]; if (i > 0 && iOrder > 0 && iOrder < m_iColumnsTracked && iOrder != i) piArray[i] = iOrder; m_aColumns[i].iLocation = piArray[i]; } piArray[0] = 0; for (int i = 0; i < m_iColumnsTracked; i++) m_aColumns[piArray[i]].iLocation = i; pHeaderCtrl->SetOrderArray(m_iColumnsTracked, piArray); for (int i = 1; i < m_iColumnsTracked; i++) { if (piColHidden[i] > 0 || (piColHidden[i] == -1 && m_liDefaultHiddenColumns.Find(i) != NULL)) HideColumn(i); } delete[] piArray; delete[] piColOrders; delete[] piColWidths; delete[] piColHidden; // SLUGFILLER: multiSort remove - unused /* delete[] piSortHist; */ // SLUGFILLER: multiSort remove - unused // ==> Design Settings [eWombat/Stulle] - Stulle /* //Xman narrow font at transferwindow { CFont* pFont = GetFont(); LOGFONT lfFont = {0}; pFont->GetLogFont(&lfFont); _tcscpy(lfFont.lfFaceName, _T("Arial Narrow")); if(m_fontNarrow.m_hObject==NULL) m_fontNarrow.CreateFontIndirect(&lfFont); } //Xman end */ // <== Design Settings [eWombat/Stulle] - Stulle } HBITMAP LoadImageAsPARGB(LPCTSTR pszPath) { extern bool g_bGdiPlusInstalled; if (!g_bGdiPlusInstalled) return NULL; HBITMAP hbmPARGB = NULL; ULONG_PTR gdiplusToken = 0; Gdiplus::GdiplusStartupInput gdiplusStartupInput; if (Gdiplus::GdiplusStartup(&gdiplusToken, &gdiplusStartupInput, NULL) == Gdiplus::Ok) { Gdiplus::Bitmap bmp(pszPath); #if 0 Gdiplus::Rect rc(0, 0, bmp.GetWidth(), bmp.GetHeight()); // For PNGs with RGBA, it does not make any difference whether the pixel format is specified as: // // PixelFormat32bppPARGB (the supposed correct one) // PixelFormat32bppARGB (could also work) // PixelFormat32bppRGB (should not work) // PixelFormat24bppRGB (should not work at all) // // The returned bitmap always contains a correct alpha channel !? // // For ICOs with RGBA, it also does not make any difference what the pixel format is set to, the // returned bitmap is always *wrong* (no alpha). // Gdiplus::Bitmap *pBmpPARGB = bmp.Clone(rc, PixelFormat32bppPARGB); if (pBmpPARGB) { // Regardless whether a PNG or ICO was loaded and regardless what pixel format was specified, // the pixel format here is always 'PixelFormat32bppARGB' !? Gdiplus::PixelFormat pf = pBmpPARGB->GetPixelFormat(); ASSERT( pf == PixelFormat32bppARGB ); pBmpPARGB->GetHBITMAP(NULL, &hbmPARGB); delete pBmpPARGB; } #else bmp.GetHBITMAP(NULL, &hbmPARGB); #endif } Gdiplus::GdiplusShutdown(gdiplusToken); return hbmPARGB; } void CMuleListCtrl::SetColors() { m_crWindow = ::GetSysColor(COLOR_WINDOW); m_crWindowText = ::GetSysColor(COLOR_WINDOWTEXT); m_crWindowTextBk = m_crWindow; COLORREF crHighlight = ::GetSysColor(COLOR_HIGHLIGHT); CString strBkImage; LPCTSTR pszSkinProfile = thePrefs.GetSkinProfile(); if (pszSkinProfile != NULL && pszSkinProfile[0] != _T('\0')) { CString strKey(m_strSkinKey); if (strKey.IsEmpty()) strKey = _T("DefLv"); if (theApp.LoadSkinColorAlt(strKey + _T("Bk" ), _T("DefLvBk"), m_crWindow)) m_crWindowTextBk = m_crWindow; theApp.LoadSkinColorAlt(strKey + _T("Fg"), _T("DefLvFg"), m_crWindowText); theApp.LoadSkinColorAlt(strKey + _T("Hl"), _T("DefLvHl"), crHighlight); TCHAR szColor[MAX_PATH]; GetPrivateProfileString(_T("Colors"), strKey + _T("BkImg"), _T(""), szColor, _countof(szColor), pszSkinProfile); if (szColor[0] == _T('\0')) GetPrivateProfileString(_T("Colors"), _T("DefLvBkImg"), _T(""), szColor, _countof(szColor), pszSkinProfile); if (szColor[0] != _T('\0')) strBkImage = szColor; } SetBkColor(m_crWindow); SetTextBkColor(m_crWindowTextBk); SetTextColor(m_crWindowText); // Must explicitly set a NULL watermark bitmap, to clear any already set watermark bitmap. LVBKIMAGE lvimg = {0}; lvimg.ulFlags = LVBKIF_TYPE_WATERMARK; SetBkImage(&lvimg); if (!strBkImage.IsEmpty() && !g_bLowColorDesktop) { // expand any optional available environment strings TCHAR szExpSkinRes[MAX_PATH]; if (ExpandEnvironmentStrings(strBkImage, szExpSkinRes, _countof(szExpSkinRes)) != 0) strBkImage = szExpSkinRes; // create absolute path to icon resource file TCHAR szFullResPath[MAX_PATH]; if (PathIsRelative(strBkImage)) { TCHAR szSkinResFolder[MAX_PATH]; _tcsncpy(szSkinResFolder, pszSkinProfile, _countof(szSkinResFolder)); szSkinResFolder[_countof(szSkinResFolder)-1] = _T('\0'); PathRemoveFileSpec(szSkinResFolder); _tmakepathlimit(szFullResPath, NULL, szSkinResFolder, strBkImage, NULL); } else { _tcsncpy(szFullResPath, strBkImage, _countof(szFullResPath)); szFullResPath[_countof(szFullResPath)-1] = _T('\0'); } #if 0 // Explicitly check if the file exists, because 'SetBkImage' will return TRUE even if the file does not exist. if (PathFileExists(szFullResPath)) { // This places the bitmap near the bottom-right border of the client area. But due to that // the position is specified via percentages, the bitmap is never exactly at the bottom // right border, it depends on the window's height. Apart from that, the bitmap gets // scrolled(!) with the window contents. CString strUrl(_T("file:///")); strUrl += szFullResPath; if (SetBkImage(const_cast<LPTSTR>((LPCTSTR)strUrl), FALSE, 100, 92)) { m_crWindowTextBk = CLR_NONE; SetTextBkColor(m_crWindowTextBk); } } #else HBITMAP hbm = LoadImageAsPARGB(szFullResPath); if (hbm) { LVBKIMAGE lvbkimg = {0}; lvbkimg.ulFlags = LVBKIF_TYPE_WATERMARK; lvbkimg.ulFlags |= LVBKIF_FLAG_ALPHABLEND; lvbkimg.hbm = hbm; if (SetBkImage(&lvbkimg)) { m_crWindowTextBk = CLR_NONE; SetTextBkColor(m_crWindowTextBk); } else DeleteObject(lvbkimg.hbm); } #endif } m_crFocusLine = crHighlight; if (g_bLowColorDesktop) { m_crNoHighlight = crHighlight; m_crNoFocusLine = crHighlight; m_crHighlight = crHighlight; m_crHighlightText = GetSysColor(COLOR_HIGHLIGHTTEXT); m_crGlow = crHighlight; } else { m_crNoHighlight = MLC_RGBBLEND(crHighlight, m_crWindow, 8); m_crNoFocusLine = MLC_RGBBLEND(crHighlight, m_crWindow, 2); m_crHighlight = MLC_RGBBLEND(crHighlight, m_crWindow, 4); m_crHighlightText = m_crWindowText; m_crGlow = MLC_RGBBLEND(crHighlight, m_crWindow, 3); } } void CMuleListCtrl::SetSortArrow(int iColumn, ArrowType atType) { HDITEM headerItem; headerItem.mask = HDI_FORMAT; CHeaderCtrl* pHeaderCtrl = GetHeaderCtrl(); if(iColumn != m_iCurrentSortItem) { pHeaderCtrl->GetItem(m_iCurrentSortItem, &headerItem); headerItem.fmt &= ~(HDF_IMAGE | HDF_BITMAP_ON_RIGHT); pHeaderCtrl->SetItem(m_iCurrentSortItem, &headerItem); m_iCurrentSortItem = iColumn; m_imlHeaderCtrl.DeleteImageList(); } //place new arrow unless we were given an invalid column if(iColumn >= 0 && pHeaderCtrl->GetItem(iColumn, &headerItem)) { m_atSortArrow = atType; HINSTANCE hInstRes = AfxFindResourceHandle(MAKEINTRESOURCE(m_atSortArrow), RT_BITMAP); if (hInstRes != NULL){ HBITMAP hbmSortStates = (HBITMAP)::LoadImage(hInstRes, MAKEINTRESOURCE(m_atSortArrow), IMAGE_BITMAP, 0, 0, LR_CREATEDIBSECTION | LR_LOADMAP3DCOLORS); if (hbmSortStates != NULL){ CBitmap bmSortStates; bmSortStates.Attach(hbmSortStates); CImageList imlSortStates; if (imlSortStates.Create(14, 14, theApp.m_iDfltImageListColorFlags | ILC_MASK, 1, 0)){ VERIFY( imlSortStates.Add(&bmSortStates, RGB(255, 0, 255)) != -1 ); // To avoid drawing problems (which occure only with an image list *with* a mask) while // resizing list view columns which have the header control bitmap right aligned, set // the background color of the image list. if (theApp.m_ullComCtrlVer < MAKEDLLVERULL(6,0,0,0)) imlSortStates.SetBkColor(GetSysColor(COLOR_BTNFACE)); // When setting the image list for the header control for the first time we'll get // the image list of the listview control!! So, better store the header control imagelist separate. (void)pHeaderCtrl->SetImageList(&imlSortStates); m_imlHeaderCtrl.DeleteImageList(); m_imlHeaderCtrl.Attach(imlSortStates.Detach()); // Use smaller bitmap margins -- this saves some pixels which may be required for // rather small column titles. if (theApp.m_ullComCtrlVer >= MAKEDLLVERULL(5,8,0,0)){ int iBmpMargin = pHeaderCtrl->GetBitmapMargin(); int iNewBmpMargin = GetSystemMetrics(SM_CXEDGE) + GetSystemMetrics(SM_CXEDGE)/2; if (iNewBmpMargin < iBmpMargin) pHeaderCtrl->SetBitmapMargin(iNewBmpMargin); } } } } headerItem.mask |= HDI_IMAGE; headerItem.fmt |= HDF_IMAGE | HDF_BITMAP_ON_RIGHT; headerItem.iImage = 0; pHeaderCtrl->SetItem(iColumn, &headerItem); } } // move item in list, returns index of new item int CMuleListCtrl::MoveItem(int iOldIndex, int iNewIndex) { if (iNewIndex > iOldIndex) iNewIndex--; //Xman // netfinity start: Don't move item if new index is the same as the old one if(iNewIndex == iOldIndex) return iNewIndex; // netf end // copy item LVITEM lvi; TCHAR szText[256]; lvi.mask = LVIF_TEXT | LVIF_STATE | LVIF_PARAM | LVIF_INDENT | LVIF_IMAGE | LVIF_NORECOMPUTE; lvi.stateMask = (UINT)-1; lvi.iItem = iOldIndex; lvi.iSubItem = 0; lvi.pszText = szText; lvi.cchTextMax = _countof(szText); lvi.iIndent = 0; if (!GetItem(&lvi)) return -1; szText[_countof(szText) - 1] = _T('\0'); // copy strings of sub items CSimpleArray<void *> aSubItems; DWORD Style = GetStyle(); if ((Style & LVS_OWNERDATA) == 0) { TCHAR szText[256]; LVITEM lvi; lvi.mask = LVIF_TEXT | LVIF_NORECOMPUTE; lvi.iItem = iOldIndex; for (int i = 1; i < m_iColumnsTracked; i++) { lvi.iSubItem = i; lvi.cchTextMax = _countof(szText); lvi.pszText = szText; void *pstrSubItem = NULL; if (GetItem(&lvi)) { if (lvi.pszText == LPSTR_TEXTCALLBACK) pstrSubItem = LPSTR_TEXTCALLBACK; else { szText[_countof(szText) - 1] = _T('\0'); pstrSubItem = new CString(szText); } } aSubItems.Add(pstrSubItem); } } // do the move SetRedraw(FALSE); DeleteItem(iOldIndex); lvi.iItem = iNewIndex; iNewIndex = InsertItem(&lvi); // restore strings of sub items if ((Style & LVS_OWNERDATA) == 0) { for (int i = 1; i < m_iColumnsTracked; i++) { LVITEM lvi; lvi.iSubItem = i; void *pstrSubItem = aSubItems[i-1]; if (pstrSubItem != NULL) { if (pstrSubItem == LPSTR_TEXTCALLBACK) lvi.pszText = LPSTR_TEXTCALLBACK; else lvi.pszText = const_cast<LPTSTR>((LPCTSTR)*((CString *)pstrSubItem)); DefWindowProc(LVM_SETITEMTEXT, iNewIndex, (LPARAM)&lvi); if (pstrSubItem != LPSTR_TEXTCALLBACK) delete (CString *)pstrSubItem; } } } SetRedraw(TRUE); return iNewIndex; } int CMuleListCtrl::UpdateLocation(int iItem) { int iItemCount = GetItemCount(); if(iItem >= iItemCount || iItem < 0) return iItem; BOOL notLast = iItem + 1 < iItemCount; BOOL notFirst = iItem > 0; DWORD_PTR dwpItemData = GetItemData(iItem); if(dwpItemData == NULL) return iItem; if(notFirst) { int iNewIndex = iItem - 1; POSITION pos = m_Params.FindIndex(iNewIndex); // SLUGFILLER: multiSort /* int iResult = m_SortProc(dwpItemData, GetParamAt(pos, iNewIndex), m_dwParamSort); */ int iResult = MultiSortProc(dwpItemData, GetParamAt(pos, iNewIndex)); // SLUGFILLER End if(iResult < 0) { POSITION posPrev = pos; int iDist = iNewIndex / 2; while(iDist > 1) { for(int i = 0; i < iDist; i++) m_Params.GetPrev(posPrev); // SLUGFILLER: multiSort /* if(m_SortProc(dwpItemData, GetParamAt(posPrev, iNewIndex - iDist), m_dwParamSort) < 0) { */ if(MultiSortProc(dwpItemData, GetParamAt(posPrev, iNewIndex - iDist)) < 0) { // SLUGFILLER End iNewIndex = iNewIndex - iDist; pos = posPrev; } else { posPrev = pos; } iDist /= 2; } while(--iNewIndex >= 0) { m_Params.GetPrev(pos); // SLUGFILLER: multiSort /* if(m_SortProc(dwpItemData, GetParamAt(pos, iNewIndex), m_dwParamSort) >= 0) */ if(MultiSortProc(dwpItemData, GetParamAt(pos, iNewIndex)) >= 0) // SLUGFILLER End break; } MoveItem(iItem, iNewIndex + 1); return iNewIndex + 1; } } if(notLast) { int iNewIndex = iItem + 1; POSITION pos = m_Params.FindIndex(iNewIndex); // SLUGFILLER: multiSort /* int iResult = m_SortProc(dwpItemData, GetParamAt(pos, iNewIndex), m_dwParamSort); */ int iResult = MultiSortProc(dwpItemData, GetParamAt(pos, iNewIndex)); // SLUGFILLER End if(iResult > 0) { POSITION posNext = pos; int iDist = (GetItemCount() - iNewIndex) / 2; while(iDist > 1) { for(int i = 0; i < iDist; i++) m_Params.GetNext(posNext); // SLUGFILLER: multiSort /* if(m_SortProc(dwpItemData, GetParamAt(posNext, iNewIndex + iDist), m_dwParamSort) > 0) { */ if(MultiSortProc(dwpItemData, GetParamAt(posNext, iNewIndex + iDist)) > 0) { // SLUGFILLER End iNewIndex = iNewIndex + iDist; pos = posNext; } else { posNext = pos; } iDist /= 2; } while(++iNewIndex < iItemCount) { m_Params.GetNext(pos); // SLUGFILLER: multiSort /* if(m_SortProc(dwpItemData, GetParamAt(pos, iNewIndex), m_dwParamSort) <= 0) */ if(MultiSortProc(dwpItemData, GetParamAt(pos, iNewIndex)) <= 0) // SLUGFILLER End break; } MoveItem(iItem, iNewIndex); return iNewIndex; } } return iItem; } DWORD_PTR CMuleListCtrl::GetItemData(int iItem) { POSITION pos = m_Params.FindIndex(iItem); if (pos == NULL) return 0; LPARAM lParam = GetParamAt(pos, iItem); MLC_ASSERT(lParam == CListCtrl::GetItemData(iItem)); return lParam; } //lower level than everything else so poorly overriden functions don't break us BOOL CMuleListCtrl::OnWndMsg(UINT message, WPARAM wParam, LPARAM lParam, LRESULT* pResult) { //lets look for the important messages that are essential to handle switch(message) { case WM_NOTIFY: if(wParam == 0) { if(((NMHDR*)lParam)->code == NM_RCLICK) { //handle right click on headers and show column menu POINT point; GetCursorPos (&point); CTitleMenu tmColumnMenu; tmColumnMenu.CreatePopupMenu(); tmColumnMenu.AddMenuTitle(GetResString(IDS_COLUMNS)); // XP Style Menu [Xanatos] - Stulle CHeaderCtrl *pHeaderCtrl = GetHeaderCtrl(); int iCount = pHeaderCtrl->GetItemCount(); for(int iCurrent = 1; iCurrent < iCount; iCurrent++) { HDITEM item; TCHAR text[255]; item.pszText = text; item.mask = HDI_TEXT; item.cchTextMax = _countof(text); pHeaderCtrl->GetItem(iCurrent, &item); text[_countof(text) - 1] = _T('\0'); tmColumnMenu.AppendMenu(MF_STRING | (m_aColumns[iCurrent].bHidden ? 0 : MF_CHECKED), MLC_IDC_MENU + iCurrent, item.pszText); } tmColumnMenu.TrackPopupMenu(TPM_LEFTALIGN | TPM_RIGHTBUTTON, point.x, point.y, this); VERIFY( tmColumnMenu.DestroyMenu() ); return *pResult = TRUE; } else if(((NMHDR*)lParam)->code == HDN_BEGINTRACKA || ((NMHDR*)lParam)->code == HDN_BEGINTRACKW) { //stop them from changeing the size of anything "before" first column HD_NOTIFY *pHDN = (HD_NOTIFY*)lParam; if(m_aColumns[pHDN->iItem].bHidden) return *pResult = TRUE; } else if(((NMHDR*)lParam)->code == HDN_ENDDRAG) { //stop them from moving first column NMHEADER *pHeader = (NMHEADER*)lParam; if(pHeader->iItem != 0 && pHeader->pitem->iOrder != 0) { int iNewLoc = pHeader->pitem->iOrder - GetHiddenColumnCount(); if(iNewLoc > 0) { if(m_aColumns[pHeader->iItem].iLocation != iNewLoc) { if(m_aColumns[pHeader->iItem].iLocation > iNewLoc) { int iMax = m_aColumns[pHeader->iItem].iLocation; int iMin = iNewLoc; for(int i = 0; i < m_iColumnsTracked; i++) { if(m_aColumns[i].iLocation >= iMin && m_aColumns[i].iLocation < iMax) m_aColumns[i].iLocation++; } } else if(m_aColumns[pHeader->iItem].iLocation < iNewLoc) { int iMin = m_aColumns[pHeader->iItem].iLocation; int iMax = iNewLoc; for(int i = 0; i < m_iColumnsTracked; i++) { if(m_aColumns[i].iLocation > iMin && m_aColumns[i].iLocation <= iMax) m_aColumns[i].iLocation--; } } m_aColumns[pHeader->iItem].iLocation = iNewLoc; Invalidate(FALSE); break; } } } return *pResult = 1; } else if(((NMHDR*)lParam)->code == HDN_DIVIDERDBLCLICKA || ((NMHDR*)lParam)->code == HDN_DIVIDERDBLCLICKW) { // The effect of LVSCW_AUTOSIZE_USEHEADER is as follows: // If the listview control can query for all the items in a column, it is // capable of computing the minimal width needed to display the item with // the largest width. However, if the width of the header label is larger // then the largest width of the items in a column, the width of the header label // will overrule the width which would be needed for the items in the column. In // practice this means, that the column could get larger than really needed // for the items in the column (just because the width gets adjusted for also // showing the header label). // This is a good solution for some of our listviews which do not (yet) provide // the according functions which would give the listview control the chance to // query for all items in a column. This flag will thus lead to sizing the // column at least to the width of the header label. That's at least better // than resizing the column to zero width (which would be the alternative). // // Though, a few of our listviews are already capable of providing all the // information which is needed by the listview control to properly auto size // a column. Those listviews can set the 'm_iAutoSizeWidth' to 'LVSCW_AUTOSIZE' // which will lead to standard Windows behaviour. // if (GetStyle() & LVS_OWNERDRAWFIXED) { NMHEADER *pHeader = (NMHEADER*)lParam; // If the listview is empty, the LVSCW_AUTOSIZE_USEHEADER is more appropriate, even if // some listview has requested LVSCW_AUTOSIZE. SetColumnWidth(pHeader->iItem, GetItemCount() == 0 ? LVSCW_AUTOSIZE_USEHEADER : m_iAutoSizeWidth); return *pResult = 1; } } } break; case WM_COMMAND: //deal with menu clicks if(wParam == MLC_IDC_UPDATE) { UpdateLocation(lParam); return *pResult = 1; } else if(wParam >= MLC_IDC_MENU) { CHeaderCtrl *pHeaderCtrl = GetHeaderCtrl(); int iCount = pHeaderCtrl->GetItemCount(); int iToggle = wParam - MLC_IDC_MENU; if(iToggle >= iCount) break; if(m_aColumns[iToggle].bHidden) ShowColumn(iToggle); else HideColumn(iToggle); return *pResult = 1; } break; case LVM_DELETECOLUMN: if(m_aColumns != NULL) { for(int i = 0; i < m_iColumnsTracked; i++) if(m_aColumns[i].bHidden) ShowColumn(i); delete[] m_aColumns; m_aColumns = NULL; // 'new' may throw an exception } m_aColumns = new MULE_COLUMN[--m_iColumnsTracked]; for(int i = 0; i < m_iColumnsTracked; i++) { m_aColumns[i].iLocation = i; m_aColumns[i].bHidden = false; } break; case LVM_INSERTCOLUMNA: case LVM_INSERTCOLUMNW: if(m_aColumns != NULL) { for(int i = 0; i < m_iColumnsTracked; i++) if(m_aColumns[i].bHidden) ShowColumn(i); delete[] m_aColumns; m_aColumns = NULL; // 'new' may throw an exception } m_aColumns = new MULE_COLUMN[++m_iColumnsTracked]; for(int i = 0; i < m_iColumnsTracked; i++) { m_aColumns[i].iLocation = i; m_aColumns[i].bHidden = false; } break; case LVM_SETITEM: { POSITION pos = m_Params.FindIndex(((LPLVITEM)lParam)->iItem); if(pos) { m_Params.SetAt(pos, MLC_MAGIC); if (m_eUpdateMode == lazy) PostMessage(LVM_UPDATE, ((LPLVITEM)lParam)->iItem); else if (m_eUpdateMode == direct) UpdateLocation(((LPLVITEM)lParam)->iItem); } break; } case LVN_KEYDOWN: break; case LVM_SETITEMTEXT: //need to check for movement *pResult = DefWindowProc(message, wParam, lParam); if (*pResult) { if (m_eUpdateMode == lazy) PostMessage(WM_COMMAND, MLC_IDC_UPDATE, wParam); else if (m_eUpdateMode == direct) UpdateLocation(wParam); } return *pResult; case LVM_SORTITEMS: m_dwParamSort = (LPARAM)wParam; UpdateSortHistory(m_dwParamSort, 0); // SLUGFILLER: multiSort - fail-safe, ensure it's in the sort history(no inverse check) m_SortProc = (PFNLVCOMPARE)lParam; // SLUGFILLER: multiSort - hook our own callback for automatic layered sorting lParam = (LPARAM)MultiSortCallback; wParam = (WPARAM)this; // SLUGFILLER: multiSort for(POSITION pos = m_Params.GetHeadPosition(); pos != NULL; m_Params.GetNext(pos)) m_Params.SetAt(pos, MLC_MAGIC); break; case LVM_DELETEALLITEMS: if(!CListCtrl::OnWndMsg(message, wParam, lParam, pResult) && DefWindowProc(message, wParam, lParam)) m_Params.RemoveAll(); return *pResult = TRUE; case LVM_DELETEITEM: MLC_ASSERT(m_Params.GetAt(m_Params.FindIndex(wParam)) == CListCtrl::GetItemData(wParam)); if(!CListCtrl::OnWndMsg(message, wParam, lParam, pResult) && DefWindowProc(message, wParam, lParam)) m_Params.RemoveAt(m_Params.FindIndex(wParam)); return *pResult = TRUE; case LVM_INSERTITEMA: case LVM_INSERTITEMW: //try to fix position of inserted items { LPLVITEM pItem = (LPLVITEM)lParam; int iItem = pItem->iItem; int iItemCount = GetItemCount(); BOOL notLast = iItem < iItemCount; BOOL notFirst = iItem > 0; if(notFirst) { int iNewIndex = iItem - 1; POSITION pos = m_Params.FindIndex(iNewIndex); // SLUGFILLER: multiSort /* int iResult = m_SortProc(pItem->lParam, GetParamAt(pos, iNewIndex), m_dwParamSort); */ int iResult = MultiSortProc(pItem->lParam, GetParamAt(pos, iNewIndex)); // SLUGFILLER End if(iResult < 0) { POSITION posPrev = pos; int iDist = iNewIndex / 2; while(iDist > 1) { for(int i = 0; i < iDist; i++) m_Params.GetPrev(posPrev); // SLUGFILLER: multiSort /* if(m_SortProc(pItem->lParam, GetParamAt(posPrev, iNewIndex - iDist), m_dwParamSort) < 0) { */ if(MultiSortProc(pItem->lParam, GetParamAt(posPrev, iNewIndex - iDist)) < 0) { // SLUGFILLER End iNewIndex = iNewIndex - iDist; pos = posPrev; } else { posPrev = pos; } iDist /= 2; } while(--iNewIndex >= 0) { m_Params.GetPrev(pos); // SLUGFILLER: multiSort /* if(m_SortProc(pItem->lParam, GetParamAt(pos, iNewIndex), m_dwParamSort) >= 0) */ if(MultiSortProc(pItem->lParam, GetParamAt(pos, iNewIndex)) >= 0) // SLUGFILLER End break; } pItem->iItem = iNewIndex + 1; notLast = false; } } if(notLast) { int iNewIndex = iItem; POSITION pos = m_Params.FindIndex(iNewIndex); // SLUGFILLER: multiSort /* int iResult = m_SortProc(pItem->lParam, GetParamAt(pos, iNewIndex), m_dwParamSort); */ int iResult = MultiSortProc(pItem->lParam, GetParamAt(pos, iNewIndex)); // SLUGFILLER End if(iResult > 0) { POSITION posNext = pos; int iDist = (GetItemCount() - iNewIndex) / 2; while(iDist > 1) { for(int i = 0; i < iDist; i++) m_Params.GetNext(posNext); // SLUGFILLER: multiSort /* if(m_SortProc(pItem->lParam, GetParamAt(posNext, iNewIndex + iDist), m_dwParamSort) > 0) { */ if(MultiSortProc(pItem->lParam, GetParamAt(posNext, iNewIndex + iDist)) > 0) { // SLUGFILLER End iNewIndex = iNewIndex + iDist; pos = posNext; } else { posNext = pos; } iDist /= 2; } while(++iNewIndex < iItemCount) { m_Params.GetNext(pos); // SLUGFILLER: multiSort /* if(m_SortProc(pItem->lParam, GetParamAt(pos, iNewIndex), m_dwParamSort) <= 0) */ if(MultiSortProc(pItem->lParam, GetParamAt(pos, iNewIndex)) <= 0) // SLUGFILLER End break; } pItem->iItem = iNewIndex; } } if(pItem->iItem == 0) { m_Params.AddHead(pItem->lParam); return FALSE; } LRESULT lResult = DefWindowProc(message, wParam, lParam); if(lResult != -1) { if(lResult >= GetItemCount()) m_Params.AddTail(pItem->lParam); else if(lResult == 0) m_Params.AddHead(pItem->lParam); else m_Params.InsertAfter(m_Params.FindIndex(lResult - 1), pItem->lParam); } return *pResult = lResult; } break; case WM_DESTROY: //Xman 4.3 //few users had a crash on exit at this point. (in savesettings, when showing the columns) //until now I don't have any idea what's going wrong here. //because this part of code isn't a problematic one, the easiest way to avoid the crash //is a try catch try { SaveSettings(); } catch(...) { //nope } break; case LVM_UPDATE: //better fix for old problem... normally Update(int) causes entire list to redraw if (wParam == (UINT)UpdateLocation(wParam)) { //no need to invalidate rect if item moved RECT rcItem; BOOL bResult = GetItemRect(wParam, &rcItem, LVIR_BOUNDS); if(bResult) InvalidateRect(&rcItem, FALSE); return *pResult = bResult; } return *pResult = TRUE; case WM_CONTEXTMENU: // If the context menu is opened with the _mouse_ and if it was opened _outside_ // the client area of the list view, let Windows handle that message. // Otherwise we would prevent the context menu for e.g. scrollbars to be invoked. if ((HWND)wParam == m_hWnd) { CPoint ptMouse(lParam); if (ptMouse.x != -1 || ptMouse.y != -1) { ScreenToClient(&ptMouse); CRect rcClient; GetClientRect(&rcClient); if (!rcClient.PtInRect(ptMouse)) return DefWindowProc(message, wParam, lParam); } } break; } return CListCtrl::OnWndMsg(message, wParam, lParam, pResult); } void CMuleListCtrl::OnKeyDown(UINT nChar,UINT nRepCnt,UINT nFlags) { if (nChar == 'A' && ::GetAsyncKeyState(VK_CONTROL)<0) { // Ctrl+A: Select all items LVITEM theItem; theItem.mask = LVIF_STATE; theItem.iItem = -1; theItem.iSubItem = 0; theItem.state = LVIS_SELECTED; theItem.stateMask = 2; SetItemState(-1, &theItem); } else if (nChar == VK_DELETE) PostMessage(WM_COMMAND, MPG_DELETE, 0); else if (nChar == VK_F2) PostMessage(WM_COMMAND, MPG_F2, 0); else if (nChar == 'C' && (GetKeyState(VK_CONTROL) & 0x8000)) { // Ctrl+C: Copy keycombo SendMessage(WM_COMMAND, MP_COPYSELECTED); } else if (nChar == 'V' && (GetKeyState(VK_CONTROL) & 0x8000)) { // Ctrl+V: Paste keycombo SendMessage(WM_COMMAND, MP_PASTE); } else if (nChar == 'X' && (GetKeyState(VK_CONTROL) & 0x8000)) { // Ctrl+X: Paste keycombo SendMessage(WM_COMMAND, MP_CUT); } else if (m_bGeneralPurposeFind){ if (nChar == 'F' && (GetKeyState(VK_CONTROL) & 0x8000)){ // Ctrl+F: Search item OnFindStart(); } else if (nChar == VK_F3){ if (GetKeyState(VK_SHIFT) & 0x8000){ // Shift+F3: Search previous OnFindPrev(); } else{ // F3: Search next OnFindNext(); } } } return CListCtrl::OnKeyDown(nChar,nRepCnt,nFlags); } BOOL CMuleListCtrl::OnChildNotify(UINT message, WPARAM wParam, LPARAM lParam, LRESULT* pResult) { if(message != WM_DRAWITEM) { //catch the prepaint and copy struct if(message == WM_NOTIFY && ((NMHDR*)lParam)->code == NM_CUSTOMDRAW && ((LPNMLVCUSTOMDRAW)lParam)->nmcd.dwDrawStage == CDDS_ITEMPREPAINT) { m_bCustomDraw = CListCtrl::OnChildNotify(message, wParam, lParam, pResult); if(m_bCustomDraw) m_lvcd = *((LPNMLVCUSTOMDRAW)lParam); return m_bCustomDraw; } return CListCtrl::OnChildNotify(message, wParam, lParam, pResult); } ASSERT(pResult == NULL); // no return value expected DrawItem((LPDRAWITEMSTRUCT)lParam); return TRUE; } // ==> Visual Studio 2010 Compatibility [Stulle/Avi-3k/ied] - Stulle /* void CMuleListCtrl::InitItemMemDC(CMemDC *dc, LPDRAWITEMSTRUCT lpDrawItemStruct, BOOL &bCtrlFocused) */ //Xman narrow font at transferwindow /* void CMuleListCtrl::InitItemMemDC(CMemoryDC *dc, LPDRAWITEMSTRUCT lpDrawItemStruct, BOOL &bCtrlFocused) *//* void CMuleListCtrl::InitItemMemDC(CMemoryDC *dc, LPDRAWITEMSTRUCT lpDrawItemStruct, BOOL &bCtrlFocused, bool bTransferWnd) //Xman end // <== Visual Studio 2010 Compatibility [Stulle/Avi-3k/ied] - Stulle { bCtrlFocused = ((GetFocus() == this) || (GetStyle() & LVS_SHOWSELALWAYS)); if (lpDrawItemStruct->itemState & ODS_SELECTED) { if (bCtrlFocused) dc->FillBackground(m_crHighlight); else dc->FillBackground(m_crNoHighlight); } else { if (m_crWindowTextBk == CLR_NONE) { DefWindowProc(WM_ERASEBKGND, (WPARAM)(HDC)*dc, 0); dc->SetBkMode(TRANSPARENT); } else { ASSERT( m_crWindowTextBk == GetBkColor() ); dc->FillBackground(m_crWindowTextBk); } } dc->SetTextColor((lpDrawItemStruct->itemState & ODS_SELECTED) ? m_crHighlightText : m_crWindowText); //Xman narrow font at transferwindow /* dc->SetFont(GetFont()); *//* dc->SetFont((thePrefs.UseNarrowFont() && bTransferWnd) ? &m_fontNarrow : GetFont()); //Xman end } */ void CMuleListCtrl::InitItemMemDC(CMemoryDC *dc, LPDRAWITEMSTRUCT lpDrawItemStruct, BOOL &bCtrlFocused, bool bTransferWnd, int nList) { int iStyle = 0; StylesStruct style; bool bOverrideBk = false; switch(nList) { case style_b_clientlist: case style_b_queuelist: { const CUpDownClient* client = (CUpDownClient*)lpDrawItemStruct->itemData; iStyle = client->GetClientStyle(true,true,true,false); thePrefs.GetStyle(client_styles, iStyle, &style); } break; case style_b_dlclientlist: { const CUpDownClient* client = (CUpDownClient*)lpDrawItemStruct->itemData; iStyle = client->GetClientStyle(false,true,false,true); thePrefs.GetStyle(client_styles, iStyle, &style); } break; case style_b_uploadlist: { const CUpDownClient* client = (CUpDownClient*)lpDrawItemStruct->itemData; iStyle = client->GetClientStyle(true,false,true,false); thePrefs.GetStyle(client_styles, iStyle, &style); } break; case style_b_downloadlist: { int iMaster = 0; CtrlItem_Struct* content = (CtrlItem_Struct*)lpDrawItemStruct->itemData; if(content->type == FILE_TYPE) { iStyle = ((const CPartFile*)content->value)->GetPfStyle(); iMaster = download_styles; } else if(content->type == UNAVAILABLE_SOURCE || content->type == AVAILABLE_SOURCE) { iStyle = ((const CUpDownClient*)content->value)->GetClientStyle(true,true,false,true); iMaster = client_styles; } thePrefs.GetStyle(iMaster, iStyle, &style); } break; case style_b_sharedlist: { CShareableFile* file = (CShareableFile*)lpDrawItemStruct->itemData; if (file->IsKindOf(RUNTIME_CLASS(CKnownFile))) { CKnownFile* pKnownFile = (CKnownFile*)file; if(pKnownFile->IsPartFile() && thePrefs.GetStyleOnOff(share_styles, style_s_incomplete)!=0) iStyle = style_s_incomplete; else iStyle = pKnownFile->GetKnownStyle(); } else if(thePrefs.GetStyleOnOff(share_styles, style_s_shareable)!=0) iStyle = style_s_shareable; thePrefs.GetStyle(share_styles, iStyle, &style); } break; default: ASSERT( false ); // this should not happen! proceed to default case -1: thePrefs.GetStyle(master_count, 0, &style); // initialize to avoid warning break; } COLORREF crTempColor = GetBkColor(); if (nList != -1 && style.nBackColor != CLR_DEFAULT) { crTempColor = style.nBackColor; bOverrideBk = true; } bCtrlFocused = ((GetFocus() == this) || (GetStyle() & LVS_SHOWSELALWAYS)); if (lpDrawItemStruct->itemState & ODS_SELECTED) { if (bCtrlFocused) dc->FillBackground(m_crHighlight); else dc->FillBackground(m_crNoHighlight); } else { if (!bOverrideBk && m_crWindowTextBk == CLR_NONE) { DefWindowProc(WM_ERASEBKGND, (WPARAM)(HDC)*dc, 0); dc->SetBkMode(TRANSPARENT); } else { // We disable this ASSERT because we set the items background indipendently from the list background //ASSERT( m_crWindowTextBk == GetBkColor() ); dc->FillBackground(crTempColor); } } crTempColor = m_crWindowText; if(nList != -1 && style.nFontColor != CLR_DEFAULT) crTempColor = style.nFontColor; dc->SetTextColor((lpDrawItemStruct->itemState & ODS_SELECTED) ? m_crHighlightText : crTempColor); dc->SetFont((nList != -1) ? theApp.GetFontByStyle(style.nFlags, (thePrefs.UseNarrowFont() && bTransferWnd)) : GetFont()); } // <== Design Settings [eWombat/Stulle] - Stulle void CMuleListCtrl::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct) { //MORPH START - Added by SiRoB, Don't draw hidden Rect RECT clientRect; GetClientRect(&clientRect); CRect rcItem(lpDrawItemStruct->rcItem); if (rcItem.top >= clientRect.bottom || rcItem.bottom <= clientRect.top) return; //MORPH END - Added by SiRoB, Don't draw hidden Rect //set up our flicker free drawing //MORPH - Moved by SiRoB, Don't draw hidden Rect /* CRect rcItem(lpDrawItemStruct->rcItem); */ CDC *oDC = CDC::FromHandle(lpDrawItemStruct->hDC); // ==> Visual Studio 2010 Compatibility [Stulle/Avi-3k/ied] - Stulle /* CMemDC pDC(oDC, &rcItem, m_crWindow); */ CMemoryDC pDC(oDC, &rcItem, m_crWindow); // <== Visual Studio 2010 Compatibility [Stulle/Avi-3k/ied] - Stulle CFont *pOldFont = pDC->SelectObject(GetFont()); CRect rcClient; GetClientRect(&rcClient); int iItem = lpDrawItemStruct->itemID; CImageList* pImageList; CHeaderCtrl *pHeaderCtrl = GetHeaderCtrl(); //gets the item image and state info LVITEM lvi; lvi.mask = LVIF_IMAGE | LVIF_STATE; lvi.iItem = iItem; lvi.iSubItem = 0; lvi.stateMask = LVIS_DROPHILITED | LVIS_FOCUSED | LVIS_SELECTED | LVIS_GLOW; GetItem(&lvi); //see if the item be highlighted BOOL bHighlight = ((lvi.state & LVIS_DROPHILITED) || (lvi.state & LVIS_SELECTED)); BOOL bCtrlFocused = ((GetFocus() == this) || (GetStyle() & LVS_SHOWSELALWAYS)); BOOL bGlowing = ( lvi.state & LVIS_GLOW ); COLORREF crOldTextColor; if (m_bCustomDraw) { if (bHighlight) crOldTextColor = pDC->SetTextColor(g_bLowColorDesktop ? m_crHighlightText : m_lvcd.clrText); else crOldTextColor = pDC->SetTextColor(m_lvcd.clrText); } else { if (bHighlight) crOldTextColor = pDC->SetTextColor(m_crHighlightText); else crOldTextColor = pDC->SetTextColor(m_crWindowText); } //get rectangles for drawing CRect rcBounds, rcLabel, rcIcon; GetItemRect(iItem, rcBounds, LVIR_BOUNDS); GetItemRect(iItem, rcLabel, LVIR_LABEL); GetItemRect(iItem, rcIcon, LVIR_ICON); CRect rcCol(rcBounds); //the label! CString sLabel = GetItemText(iItem, 0); //labels are offset by a certain amount //this offset is related to the width of a space character CRect rcHighlight; CRect rcWnd; //should I check (GetExtendedStyle() & LVS_EX_FULLROWSELECT) ? rcHighlight.top = rcBounds.top; rcHighlight.bottom = rcBounds.bottom; rcHighlight.left = rcBounds.left; rcHighlight.right = rcBounds.right; //draw the background color if(bHighlight) { if(bCtrlFocused) { //Xman Code Improvement: FillSolidRect /* pDC->FillRect(rcHighlight, &CBrush(m_crHighlight)); */ pDC->FillSolidRect(rcHighlight, m_crHighlight); //Xman End pDC->SetBkColor(m_crHighlight); } else if(bGlowing) { //Xman Code Improvement: FillSolidRect /* pDC->FillRect(rcHighlight, &CBrush(m_crGlow)); */ pDC->FillSolidRect(rcHighlight, m_crGlow); //Xman End pDC->SetBkColor(m_crGlow); } else { //Xman Code Improvement: FillSolidRect /* pDC->FillRect(rcHighlight, &CBrush(m_crNoHighlight)); */ pDC->FillSolidRect(rcHighlight, m_crNoHighlight); //Xman End pDC->SetBkColor(m_crNoHighlight); } } else { if(bGlowing) { //Xman Code Improvement: FillSolidRect /* pDC->FillRect(rcHighlight, &CBrush(m_crGlow)); */ pDC->FillSolidRect(rcHighlight, m_crGlow); //Xman End pDC->SetBkColor(m_crGlow); } else { if (m_crWindowTextBk == CLR_NONE) DefWindowProc(WM_ERASEBKGND, (WPARAM)pDC->m_hDC, 0); else //Xman Code Improvement: FillSolidRect /* pDC->FillRect(rcHighlight, &CBrush(m_crWindow)); */ pDC->FillSolidRect(rcHighlight, m_crWindow); //Xman End pDC->SetBkColor(m_crWindow); } } //update column rcCol.right = rcCol.left + GetColumnWidth(0); //draw state icon if(lvi.state & LVIS_STATEIMAGEMASK) { int nImage = ((lvi.state & LVIS_STATEIMAGEMASK)>>12) - 1; pImageList = GetImageList(LVSIL_STATE); if(pImageList) { pImageList->Draw(pDC, nImage, rcCol.TopLeft(), ILD_TRANSPARENT); } } //draw the item's icon pImageList = GetImageList(LVSIL_SMALL); if(pImageList) { int iIconPosY = (rcItem.Height() > 16) ? ((rcItem.Height() - 16) / 2) : 0; pImageList->Draw(pDC, lvi.iImage, CPoint(rcIcon.left, rcIcon.top + iIconPosY), ILD_TRANSPARENT); } if (m_crWindowTextBk == CLR_NONE) pDC->SetBkMode(TRANSPARENT); //draw item label (column 0) rcLabel.left += sm_iLabelOffset; rcLabel.right -= sm_iLabelOffset; pDC->DrawText(sLabel, -1, rcLabel, MLC_DT_TEXT | DT_NOCLIP); //draw labels for remaining columns LVCOLUMN lvc; lvc.mask = LVCF_FMT | LVCF_WIDTH; rcBounds.right = rcHighlight.right > rcBounds.right ? rcHighlight.right : rcBounds.right; int iCount = pHeaderCtrl->GetItemCount(); for(int iCurrent = 1; iCurrent < iCount; iCurrent++) { int iColumn = pHeaderCtrl->OrderToIndex(iCurrent); //don't draw column 0 again if(iColumn == 0) continue; GetColumn(iColumn, &lvc); //don't draw anything with 0 width if(lvc.cx == 0) continue; rcCol.left = rcCol.right; rcCol.right += lvc.cx; if (rcCol.left < rcCol.right && HaveIntersection(rcClient, rcCol)) { sLabel = GetItemText(iItem, iColumn); if (sLabel.GetLength() == 0) continue; //get the text justification UINT nJustify = DT_LEFT; switch(lvc.fmt & LVCFMT_JUSTIFYMASK) { case LVCFMT_RIGHT: nJustify = DT_RIGHT; break; case LVCFMT_CENTER: nJustify = DT_CENTER; break; default: break; } rcLabel = rcCol; rcLabel.left += sm_iLabelOffset + sm_iSubItemInset; rcLabel.right -= sm_iLabelOffset + sm_iSubItemInset; pDC->DrawText(sLabel, -1, rcLabel, MLC_DT_TEXT | nJustify); } } DrawFocusRect(pDC, rcHighlight, lvi.state & LVIS_FOCUSED, bCtrlFocused, lvi.state & LVIS_SELECTED); //Xman Code Improvement //not needed /* pDC->Flush(); */ //Xman end pDC->SelectObject(pOldFont); } void CMuleListCtrl::DrawFocusRect(CDC *pDC, const CRect &rcItem, BOOL bItemFocused, BOOL bCtrlFocused, BOOL bItemSelected) { //draw focus rectangle if item has focus if (bItemFocused && (bCtrlFocused || bItemSelected)) { if (!bCtrlFocused || !bItemSelected) pDC->FrameRect(rcItem, &CBrush(m_crNoFocusLine)); else pDC->FrameRect(rcItem, &CBrush(m_crFocusLine)); } } BOOL CMuleListCtrl::OnEraseBkgnd(CDC* pDC) { // if (m_crWindowTextBk == CLR_NONE) // this creates a lot screen flickering // return CListCtrl::OnEraseBkgnd(pDC); int itemCount = GetItemCount(); if (!itemCount) return CListCtrl::OnEraseBkgnd(pDC); RECT clientRect; RECT itemRect; int topIndex = GetTopIndex(); int maxItems = GetCountPerPage(); int drawnItems = itemCount < maxItems ? itemCount : maxItems; CRect rcClip; //draw top portion GetClientRect(&clientRect); rcClip = clientRect; GetItemRect(topIndex, &itemRect, LVIR_BOUNDS); clientRect.bottom = itemRect.top; if (m_crWindowTextBk != CLR_NONE) pDC->FillSolidRect(&clientRect,GetBkColor()); else rcClip.top = itemRect.top; //draw bottom portion if we have to if(topIndex + maxItems >= itemCount) { GetClientRect(&clientRect); GetItemRect(topIndex + drawnItems - 1, &itemRect, LVIR_BOUNDS); clientRect.top = itemRect.bottom; rcClip.bottom = itemRect.bottom; if (m_crWindowTextBk != CLR_NONE) pDC->FillSolidRect(&clientRect, GetBkColor()); } //draw right half if we need to if (itemRect.right < clientRect.right) { GetClientRect(&clientRect); clientRect.left = itemRect.right; rcClip.right = itemRect.right; if (m_crWindowTextBk != CLR_NONE) pDC->FillSolidRect(&clientRect, GetBkColor()); } if (m_crWindowTextBk == CLR_NONE){ CRect rcClipBox; pDC->GetClipBox(&rcClipBox); rcClipBox.SubtractRect(&rcClipBox, &rcClip); if (!rcClipBox.IsRectEmpty()){ pDC->ExcludeClipRect(&rcClip); CListCtrl::OnEraseBkgnd(pDC); InvalidateRect(&rcClip, FALSE); } } return TRUE; } void CMuleListCtrl::OnSysColorChange() { //adjust colors CListCtrl::OnSysColorChange(); SetColors(); //redraw the up/down sort arrow (if it's there) if(m_iCurrentSortItem >= 0) SetSortArrow(m_iCurrentSortItem, (ArrowType)m_atSortArrow); if (thePrefs.GetUseSystemFontForMainControls()) { // Send a (useless) WM_WINDOWPOSCHANGED to the listview control to trigger a // WM_MEASUREITEM message which is needed to set the new item height in case // there was a font changed in the Windows System settings. // // Though it does not work as expected. Although we get the WM_MEASUREITEM and although // we return the correct (new) item height, the listview control does not redraw the // items with the new height until the control really gets resized. CRect rc; GetWindowRect(&rc); WINDOWPOS wp; wp.hwnd = m_hWnd; wp.cx = rc.Width(); wp.cy = rc.Height(); wp.flags = SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOOWNERZORDER | SWP_NOZORDER | SWP_FRAMECHANGED; SendMessage(WM_WINDOWPOSCHANGED, 0, (LPARAM)&wp); } } void CMuleListCtrl::MeasureItem(LPMEASUREITEMSTRUCT lpMeasureItemStruct) { Default(); if (thePrefs.GetUseSystemFontForMainControls()) { CDC *pDC = GetDC(); if (pDC) { CFont *pFont = GetFont(); if (pFont) { CFont *pFontOld = pDC->SelectObject(pFont); TEXTMETRIC tm; pDC->GetTextMetrics(&tm); int iNewHeight = tm.tmHeight + tm.tmExternalLeading + 1; lpMeasureItemStruct->itemHeight = max(18, iNewHeight); pDC->SelectObject(pFontOld); } ReleaseDC(pDC); } } } HIMAGELIST CMuleListCtrl::ApplyImageList(HIMAGELIST himl) { HIMAGELIST himlOld = (HIMAGELIST)SendMessage(LVM_SETIMAGELIST, LVSIL_SMALL, (LPARAM)himl); if (m_imlHeaderCtrl.m_hImageList != NULL){ // Must *again* set the image list for the header control, because LVM_SETIMAGELIST // always resets any already specified header control image lists! GetHeaderCtrl()->SetImageList(&m_imlHeaderCtrl); } return himlOld; } void CMuleListCtrl::DoFind(int iStartItem, int iDirection /*1=down, 0 = up*/, BOOL bShowError) { CWaitCursor curHourglass; if (iStartItem < 0) { MessageBeep(MB_OK); return; } int iNumItems = iDirection ? GetItemCount() : 0; int iItem = iStartItem; while ( iDirection ? iItem < iNumItems : iItem >= 0 ) { CString strItemText(GetItemText(iItem, m_iFindColumn)); if (!strItemText.IsEmpty()) { if ( m_bFindMatchCase ? _tcsstr(strItemText, m_strFindText) != NULL : stristr(strItemText, m_strFindText) != NULL ) { // Deselect all listview entries SetItemState(-1, 0, LVIS_SELECTED); // Select the found listview entry SetItemState(iItem, LVIS_SELECTED | LVIS_FOCUSED, LVIS_SELECTED | LVIS_FOCUSED); SetSelectionMark(iItem); EnsureVisible(iItem, FALSE/*bPartialOK*/); SetFocus(); return; } } if (iDirection) iItem++; else iItem--; } if (bShowError) AfxMessageBox(GetResString(IDS_SEARCH_NORESULT), MB_ICONINFORMATION); else MessageBeep(MB_OK); } void CMuleListCtrl::OnFindStart() { if (GetItemCount() == 0) { MessageBeep(MB_OK); return; } CListViewSearchDlg dlg; dlg.m_pListView = this; dlg.m_strFindText = m_strFindText; dlg.m_bCanSearchInAllColumns = m_bCanSearchInAllColumns; dlg.m_iSearchColumn = m_iFindColumn; if (dlg.DoModal() != IDOK || dlg.m_strFindText.IsEmpty()) return; m_strFindText = dlg.m_strFindText; m_iFindColumn = dlg.m_iSearchColumn; DoFindNext(TRUE/*bShowError*/); } void CMuleListCtrl::OnFindNext() { if (GetItemCount() == 0) { MessageBeep(MB_OK); return; } DoFindNext(FALSE/*bShowError*/); } void CMuleListCtrl::DoFindNext(BOOL bShowError) { int iStartItem = GetNextItem(-1, LVNI_SELECTED | LVNI_FOCUSED); if (iStartItem == -1) iStartItem = 0; else iStartItem = iStartItem + (m_iFindDirection ? 1 : -1); DoFind(iStartItem, m_iFindDirection, bShowError); } void CMuleListCtrl::OnFindPrev() { if (GetItemCount() == 0) { MessageBeep(MB_OK); return; } int iStartItem = GetNextItem(-1, LVNI_SELECTED | LVNI_FOCUSED); if (iStartItem == -1) iStartItem = 0; else iStartItem = iStartItem + (!m_iFindDirection ? 1 : -1); DoFind(iStartItem, !m_iFindDirection, FALSE/*bShowError*/); } BOOL CMuleListCtrl::PreTranslateMessage(MSG* pMsg) { if (pMsg->message == WM_SYSKEYDOWN && pMsg->wParam == VK_RETURN && GetAsyncKeyState(VK_MENU)<0) { PostMessage(WM_COMMAND, MPG_ALTENTER, 0); return TRUE; } if (m_hAccel != NULL) { if (pMsg->message >= WM_KEYFIRST && pMsg->message <= WM_KEYLAST) { // If we want to handle the VK_RETURN key, we have to do that via accelerators! if (TranslateAccelerator(m_hWnd, m_hAccel, pMsg)) return TRUE; } } // Catch the "Ctrl+<NumPad_Plus_Key>" shortcut. CMuleListCtrl can not handle this. if (pMsg->message == WM_KEYDOWN && pMsg->wParam == VK_ADD && GetAsyncKeyState(VK_CONTROL)<0) { return TRUE; } return CListCtrl::PreTranslateMessage(pMsg); } void CMuleListCtrl::AutoSelectItem() { int iItem = GetNextItem(-1, LVIS_SELECTED | LVIS_FOCUSED); if (iItem == -1) { iItem = GetNextItem(-1, LVIS_FOCUSED); if (iItem != -1) { SetItemState(iItem, LVIS_SELECTED, LVIS_SELECTED); SetSelectionMark(iItem); } } } void CMuleListCtrl::UpdateSortHistory(int dwNewOrder, int dwInverseValue){ // SLUGFILLER: multiSort - changed to >= for sort #0 /* int dwInverse = (dwNewOrder > dwInverseValue) ? (dwNewOrder-dwInverseValue) : (dwNewOrder+dwInverseValue); */ int dwInverse = (dwNewOrder >= dwInverseValue) ? (dwNewOrder-dwInverseValue) : (dwNewOrder+dwInverseValue); // SLUGFILLER End // delete the value (or its inverse sorting value) if it appears already in the list POSITION pos1, pos2; for (pos1 = m_liSortHistory.GetHeadPosition();( pos2 = pos1 ) != NULL;) { m_liSortHistory.GetNext(pos1); if (m_liSortHistory.GetAt(pos2) == dwNewOrder || m_liSortHistory.GetAt(pos2) == dwInverse) m_liSortHistory.RemoveAt(pos2); } m_liSortHistory.AddHead(dwNewOrder); // limit it to MAX_SORTORDERHISTORY entries for now, just for performance // SLUGFILLER: multiSort remove - do not limit, unlimited saving and loading available /* if (m_liSortHistory.GetSize() > MAX_SORTORDERHISTORY) m_liSortHistory.RemoveTail(); */ // SLUGFILLER End } int CMuleListCtrl::GetNextSortOrder(int dwCurrentSortOrder) const{ POSITION pos1, pos2; for (pos1 = m_liSortHistory.GetHeadPosition();( pos2 = pos1 ) != NULL;) { m_liSortHistory.GetNext(pos1); if (m_liSortHistory.GetAt(pos2) == dwCurrentSortOrder){ if (pos1 == NULL) return -1; // there is no further sortorder stored else return m_liSortHistory.GetAt(pos1); } } // current one not found, shouldn't happen // ASSERT( false ); return -1; } CMuleListCtrl::EUpdateMode CMuleListCtrl::SetUpdateMode(EUpdateMode eUpdateMode) { EUpdateMode eCurUpdateMode = m_eUpdateMode; m_eUpdateMode = eUpdateMode; return eCurUpdateMode; } void CMuleListCtrl::OnLvnGetInfoTip(NMHDR *pNMHDR, LRESULT *pResult) { // NOTE: Using 'Info Tips' for owner drawn list view controls (like almost all instances // of the CMuleListCtrl) gives potentially *wrong* results. One may and will experience // several situations where a tooltip should be shown and none will be shown. This is // because the Windows list view control code does not know anything about what the // owner drawn list view control was actually drawing. So, the Windows list view control // code is just *assuming* that the owner drawn list view control instance is using the // same drawing metrics as the Windows control. Because our owner drawn list view controls // almost always draw an additional icon before the actual item text and because the // Windows control does not know that, the calculations performed by the Windows control // regarding folded/unfolded items are in couple of cases wrong. E.g. because the Windows // control does not know about the additional icon and thus about the reduced space used // for drawing the item text, we may show folded item texts while the Windows control is // still assuming that we show the full text -> thus we will not receive a precomputed // info tip which contains the unfolded item text. Result: We would have to implement // our own info tip processing. LPNMLVGETINFOTIP pGetInfoTip = reinterpret_cast<LPNMLVGETINFOTIP>(pNMHDR); if (pGetInfoTip->iSubItem == 0) { LVHITTESTINFO hti = {0}; ::GetCursorPos(&hti.pt); ScreenToClient(&hti.pt); if (SubItemHitTest(&hti) == -1 || hti.iItem != pGetInfoTip->iItem || hti.iSubItem != 0) { // Don't show the default label tip for the main item, if the mouse is not over // the main item. if ((pGetInfoTip->dwFlags & LVGIT_UNFOLDED) == 0 && pGetInfoTip->cchTextMax > 0 && pGetInfoTip->pszText[0] != _T('\0')) { // For any reason this does not work with Win98 (COMCTL32 v5.8). Even when // the info tip text is explicitly set to empty, the list view control may // display the unfolded text for the 1st item. It though works for WinXP. pGetInfoTip->pszText[0] = _T('\0'); } return; } } *pResult = 0; } void CMuleListCtrl::SetAutoSizeWidth(int iAutoSizeWidth) { m_iAutoSizeWidth = iAutoSizeWidth; } int CMuleListCtrl::InsertColumn(int nCol, LPCTSTR lpszColumnHeading, int nFormat, int nWidth, int nSubItem , bool bHiddenByDefault) { if (bHiddenByDefault) m_liDefaultHiddenColumns.AddTail(nCol); return CListCtrl::InsertColumn(nCol, lpszColumnHeading, nFormat, nWidth, nSubItem); } // ==> XP Style Menu [Xanatos] - Stulle void CMuleListCtrl::OnMeasureItem(int nIDCtl, LPMEASUREITEMSTRUCT lpMeasureItemStruct) { HMENU hMenu = AfxGetThreadState()->m_hTrackingMenu; if(CMenu *pMenu = CMenu::FromHandle(hMenu)) pMenu->MeasureItem(lpMeasureItemStruct); CListCtrl::OnMeasureItem(nIDCtl, lpMeasureItemStruct); } LRESULT CMuleListCtrl::OnMenuChar(UINT nChar, UINT nFlags, CMenu* pMenu) { if (pMenu->IsKindOf(RUNTIME_CLASS(CTitleMenu)) ) return CTitleMenu::OnMenuChar(nChar, nFlags, pMenu); return CListCtrl::OnMenuChar(nChar, nFlags, pMenu); } // <== XP Style Menu [Xanatos] - Stulle
[ "Mike.Ken.S@dd569cc8-ff36-11de-bbca-1111db1fd05b", "[email protected]@dd569cc8-ff36-11de-bbca-1111db1fd05b" ]
[ [ [ 1, 241 ], [ 243, 259 ], [ 261, 269 ], [ 271, 802 ], [ 804, 815 ], [ 817, 830 ], [ 832, 846 ], [ 848, 859 ], [ 861, 874 ], [ 876, 1134 ], [ 1136, 1147 ], [ 1149, 1162 ], [ 1164, 1178 ], [ 1180, 1191 ], [ 1193, 1206 ], [ 1208, 1355 ], [ 1357, 1358 ], [ 1367, 1395 ], [ 1397, 1399 ], [ 1401, 1499 ], [ 1501, 1519 ], [ 1522, 1522 ], [ 1526, 1590 ], [ 1592, 1600 ], [ 1602, 1610 ], [ 1612, 1623 ], [ 1625, 1636 ], [ 1638, 2012 ], [ 2014, 2028 ], [ 2030, 2094 ], [ 2096, 2125 ] ], [ [ 242, 242 ], [ 260, 260 ], [ 270, 270 ], [ 803, 803 ], [ 816, 816 ], [ 831, 831 ], [ 847, 847 ], [ 860, 860 ], [ 875, 875 ], [ 1135, 1135 ], [ 1148, 1148 ], [ 1163, 1163 ], [ 1179, 1179 ], [ 1192, 1192 ], [ 1207, 1207 ], [ 1356, 1356 ], [ 1359, 1366 ], [ 1396, 1396 ], [ 1400, 1400 ], [ 1500, 1500 ], [ 1520, 1521 ], [ 1523, 1525 ], [ 1591, 1591 ], [ 1601, 1601 ], [ 1611, 1611 ], [ 1624, 1624 ], [ 1637, 1637 ], [ 2013, 2013 ], [ 2029, 2029 ], [ 2095, 2095 ] ] ]
c90d11219612f730bcbc4d4a4b5c7ba952aea6b0
ce10be13a62b6ed6e3ccdd0780fe98e08573166e
/include/modulegame.h
47fbe62df15a0cd18920ae835346603f058a1597
[]
no_license
pfeyssaguet/afrods
b2d63fd501a60a5c40d2d128bc03820f389c4d59
df2e85990bac4a2107bba5ad7ba9232753cf7725
refs/heads/master
2016-09-06T02:13:26.546098
2010-02-07T13:07:01
2010-02-07T13:07:01
32,130,697
0
0
null
null
null
null
UTF-8
C++
false
false
4,825
h
#ifndef __GAME_H__ #define __GAME_H__ #include "module.h" #include "map.h" #include "spritechar.h" #include "spritegameicon.h" #include "background.h" // décalage des icônes du menu en bas #define AFRODS_GAME_OFFSET_ICONS_X 216 #define AFRODS_GAME_OFFSET_ICONS_Y 8 #define AFRODS_GAME_OFFSET_ICONS_SPACE 0 // décalage du doigt vers le haut #define AFRODS_GAME_OFFSET_FINGER_Y 3 // nombre de lignes dans l'inventaire #define AFRODS_GAME_INVENTORY_NBLINES 12 #define AFRODS_GAME_SHOP_NBLINES 14 // Les différents sous-menus du shop #define MENU_GAME_BUY_STR "Buy" #define MENU_GAME_SELL_STR "Sell" #define MENU_GAME_QUIT_STR "Quit" namespace AfroDS { /** * Permet de gérer les sous-modes qu'on gère dans le module Game. * Cette enum est utilisée par la variable m_gameMode * - MODE_WALK : personnage en train de marcher * - MODE_INVENTORY : mode sélection dans l'inventaire * - MODE_EQUIPMENT : mode sélection dans l'équipement */ enum GameMode {MODE_WALK, MODE_INVENTORY, MODE_EQUIPMENT, MODE_SHOP}; enum MenuGameType {MENU_GAME_DEFAULT, MENU_GAME_BUY, MENU_GAME_SELL, MENU_GAME_QUIT}; /** * Classe Module Game */ class ModuleGame : public Module { public: /** * Lancement du module Game, création du niveau */ ModuleGame(Context * context); /** * Destructeur du module, supprime tous les sprites et backgrounds */ virtual ~ModuleGame(); /** * Gestion des événements du module Game */ void moduleEvents(); void modulePause(); void moduleResume(); private: /** * Initialisation du menu en bas : * - affichage du background * - affichage des 5 sprites de menu */ void initMenu(); /** * Initialisation du monde affiché en haut, géré * au travers de la classe Map */ void initWorld(MapWarp warp); void initConsoles(); /** * Gestion du déplacement du perso, avec scrolling en conséquence */ void moveChar(); /** * Méthode appelée lorsqu'on veut quitter le jeu */ void quit(); /** * Gestion du mode MODE_WALK : interactions : * - déplacer le personnage avec les flèches * - activer le mode MODE_INVENTORY en appuyant sur Start * - afficher les stats du personnage en cliquant sur le sprite Status * - afficher l'inventaire en cliquant sur le sprite Inventory * - afficher l'équipement en cliquant sur le sprite Equipment * - quitter le jeu en cliquant sur le sprite Quit * @return bool */ bool doModeWalk(); /** * Gestion des modes MODE_INVENTORY et MODE_EQUIPMENT : interactions : * - revenir en mode MODE_WALK en appuyant sur Start * - basculer entre MODE_INVENTORY et MODE_EQUIPMENT en appuyant sur R ou L * - naviguer dans l'inventaire ou l'équipement avec haut/bas * - équiper un item de l'inventaire avec A * - retirer un item de l'équipement avec A */ void doModeSelection(); void initShop(); void doModeShop(); /** * Affiche les stats du personnage. Correspond à l'icône "Status" du menu */ void showStatus(); /** * Affiche l'inventaire du personnage. Correspond à l'icône "Inventory" du menu */ void showInventory(); /** * Affiche l'équipement du personnage. Correspond à l'icône "Equipment" du menu */ void showEquipment(); void showShop(const MenuGameType menu); void quitShop(); void updatePositions(); void battle(); /** Console principale */ PrintConsole m_consoleMain; /** Console de description */ PrintConsole m_consoleDesc; PrintConsole m_consolePrices; /** Le mode actuel */ GameMode m_gameMode; /** L'entrée sélectionnée en mode Inventory */ unsigned int m_selectedEntry; /** Offset pour l'inventaire */ int m_offsetInventory; std::vector<MapWarp> m_doors; std::vector<std::string> m_shopMenuEntries; MenuGameType m_shopCurrentMenu; unsigned int m_shopSelectedEntry; /** Représente la map courante dans laquelle évolue le personnage principal */ Map * m_activeMap; /** Le background du bas */ Background * m_bgBottom; /** Sprite du haut : le perso */ SpriteChar * m_spritePlayer; /** Sprites du bas : icône de menu, à droite */ SpriteGameIcon * m_spriteIconStatus; SpriteGameIcon * m_spriteIconInventory; SpriteGameIcon * m_spriteIconEquipment; SpriteGameIcon * m_spriteIconOptions; SpriteGameIcon * m_spriteIconQuit; /** le sprite du doigt */ Sprite * m_spriteFinger; /** Le sprite pour l'icône de l'item sélectionné */ Sprite * m_spriteSelectedItem; }; } #endif
[ "deuspi@fce96c3e-db3a-11de-b64b-7d26b27941e2" ]
[ [ [ 1, 189 ] ] ]
6c99b1f6c6e40a260607dbd872bdf23a4e470248
9af87532952042dfa56127996e07fb9ddf23b928
/Box2D/Dynamics/Controllers/b2ConstantForceController.h
bb6b169f4c8e19b8b9478f94e6df2950b688257a
[]
no_license
fuyunkong/box2d-extended
70e7c72f7707a7598cb034b6e4e85ff39ae4db6d
4656ae96fa1a5543871334ce760a539dae39604d
refs/heads/master
2021-01-18T01:42:00.352351
2011-02-12T15:38:00
2011-02-12T15:38:00
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,756
h
/* * Copyright (c) 2006-2007 Erin Catto http://www.gphysics.com * * This software is provided 'as-is', without any express or implied * warranty. In no event will the authors be held liable for any damages * arising from the use of this software. * Permission is granted to anyone to use this software for any purpose, * including commercial applications, and to alter it and redistribute it * freely, subject to the following restrictions: * 1. The origin of this software must not be misrepresented; you must not * claim that you wrote the original software. If you use this software * in a product, an acknowledgment in the product documentation would be * appreciated but is not required. * 2. Altered source versions must be plainly marked as such, and must not be * misrepresented as being the original software. * 3. This notice may not be removed or altered from any source distribution. */ #ifndef B2_CONSTANTFORCECONTROLLER_H #define B2_CONSTANTFORCECONTROLLER_H #include <Box2D/Dynamics/Controllers/b2Controller.h> class b2ConstantForceControllerDef; /// Applies a force every frame class b2ConstantForceController : public b2Controller { public: /// The force to apply b2Vec2 F; /// @see b2Controller::Step void Step(const b2TimeStep& step); protected: void Destroy(b2BlockAllocator* allocator); private: friend class b2ConstantForceControllerDef; b2ConstantForceController(const b2ConstantForceControllerDef* def); }; /// This class is used to build constant force controllers class b2ConstantForceControllerDef : public b2ControllerDef { public: /// The force to apply b2Vec2 F; private: b2ConstantForceController* Create(b2BlockAllocator* allocator) const; }; #endif
[ [ [ 1, 54 ] ] ]
63f4c1eb904175e242a9bd2fcef1a49b751d9f0d
c1c3866586c56ec921cd8c9a690e88ac471adfc8
/Practise_2005/dshow.test.texture3d9/dshow.texture3d9.cpp
1d182651d7d1998a390d22f0d42cadbf1f98a1f3
[]
no_license
rtmpnewbie/lai3d
0802dbb5ebe67be2b28d9e8a4d1cc83b4f36b14f
b44c9edfb81fde2b40e180a651793fec7d0e617d
refs/heads/master
2021-01-10T04:29:07.463289
2011-03-22T17:51:24
2011-03-22T17:51:24
36,842,700
1
0
null
null
null
null
UTF-8
C++
false
false
4,672
cpp
#include "stdafx.h" #include "dshow.texture3d9.h" #include "Render3D9.h" #include <strsafe.h> #include <dshow.h> // Define this if you want to render only the video component with no audio // // #define NO_AUDIO_RENDERER // An application can advertise the existence of its filter graph // by registering the graph with a global Running Object Table (ROT). // The GraphEdit application can detect and remotely view the running // filter graph, allowing you to 'spy' on the graph with GraphEdit. // // To enable registration in this sample, define REGISTER_FILTERGRAPH. // #define REGISTER_FILTERGRAPH // File filter for OpenFile dialog #define FILE_FILTER_TEXT \ TEXT("Video Files (*.avi; *.qt; *.mov; *.mpg; *.mpeg; *.m1v)\0*.avi; *.qt; *.mov; *.mpg; *.mpeg; *.m1v\0")\ TEXT("Audio files (*.wav; *.mpa; *.mp2; *.mp3; *.au; *.aif; *.aiff; *.snd)\0*.wav; *.mpa; *.mp2; *.mp3; *.au; *.aif; *.aiff; *.snd\0")\ TEXT("MIDI Files (*.mid, *.midi, *.rmi)\0*.mid; *.midi; *.rmi\0") \ TEXT("Image Files (*.jpg, *.bmp, *.gif, *.tga)\0*.jpg; *.bmp; *.gif; *.tga\0") \ TEXT("All Files (*.*)\0*.*;\0\0") //extern HRESULT UpgradeGeometry( LONG lActualW, LONG lTextureW, // LONG lActualH, LONG lTextureH ); #ifdef REGISTER_FILTERGRAPH //----------------------------------------------------------------------------- // Running Object Table functions: Used to debug. By registering the graph // in the running object table, GraphEdit is able to connect to the running // graph. This code should be removed before the application is shipped in // order to avoid third parties from spying on your graph. //----------------------------------------------------------------------------- DWORD dwROTReg = 0xfedcba98; HRESULT AddToROT(IUnknown *pUnkGraph) { IMoniker * pmk; IRunningObjectTable *pROT; if (FAILED(GetRunningObjectTable(0, &pROT))) { return E_FAIL; } WCHAR wsz[256]; (void)StringCchPrintfW(wsz, NUMELMS(wsz),L"FilterGraph %08x pid %08x\0", (DWORD_PTR) 0, GetCurrentProcessId()); HRESULT hr = CreateItemMoniker(L"!", wsz, &pmk); if (SUCCEEDED(hr)) { // Use the ROTFLAGS_REGISTRATIONKEEPSALIVE to ensure a strong reference // to the object. Using this flag will cause the object to remain // registered until it is explicitly revoked with the Revoke() method. // // Not using this flag means that if GraphEdit remotely connects // to this graph and then GraphEdit exits, this object registration // will be deleted, causing future attempts by GraphEdit to fail until // this application is restarted or until the graph is registered again. hr = pROT->Register(ROTFLAGS_REGISTRATIONKEEPSALIVE, pUnkGraph, pmk, &dwROTReg); pmk->Release(); } pROT->Release(); return hr; } void RemoveFromROT(void) { IRunningObjectTable *pirot=0; if (SUCCEEDED(GetRunningObjectTable(0, &pirot))) { pirot->Revoke(dwROTReg); pirot->Release(); } } #endif //----------------------------------------------------------------------------- // Msg: Display an error message box if needed //----------------------------------------------------------------------------- void Msg(TCHAR *szFormat, ...) { TCHAR szBuffer[1024]; // Large buffer for long filenames or URLs const size_t NUMCHARS = sizeof(szBuffer) / sizeof(szBuffer[0]); const int LASTCHAR = NUMCHARS - 1; // Format the input string va_list pArgs; va_start(pArgs, szFormat); // Use a bounded buffer size to prevent buffer overruns. Limit count to // character size minus one to allow for a NULL terminating character. (void)StringCchVPrintf(szBuffer, NUMCHARS - 1, szFormat, pArgs); va_end(pArgs); // Ensure that the formatted string is NULL-terminated szBuffer[LASTCHAR] = TEXT('\0'); MessageBox(NULL, szBuffer, TEXT("DirectShow Texture3D9 Sample"), MB_OK | MB_ICONERROR); } BOOL GetClipFileName(LPTSTR szName) { OPENFILENAME ofn; ZeroMemory(&ofn, sizeof(ofn)); // Reset filename *szName = 0; // Fill in standard structure fields ofn.lStructSize = sizeof(OPENFILENAME); ofn.hwndOwner = g_hWnd; ofn.lpstrFilter = FILE_FILTER_TEXT; ofn.lpstrCustomFilter = NULL; ofn.nFilterIndex = 1; ofn.lpstrFile = szName; ofn.nMaxFile = MAX_PATH; ofn.lpstrTitle = TEXT("Open Media File...\0"); ofn.lpstrFileTitle = NULL; ofn.lpstrDefExt = TEXT("*\0"); ofn.Flags = OFN_FILEMUSTEXIST | OFN_READONLY | OFN_PATHMUSTEXIST; // Create the standard file open dialog and return its result return GetOpenFileName((LPOPENFILENAME)&ofn); }
[ "laiyanlin@27d9c402-1b7e-11de-9433-ad2e3fad96c5" ]
[ [ [ 1, 143 ] ] ]
f9602b8ff3a438b81ef1f2794e366279dfcccff4
90aa2eebb1ab60a2ac2be93215a988e3c51321d7
/castor/branches/Dev1.1/includes/higher_order.h
19a9d41a8320deaea11c93a9891aa60c5b587323
[ "LicenseRef-scancode-unknown-license-reference", "MIT" ]
permissive
roshannaik/castor
b9f4ea138a041fe8bccf2d8fc0dceeb13bcca5a6
e86e2bf893719bf3164f9da9590217c107cbd913
refs/heads/master
2021-04-18T19:24:38.612073
2010-08-18T05:10:39
2010-08-18T05:10:39
126,150,539
0
0
null
null
null
null
UTF-8
C++
false
false
972
h
// Castor : Logic Programming Library // Authored by Roshan Naik ([email protected]) // This software is goverened by the MIT license (http://www.opensource.org/licenses/mit-license.php). #if !defined CASTOR_HIGHER_ORDER_H #define CASTOR_HIGHER_ORDER_H 1 #include "coroutine.h" namespace castor { //------------------------------------------------- // zip(l,r) - succeeds each time l() and r() succeed //------------------------------------------------- template<typename L, typename R> class Zip_r : public Coroutine { L l; R r; public: Zip_r (const L& l, const R& r) : l(l), r(r) { } bool operator()(void) { co_begin(); while(true) { if(!l()) co_return(false); if(r()) { co_yield(true); } else { co_return(false); } } co_end(); } }; template<typename L, typename R> Zip_r<L,R> zip(const L& l, const R& r) { return Zip_r<L,R>(l,r); } } // namespace castor #endif
[ [ [ 1, 47 ] ] ]
0a4f51130d296b0103c6820ab0de93a7bebb311c
49b6646167284329aa8644c8cf01abc3d92338bd
/SEP2_RELEASE/Controller/Sensor.cpp
08c3ed4a4b99d7be12e72f64d30e8bcab7cdec9a
[]
no_license
StiggyB/javacodecollection
9d017b87b68f8d46e09dcf64650bd7034c442533
bdce3ddb7a56265b4df2202d24bf86a06ecfee2e
refs/heads/master
2020-08-08T22:45:47.779049
2011-10-24T12:10:08
2011-10-24T12:10:08
32,143,796
0
0
null
null
null
null
UTF-8
C++
false
false
3,610
cpp
/** * Sensor * * SE2 (+ SY and PL) Project SoSe 2011 * * Milestone 3: HAL Sensorik * * Authors: Rico Flaegel, * Tell Mueller-Pettenpohl, * Torsten Krane, * Jan Quenzel * * Class which deals with the interrupts. * * Inherits: HAWThread.h */ #include "Sensor.h" #include "../FSM/Puck_FSM.h" #include "../Tests/Test_FSM.h" #include "../FSM/Puck_FSM_1.h" #include "../FSM/Puck_FSM_2.h" #include <vector> Sensor::Sensor():cnt(0) { if (-1 == ThreadCtl(_NTO_TCTL_IO, 0)) { std::cout << "error for IO Control" << std::endl; } if (h == NULL){ h = HALCore::getInstance(); } l = Lampen::getInstance(); is_Band_has_wp_ls7 = false; mine = SENSOR; } Sensor::~Sensor() { } void Sensor::execute(void*) { if (settingUpCommunicatorDevice(INTERRUPTCONTROLLER)) { initPucks(); while (!isStopped()) { rcvid = MsgReceive(chid, r_msg, sizeof(Message), NULL); handleMessage(); } endCommunication(); }else{ perror("Sensor: Setting Up failed!"); } } void Sensor::initPucks(){ //int last_Reg_State_B = 0xD3;//defines a standard state of register B //int last_Reg_State_C = 0x50;//defines a standard state of register C cout << "Sensor: Start" << endl; /*Machine1 *fsm; fsm = new Machine1(); //fsm->setPocket();*/ std::vector<Puck_FSM*> wp_list; } void Sensor::handleNormalMessage(){ int port = 0; coid = getConnectIdForObject(INTERRUPTCONTROLLER); buildMessage(m, r_msg->m.chid, coid, OK, SENSOR); if (-1 == MsgReply(rcvid, 0, m, sizeof(Message))) { perror("Sensor: failed to send reply message to IC!"); } if (r_msg->m.ca == react) { port = INTERRUPT_D_PORT_B; } else { port = INTERRUPT_D_PORT_C_HIGH; } #ifdef TEST_FSM tests_fsm->handleSignal(r_msg->pulse.value.sival_int, port); #endif #ifdef TEST_SEN ts->test_sen_interrupt(port, r_msg->pulse.value.sival_int); #endif #ifdef TEST_IRQ interrupt(port, r_msg->pulse.value.sival_int); #endif } void Sensor::handlePulsMessage(){ std::cout << "Sensor: received a Puls, but doesn't know what to do with it" << std::endl; } void Sensor::shutdown() { } void Sensor::interrupt(int port, int val) { switch (port) { case INTERRUPT_D_PORT_B: if (!(val & BIT_WP_IN_HEIGHT)) { cout << "Sensor: WP_IN_H " << endl; } if (!(val & BIT_WP_RUN_IN)) { h->engineRight(); cout << "Sensor: BIT_WP_RUN_IN" << endl; } if (val & BIT_WP_IN_SWITCH) { if (val & BIT_SWITCH_STATUS) { h->closeSwitch(); cout << "Sensor: closes switch " << endl; } } else { if (val & BIT_WP_METAL) { if (!(val & BIT_SWITCH_STATUS)) { h->openSwitch(); cout << "Sensor: opens switch " << endl; } cout << "Sensor: ist Metall :D" << endl; } } if (!(val & BIT_WP_IN_SLIDE)) { cnt++; if(cnt == 4){ cnt = 0; l->shine(RED); h->stopMachine(); } } if (!(val & BIT_WP_OUTLET)) { h->engineReset(); cout << "Sensor: somethings coming out ;)" << endl; } break; case INTERRUPT_D_PORT_C_HIGH: if (!(val & BIT_E_STOP)) { l->shine(RED); h->emergencyStop(); } else { if (!(val & BIT_STOP)) { l->shine(RED); h->stopMachine(); } else { if (val & BIT_START) { cnt = 0; h->shineLED(START_LED); l->shine(GREEN); h->restart(); } else { h->removeLED(START_LED); if (val & BIT_RESET) { cnt = 0; h->shineLED(RESET_LED); h->resetAll(); } else { h->removeLED(RESET_LED); } } } } break; } }
[ "[email protected]@72d44fe2-11f0-84eb-49d3-ba3949d4c1b1", "[email protected]@72d44fe2-11f0-84eb-49d3-ba3949d4c1b1" ]
[ [ [ 1, 78 ], [ 80, 161 ] ], [ [ 79, 79 ] ] ]
c8212bcd66197166d2c86b8f7d1a11e0f7228709
8fcfa439a6c1ea4753ace06b87d7d49f55bdd1e6
/tgeEngine.h
558a688f16c9882dacb8efb0101beb7c23a5911a
[]
no_license
blacksqr/tge-cpp
bb3e0216830ace08d9381d14bd1916994009ba19
e51f36dcc46790ccadab2f2dcaa0849970b57eb3
refs/heads/master
2021-01-10T14:14:34.381325
2010-03-22T12:37:36
2010-03-22T12:37:36
48,471,490
0
0
null
null
null
null
UTF-8
C++
false
false
4,100
h
#pragma once #include "tgeCommon.h" #include <OgreSingleton.h> namespace tge { /** Scripting system engine */ class Engine : public Ogre::Singleton<Engine> { public: typedef std::map<String, Interpreter*> InterpreterMap; typedef std::map<ScriptIntfFactory*, Interpreter*> SIPtrInterpPtrMap; public: /** @brief Constructor. @details Upon construction, Engine will automatically create an Interpreter called "Default". And set it as the default Obj context. Note that "Obj context" is equivalent to "Interpreter" instance, they only differ literally. I use these two terms interchangably. */ Engine(void); /** Created interpreters, ScriptIntf's, ScriptIntfFactories and global commands will all be cleaned up in destruction. */ virtual ~Engine(void); /** @brief Creates an interpreter instance with a name, which could be used as its id. @details This method will throw exception if error occurs. @param name The name given to the interpreter being created. @return The pointer to the interpreter if succeeds. */ Interpreter* createInterpreter(const String& name) throw (tge::except); /** @brief Retrieves the interpreter instance with the name. @param name Name of the interpreter. @return Pointer to the interpreter instance. Or NULL if not exists. */ Interpreter* getInterpreter(const String& name) const; /** @brief Sets the default interp for Obj, this will save the workload to call Obj::setInterp() everywhere. And also makes the subsequent Engine::eval calls bound to that interpreter. @param The name of the interpreter, which will be served as the default context for later Obj manipulation. */ void setDefaultObjContext(const String& interpName); /** Retrieves the interpreter used as default. @return Pointer to the interpreter instance. */ Interpreter* getDefaultObjContext(void) const; /** @breif Registers a certain ScriptIntfFactory to a given interpreter. @details Only one instance of a factory of certain type could be registered to one interpreter. Attempts to register more than one instance of factory of same type to the same interpreter will fail. However we could register the SAME ScriptIntfFactory to different interpreters. @param factory The pointer to the specific factory instance. @param */ bool registerScriptIntfFactory(ScriptIntfFactory* factory, const String& interpreterName = String("")); bool unregisterScriptIntfFactory(ScriptIntfFactory* factory, const String& interpreterName = String("")); Result eval(const String& str, const String& interpreterName = String("")) throw(tge::except); Result eval(Obj* obj, const String& interpreterName = String("")) throw(tge::except); void setVar(const String& name, const Obj& obj); Obj& getVar(const String& name) throw(tge::except); void removeVar(const String& name); bool registerGlobalCmd(const String& cmdName, Cmd* cmd, const String& interpName = String("")); /** */ bool unregisterGlobalCmd(const String& cmdName, const String& interpName = String("")); /** Judges if a command with cmdName exists in the given interp instance with interpName. @param cmdName Name of the command. @param interpName Name of the interpreter. If omitted, default context will be used. @return True if the command exists otherwise no luck. */ bool commandExists(const String& cmdName, const String& interpName = String("")); protected: /** Dummy for now. */ void init(void); void deInit(void); protected: InterpreterMap mInterpMap; Interpreter* mDefContext; SIPtrInterpPtrMap mSItoInterpMap; }; }
[ "jeffreybian@99f00b9d-c5df-25c8-5ecf-577a790fa8fa" ]
[ [ [ 1, 96 ] ] ]
6388f8f1db0314689e0683c7389d390bb58b5c69
cd0987589d3815de1dea8529a7705caac479e7e9
/webkit/WebKit/chromium/src/DebuggerAgentManager.cpp
f7e9920e4e8d0bc36dc3d88f7b5dc2d5feb60bfa
[ "BSD-2-Clause" ]
permissive
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
11,182
cpp
/* * Copyright (C) 2010 Google Inc. 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 Google Inc. 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 * OWNER 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 "DebuggerAgentManager.h" #include "DebuggerAgentImpl.h" #include "Frame.h" #include "PageGroupLoadDeferrer.h" #include "ScriptDebugServer.h" #include "V8Proxy.h" #include "WebDevToolsAgentImpl.h" #include "WebFrameImpl.h" #include "WebViewImpl.h" #include <wtf/HashSet.h> #include <wtf/Noncopyable.h> namespace WebKit { WebDevToolsAgent::MessageLoopDispatchHandler DebuggerAgentManager::s_messageLoopDispatchHandler = 0; bool DebuggerAgentManager::s_inHostDispatchHandler = false; DebuggerAgentManager::DeferrersMap DebuggerAgentManager::s_pageDeferrers; bool DebuggerAgentManager::s_exposeV8DebuggerProtocol = false; namespace { class CallerIdWrapper : public v8::Debug::ClientData, public Noncopyable { public: CallerIdWrapper() : m_callerIsMananager(true), m_callerId(0) { } explicit CallerIdWrapper(int callerId) : m_callerIsMananager(false) , m_callerId(callerId) { } ~CallerIdWrapper() { } bool callerIsMananager() const { return m_callerIsMananager; } int callerId() const { return m_callerId; } private: bool m_callerIsMananager; int m_callerId; }; } // namespace void DebuggerAgentManager::debugHostDispatchHandler() { if (!s_messageLoopDispatchHandler || !s_attachedAgentsMap) return; if (s_inHostDispatchHandler) return; s_inHostDispatchHandler = true; Vector<WebViewImpl*> views; // 1. Disable active objects and input events. for (AttachedAgentsMap::iterator it = s_attachedAgentsMap->begin(); it != s_attachedAgentsMap->end(); ++it) { DebuggerAgentImpl* agent = it->second; s_pageDeferrers.set(agent->webView(), new WebCore::PageGroupLoadDeferrer(agent->page(), true)); views.append(agent->webView()); agent->webView()->setIgnoreInputEvents(true); } // 2. Process messages. s_messageLoopDispatchHandler(); // 3. Bring things back. for (Vector<WebViewImpl*>::iterator it = views.begin(); it != views.end(); ++it) { if (s_pageDeferrers.contains(*it)) { // The view was not closed during the dispatch. (*it)->setIgnoreInputEvents(false); } } deleteAllValues(s_pageDeferrers); s_pageDeferrers.clear(); s_inHostDispatchHandler = false; if (!s_attachedAgentsMap) { // Remove handlers if all agents were detached within host dispatch. v8::Debug::SetMessageHandler(0); v8::Debug::SetHostDispatchHandler(0); } } DebuggerAgentManager::AttachedAgentsMap* DebuggerAgentManager::s_attachedAgentsMap = 0; void DebuggerAgentManager::debugAttach(DebuggerAgentImpl* debuggerAgent) { if (!s_exposeV8DebuggerProtocol) return; if (!s_attachedAgentsMap) { s_attachedAgentsMap = new AttachedAgentsMap(); v8::Debug::SetMessageHandler2(&DebuggerAgentManager::onV8DebugMessage); v8::Debug::SetHostDispatchHandler(&DebuggerAgentManager::debugHostDispatchHandler, 100 /* ms */); } int hostId = debuggerAgent->webdevtoolsAgent()->hostId(); ASSERT(hostId); s_attachedAgentsMap->set(hostId, debuggerAgent); } void DebuggerAgentManager::debugDetach(DebuggerAgentImpl* debuggerAgent) { if (!s_exposeV8DebuggerProtocol) return; if (!s_attachedAgentsMap) { ASSERT_NOT_REACHED(); return; } int hostId = debuggerAgent->webdevtoolsAgent()->hostId(); ASSERT(s_attachedAgentsMap->get(hostId) == debuggerAgent); bool isOnBreakpoint = (findAgentForCurrentV8Context() == debuggerAgent); s_attachedAgentsMap->remove(hostId); if (s_attachedAgentsMap->isEmpty()) { delete s_attachedAgentsMap; s_attachedAgentsMap = 0; // Note that we do not empty handlers while in dispatch - we schedule // continue and do removal once we are out of the dispatch. Also there is // no need to send continue command in this case since removing message // handler will cause debugger unload and all breakpoints will be cleared. if (!s_inHostDispatchHandler) { v8::Debug::SetMessageHandler2(0); v8::Debug::SetHostDispatchHandler(0); } } else { // Remove all breakpoints set by the agent. WTF::String clearBreakpointGroupCmd = WTF::String::format( "{\"seq\":1,\"type\":\"request\",\"command\":\"clearbreakpointgroup\"," "\"arguments\":{\"groupId\":%d}}", hostId); sendCommandToV8(clearBreakpointGroupCmd, new CallerIdWrapper()); if (isOnBreakpoint) { // Force continue if detach happened in nessted message loop while // debugger was paused on a breakpoint(as long as there are other // attached agents v8 will wait for explicit'continue' message). sendContinueCommandToV8(); } } } void DebuggerAgentManager::onV8DebugMessage(const v8::Debug::Message& message) { v8::HandleScope scope; v8::String::Value value(message.GetJSON()); WTF::String out(reinterpret_cast<const UChar*>(*value), value.length()); // If callerData is not 0 the message is a response to a debugger command. if (v8::Debug::ClientData* callerData = message.GetClientData()) { CallerIdWrapper* wrapper = static_cast<CallerIdWrapper*>(callerData); if (wrapper->callerIsMananager()) { // Just ignore messages sent by this manager. return; } DebuggerAgentImpl* debuggerAgent = debuggerAgentForHostId(wrapper->callerId()); if (debuggerAgent) debuggerAgent->debuggerOutput(out); else if (!message.WillStartRunning()) { // Autocontinue execution if there is no handler. sendContinueCommandToV8(); } return; } // Otherwise it's an event message. ASSERT(message.IsEvent()); // Ignore unsupported event types. if (message.GetEvent() != v8::AfterCompile && message.GetEvent() != v8::Break && message.GetEvent() != v8::Exception) return; v8::Handle<v8::Context> context = message.GetEventContext(); // If the context is from one of the inpected tabs it should have its context // data. if (context.IsEmpty()) { // Unknown context, skip the event. return; } // If the context is from one of the inpected tabs or injected extension // scripts it must have hostId in the data field. int hostId = WebCore::V8Proxy::contextDebugId(context); if (hostId != -1) { DebuggerAgentImpl* agent = debuggerAgentForHostId(hostId); if (agent) { if (agent->autoContinueOnException() && message.GetEvent() == v8::Exception) { sendContinueCommandToV8(); return; } agent->debuggerOutput(out); return; } } if (!message.WillStartRunning()) { // Autocontinue execution on break and exception events if there is no // handler. sendContinueCommandToV8(); } } void DebuggerAgentManager::pauseScript() { v8::Debug::DebugBreak(); } void DebuggerAgentManager::executeDebuggerCommand(const WTF::String& command, int callerId) { sendCommandToV8(command, new CallerIdWrapper(callerId)); } void DebuggerAgentManager::setMessageLoopDispatchHandler(WebDevToolsAgent::MessageLoopDispatchHandler handler) { s_messageLoopDispatchHandler = handler; } void DebuggerAgentManager::setExposeV8DebuggerProtocol(bool value) { s_exposeV8DebuggerProtocol = value; WebCore::ScriptDebugServer::shared().setEnabled(!s_exposeV8DebuggerProtocol); } void DebuggerAgentManager::setHostId(WebFrameImpl* webframe, int hostId) { ASSERT(hostId > 0); WebCore::V8Proxy* proxy = WebCore::V8Proxy::retrieve(webframe->frame()); if (proxy) proxy->setContextDebugId(hostId); } void DebuggerAgentManager::onWebViewClosed(WebViewImpl* webview) { if (s_pageDeferrers.contains(webview)) { delete s_pageDeferrers.get(webview); s_pageDeferrers.remove(webview); } } void DebuggerAgentManager::onNavigate() { if (s_inHostDispatchHandler) DebuggerAgentManager::sendContinueCommandToV8(); } void DebuggerAgentManager::sendCommandToV8(const WTF::String& cmd, v8::Debug::ClientData* data) { v8::Debug::SendCommand(reinterpret_cast<const uint16_t*>(cmd.characters()), cmd.length(), data); } void DebuggerAgentManager::sendContinueCommandToV8() { WTF::String continueCmd("{\"seq\":1,\"type\":\"request\",\"command\":\"continue\"}"); sendCommandToV8(continueCmd, new CallerIdWrapper()); } DebuggerAgentImpl* DebuggerAgentManager::findAgentForCurrentV8Context() { if (!s_attachedAgentsMap) return 0; ASSERT(!s_attachedAgentsMap->isEmpty()); WebCore::Frame* frame = WebCore::V8Proxy::retrieveFrameForEnteredContext(); if (!frame) return 0; WebCore::Page* page = frame->page(); for (AttachedAgentsMap::iterator it = s_attachedAgentsMap->begin(); it != s_attachedAgentsMap->end(); ++it) { if (it->second->page() == page) return it->second; } return 0; } DebuggerAgentImpl* DebuggerAgentManager::debuggerAgentForHostId(int hostId) { if (!s_attachedAgentsMap) return 0; return s_attachedAgentsMap->get(hostId); } } // namespace WebKit
[ [ [ 1, 309 ] ] ]
225454058555099d2c495b22b86301607ab89b92
7707c79fe6a5b216a62bb175133249663a0fa12b
/trunk/Shape.h
099138397b8edb37c8e3e1834e2388914f455896
[]
no_license
BackupTheBerlios/freepcb-svn
51be4b266e80f336045e2242b3388928c0b731f1
0ae28845832421c80bbdb10eae514a6e13d01034
refs/heads/master
2021-01-20T12:42:11.484059
2010-06-03T04:43:44
2010-06-03T04:43:44
40,441,767
0
0
null
null
null
null
UTF-8
C++
false
false
6,266
h
// Shape.h : interface for the CShape class // #pragma once #include "stdafx.h" #include "PolyLine.h" #include "DisplayList.h" #include "SMFontUtil.h" #include "TextList.h" class CTextList; #define CENTROID_WIDTH 40*NM_PER_MIL // width of centroid symbol #define DEFAULT_GLUE_WIDTH 15*NM_PER_MIL // width of default glue spot // pad shapes enum { PAD_NONE = 0, PAD_ROUND, PAD_SQUARE, PAD_RECT, PAD_RRECT, PAD_OVAL, PAD_OCTAGON, PAD_DEFAULT = 99 }; // pad area connect flags enum { PAD_CONNECT_DEFAULT = 0, PAD_CONNECT_NEVER, PAD_CONNECT_THERMAL, PAD_CONNECT_NOTHERMAL }; // error returns enum { PART_NOERR = 0, PART_ERR_TOO_MANY_PINS }; // centroid types enum CENTROID_TYPE { CENTROID_DEFAULT = 0, // center of pads CENTROID_DEFINED // defined by user }; // glue spot position types enum GLUE_POS_TYPE { GLUE_POS_CENTROID, // at centroid GLUE_POS_DEFINED // defined by user }; // structure describing pad flags struct flag { unsigned int mask : 1; unsigned int area : 2; }; // structure describing adhesive spot struct glue { GLUE_POS_TYPE type; int w, x_rel, y_rel; }; // structure describing stroke (ie. line segment) struct stroke { int w, xi, yi, xf, yf; // thickness + endpoints int type; // CDisplayList g_type dl_element * dl_el; // pointer to graphic element for stroke; }; // structure describing mounting hole // only used during conversion of Ivex files struct mtg_hole { int pad_shape; // used for pad on top and bottom int x, y, diam, pad_diam; }; // structure describing pad class pad { public: pad(); BOOL operator==(pad p); int shape; // see enum above int size_l, size_r, size_h, radius; int connect_flag; // only for copper pads }; // padstack is pads and hole associated with a pin class padstack { public: padstack(); BOOL operator==(padstack p); BOOL exists; // only used when converting Ivex footprints or editing CString name; // identifier such as "1" or "B24" int hole_size; // 0 = no hole (i.e SMT) int x_rel, y_rel; // position relative to part origin int angle; // orientation: 0=left, 90=top, 180=right, 270=bottom pad top, top_mask, top_paste; pad bottom, bottom_mask, bottom_paste; pad inner; }; // CShape class represents a footprint // class CShape { // if variables are added, remember to modify Copy! public: enum { MAX_NAME_SIZE = 59 }; // max. characters enum { MAX_PIN_NAME_SIZE = 39 }; enum { MAX_VALUE_SIZE = 39 }; CString m_name; // name of shape (e.g. "DIP20") CString m_author; CString m_source; CString m_desc; int m_units; // units used for original definition (MM, NM or MIL) int m_sel_xi, m_sel_yi, m_sel_xf, m_sel_yf; // selection rectangle int m_ref_size, m_ref_xi, m_ref_yi, m_ref_angle; // ref text int m_ref_w; // thickness of stroke for ref text int m_value_size, m_value_xi, m_value_yi, m_value_angle; // value text int m_value_w; // thickness of stroke for value text CENTROID_TYPE m_centroid_type; // type of centroid int m_centroid_x, m_centroid_y; // position of centroid int m_centroid_angle; // angle of centroid (CCW) CArray<padstack> m_padstack; // array of padstacks for shape CArray<CPolyLine> m_outline_poly; // array of polylines for part outline CTextList * m_tl; // list of text strings CArray<glue> m_glue; // array of adhesive dots public: CShape(); ~CShape(); void Clear(); int MakeFromString( CString name, CString str ); int MakeFromFile( CStdioFile * in_file, CString name, CString file_path, int pos ); int WriteFootprint( CStdioFile * file ); int GetNumPins(); int GetPinIndexByName( LPCTSTR name ); CString GetPinNameByIndex( int index ); CRect GetBounds( BOOL bIncludeLineWidths=TRUE ); CRect GetCornerBounds(); CRect GetPadBounds( int i ); CRect GetPadRowBounds( int i, int num ); CPoint GetDefaultCentroid(); CRect GetAllPadBounds(); int Copy( CShape * shape ); // copy all data from shape BOOL Compare( CShape * shape ); // compare shapes, return true if same HENHMETAFILE CreateMetafile( CMetaFileDC * mfDC, CDC * pDC, int x_size, int y_size ); HENHMETAFILE CreateWarningMetafile( CMetaFileDC * mfDC, CDC * pDC, int x_size, int y_size ); }; // CEditShape class represents a footprint whose elements can be edited // class CEditShape : public CShape { public: CEditShape(); ~CEditShape(); void Clear(); void Draw( CDisplayList * dlist, SMFontUtil * fontutil ); void Undraw(); void Copy( CShape * shape ); void SelectPad( int i ); void StartDraggingPad( CDC * pDC, int i ); void CancelDraggingPad( int i ); void StartDraggingPadRow( CDC * pDC, int i, int num ); void CancelDraggingPadRow( int i, int num ); void SelectRef(); void StartDraggingRef( CDC * pDC ); void CancelDraggingRef(); void SelectValue(); void StartDraggingValue( CDC * pDC ); void CancelDraggingValue(); void SelectAdhesive( int idot ); void StartDraggingAdhesive( CDC * pDC, int idot ); void CancelDraggingAdhesive( int idot ); void SelectCentroid(); void StartDraggingCentroid( CDC * pDC ); void CancelDraggingCentroid(); void ShiftToInsertPadName( CString * astr, int n ); BOOL GenerateSelectionRectangle( CRect * r ); public: CDisplayList * m_dlist; CArray<dl_element*> m_hole_el; // hole display element CArray<dl_element*> m_pad_top_el; // top pad display element CArray<dl_element*> m_pad_inner_el; // inner pad display element CArray<dl_element*> m_pad_bottom_el; // bottom pad display element CArray<dl_element*> m_pad_top_mask_el; CArray<dl_element*> m_pad_top_paste_el; CArray<dl_element*> m_pad_bottom_mask_el; CArray<dl_element*> m_pad_bottom_paste_el; CArray<dl_element*> m_pad_sel; // pad selector CArray<dl_element*> m_ref_el; // strokes for "REF" dl_element * m_ref_sel; // ref selector CArray<dl_element*> m_value_el; // strokes for "VALUE" dl_element * m_value_sel; // value selector dl_element * m_centroid_el; // centroid dl_element * m_centroid_sel; // centroid selector CArray<dl_element*> m_dot_el; // adhesive dots CArray<dl_element*> m_dot_sel; // adhesive dot selectors };
[ "allanwright@21cd2c34-3bff-0310-83e0-c30e317e0b48" ]
[ [ [ 1, 215 ] ] ]
762f3ccff06beed439e87f7ca9771da625ccf0a3
fb71c08b1c1e7ea4d7abc82e65b36272069993e1
/src/CAnimation.cpp
d272127dbd09de18dd442bb349d9fc485e71a368
[]
no_license
cezarygerard/fpteacher
1bb4ea61bc86cbadcf47a810c8bb441f598d278a
7bdfcf7c047caa9382e22a9d26a2d381ce2d9166
refs/heads/master
2021-01-23T03:47:54.994165
2010-03-25T01:12:04
2010-03-25T01:12:04
39,897,391
0
0
null
null
null
null
UTF-8
C++
false
false
4,316
cpp
/**\file * @author Sebastian Luczak * @date 2009.12.30 * @version 0.6 * @brief klasa CAnimation opakowuje animacje, odwolania do niej zwiazane sa z odtwarzaniem animacji * * */ #include "CAnimation.hpp" using namespace logging; CAnimation::~CAnimation() { releaseAnimation(); CLog::getInstance()->sss << "CAnimation::~CAnimation: Destruktor CAnimation" << endl; logs(CLog::getInstance()->sss.str(), INFO); } // konstruktor domyslny CAnimation::CAnimation() : numberOfFrames_(0) { CLog::getInstance()->sss << "CAnimation::CAnimation: Konstruktor CAnimation" << endl; logs(CLog::getInstance()->sss.str(), INFO); } // konstruktor z pliku CAnimation::CAnimation(const string filename) : numberOfFrames_(0) { CLog::getInstance()->sss << "CAnimation::CAnimation: Konstruktor CAnimation z pliku" << endl; logs(CLog::getInstance()->sss.str(), INFO); openFile(filename); } // metoda otwierajaca plik i pobierajaca z niej animacje bool CAnimation::openFile(const string filename) { string s; string filename_prefix; size_t found; // pozyskanie prefiksu folderu z animacja found = filename.find_last_of("."); animSetName_ = filename.substr( 0, found ); animSetName_.append(".png"); //cout << animSetName_ << endl; // kolejka FIFO zawierajaca odstepy miedzy klatkami queue<float> temp_delays; // szerokosc paska animacji int slice_w; { ifstream in(filename.c_str()); if(!in) { loadDefault(); return true; } // proste pobieranie danych ze strumienia oparte na poszukiwaniu znacznikow while( getline(in, s) ) { istringstream data(s); string token; // pobierz ze strumienia pierwsza dana, ktora powinna byc token'em data >> token; //cout << token << endl; if( token == "SLICE_W") { //przytnij data.ignore(20, '='); //pobierz szerokosc paska data >> slice_w; //cout << slice_w << endl; } else if( token == "NUMOFFRAMES") { //przytnij data.ignore(20, '='); //pobierz liczbe klatek data >> skipws >> numberOfFrames_; //cout << numberOfFrames_ << endl; } else if( token == "DELAYS") { //przytnij data.ignore(20, '='); //pobierz kolejne czasy klatek for(int i = 1; i <= numberOfFrames_; i++) { float delay; // i wstaw do kolejki z pominieciem bialych znakow data >> skipws >> delay; temp_delays.push(delay); //cout << delay << endl; } } } } // Ciecie plikow graficznych HCSprite temp_sprite_handle; //kolejno stworz CSprite'y skladowe animacji i przypisz odpowiadajace im czasy trwania klatek for( int i = 1; i <= numberOfFrames_; i++) { temp_sprite_handle = CSpriteMgr::getInstance()->getCSprite(animSetName_, i, slice_w); animSet_.push_back(std::make_pair(temp_sprite_handle, temp_delays.front())); temp_delays.pop(); } if(numberOfFrames_ == static_cast<int>(animSet_.size() ) ) { CLog::getInstance()->sss << "CAnimation::openFile: Ladowanie animacji sie powiodlo." << endl; logs(CLog::getInstance()->sss.str(), INFO); return true; } else { CLog::getInstance()->sss << "CAnimation::openFile: Ladowanie animacji sie nie powiodlo!" << endl; logs(CLog::getInstance()->sss.str(), ERR); return false; } } void CAnimation::loadDefault() { numberOfFrames_ = 1; animSet_.push_back(std::make_pair(CSpriteMgr::getInstance()->getCSprite("default"), 0.f)); } // zwolnij wektor z uchwytami do klatek animacji i odstepami void CAnimation::releaseAnimation() { animSet_.erase(animSet_.begin(), animSet_.end()); animSet_.clear(); CLog::getInstance()->sss << "CAnimation::releaseAnimation: Wektor uchwytow zniszczony" << endl; logs(CLog::getInstance()->sss.str(), INFO); } // pobierz opoznienie dla danej ramki float CAnimation::getDelayOf(int frame) const { return animSet_[frame].second; } // pobierz liczbe klatek animacji int CAnimation::getNoOfAnimationFrames() const { return numberOfFrames_; } // pobierz nazwe animacji const string& CAnimation::getAnimationName() const { return animSetName_; } // pobierz pare sprite + jego opoznienie const vector< pair< HCSprite, float > >& CAnimation::getAnimSet() const { return animSet_; } //~~CAnimation.cpp
[ "fester3000@8e29c490-c8d6-11de-b6dc-25c59a28ecba" ]
[ [ [ 1, 162 ] ] ]
c63b6c827bb9c53e5519d35e361cead5fa6221b6
ea12fed4c32e9c7992956419eb3e2bace91f063a
/zombie/code/nebula2/inc/gui/nguicanvas.h
07b25e40318bf1de126fe99a2b678cd3909e14ca
[]
no_license
ugozapad/TheZombieEngine
832492930df28c28cd349673f79f3609b1fe7190
8e8c3e6225c2ed93e07287356def9fbdeacf3d6a
refs/heads/master
2020-04-30T11:35:36.258363
2011-02-24T14:18:43
2011-02-24T14:18:43
null
0
0
null
null
null
null
UTF-8
C++
false
false
9,418
h
#ifndef N_GUICANVAS_H #define N_GUICANVAS_H //------------------------------------------------------------------------------ /** A GuiWidget which enables the user to draw curves and text (C) 2004 RadonLabs GmbH */ #include "gui/nguiwidget.h" #include "mathlib/vector.h" #include "mathlib/line.h" #include "gui/nguitextbutton.h" #include "gui/nguiserver.h" class nGuiButton; class nGuiFormLayout; class nGuiCanvas : public nGuiWidget { public: class LineArray; class Text; /// Constructor nGuiCanvas(); /// Destructor virtual ~nGuiCanvas(); /// called when widget is becoming visible virtual void OnShow(); /// called when widget is becoming invisible virtual void OnHide(); /// render the window and all contained widgets virtual bool Render(); /// Called if the position or size of the canvas has changed virtual void OnRectChange(const rectangle& newRect); /// Called when the window gets focus virtual void OnObtainFocus(); /// Begin construction a curve void BeginCurve(vector4 col); /// End construction of a curve void EndCurve(); /// Append new line to curve void AppendLineToCurve(line2 line); /// Add a new text label void AddLabel(const char* text, vector2 pos, vector4 col, const char* font); /// Get the rectangle of a label rectangle GetLabelRect(int id); /// Get number of curves on canvas int GetCurveCount() const; /// Get number of textlabels on canvas int GetLabelCount() const; // Embedded class, represents a textlabel on the canvas class Text { public: /// Constructor Text(); /// Constructor Text(const nString& cont, const vector2& pos, const vector4& col, int id, const char* font); /// Destructor ~Text(); /// Set the font for this label void SetFont(const char* font); /// Get the font for this label const nString& GetFont() const; /// Set the position of this label void SetPosition(const vector2& pos); /// Get the position of this label const vector2& GetPosition() const; /// Set the textcolor of this label void SetColor(const vector4& col); /// Get the textcolor of this label const vector4& GetColor() const; /// Set the content of this label void SetContent(const nString& cont); /// Get the content of this label const nString& GetContent() const; /// Get the id of this label const int GetID() const; private: int id; vector4 color; vector2 position; nString content; nString font; }; // Embedded class, represents one curve on the canvas class LineArray { public: /// Constructor LineArray(); /// Constructor LineArray(line2 line, const vector4 col, int id); /// Destructor ~LineArray(); /// Get the ID of this curve const int GetID() const; /// Set the color of this curve void SetColor(const vector4& col); /// Get the color of this curve const vector4& GetColor() const; /// Append a line to the curve void AppendLineToCurve(line2 line); /// Get a specific curve nArray<line2> GetCurve(); private: int id; nArray<line2> curve; vector4 color; }; protected: /// Update the Canvas void Update(); private: struct curveDesc { int first; int num; vector4 color; }; nArray< LineArray* > curvearray; nArray< Text* > textarray; nArray< curveDesc > curveDescArray; bool inCurve; bool isDirty; int activeCurveID; vector2* vertexPtr; vector2* vertexBasePtr; vector4 currentCurveColor; }; //------------------------------------------------------------------------------ /** */ inline nGuiCanvas::nGuiCanvas() : isDirty(true), vertexBasePtr(0), vertexPtr(0) { // empty } //------------------------------------------------------------------------------ /** */ inline nGuiCanvas::~nGuiCanvas() { n_delete[] this->vertexBasePtr; this->vertexBasePtr = 0; } //------------------------------------------------------------------------------ /** */ inline int nGuiCanvas::GetCurveCount() const { return this->curvearray.Size(); } //------------------------------------------------------------------------------ /** */ inline void nGuiCanvas::AppendLineToCurve(line2 line) { this->isDirty = true; n_assert( this->inCurve ); n_assert( this->activeCurveID >= 0 ); if ( this->activeCurveID == this->curvearray.Size() ) { nGuiCanvas::LineArray* thecurve = n_new nGuiCanvas::LineArray(line, this->currentCurveColor, this->activeCurveID); this->curvearray.Append(thecurve); } else { curvearray.At( this->activeCurveID )->AppendLineToCurve( line ); } } //------------------------------------------------------------------------------ /** */ inline int nGuiCanvas::GetLabelCount() const { return this->textarray.Size(); } //------------------------------------------------------------------------------ /** */ inline nGuiCanvas::Text::Text() : color(vector4(0.0f, 0.0f, 0.0f, 1.0f)), font("GuiDefault") { // empty } //------------------------------------------------------------------------------ /** */ inline const nString& nGuiCanvas::Text::GetFont() const { return font; } //------------------------------------------------------------------------------ /** */ inline nGuiCanvas::Text::Text(const nString& cont, const vector2& pos, const vector4& col, int id, const char* font) : content(cont), position(pos), color(col), id(id), font(font) { // empty } //------------------------------------------------------------------------------ /** */ inline nGuiCanvas::Text::~Text() { // empty } //------------------------------------------------------------------------------ /** */ inline void nGuiCanvas::Text::SetFont(const char* font) { this->font=font; } //------------------------------------------------------------------------------ /** */ inline const int nGuiCanvas::Text::GetID() const { return this->id; } //------------------------------------------------------------------------------ /** */ inline const vector2& nGuiCanvas::Text::GetPosition() const { return this->position; } //------------------------------------------------------------------------------ /** */ inline void nGuiCanvas::Text::SetPosition(const vector2& pos) { this->position = pos; } //------------------------------------------------------------------------------ /** */ inline void nGuiCanvas::Text::SetColor(const vector4& col) { this->color = col; } //------------------------------------------------------------------------------ /** */ inline const vector4& nGuiCanvas::Text::GetColor() const { return this->color; } //------------------------------------------------------------------------------ /** */ inline void nGuiCanvas::Text::SetContent(const nString& cont) { this->content = cont; } //------------------------------------------------------------------------------ /** */ inline const nString& nGuiCanvas::Text::GetContent() const { return this->content; } //------------------------------------------------------------------------------ /** */ inline nGuiCanvas::LineArray::LineArray() : color(vector4(0.0f, 0.0f, 0.0f, 1.0f)), id(0) { // empty } //------------------------------------------------------------------------------ /** */ inline nGuiCanvas::LineArray::LineArray(line2 line, const vector4 col, int id) : color(col), id(id) { this->AppendLineToCurve(line); this->SetColor(col); } //------------------------------------------------------------------------------ /** */ inline nGuiCanvas::LineArray::~LineArray() { // empty } //------------------------------------------------------------------------------ /** */ inline nArray<line2> nGuiCanvas::LineArray::GetCurve() { return this->curve; } //------------------------------------------------------------------------------ /** */ inline const int nGuiCanvas::LineArray::GetID() const { return this->id; } //------------------------------------------------------------------------------ /** */ inline void nGuiCanvas::LineArray::SetColor(const vector4& col) { this->color = col; } //------------------------------------------------------------------------------ /** */ inline const vector4& nGuiCanvas::LineArray::GetColor() const { return this->color; } //------------------------------------------------------------------------------ /** */ inline void nGuiCanvas::LineArray::AppendLineToCurve(line2 line) { this->curve.Append(line); } #endif
[ "magarcias@c1fa4281-9647-0410-8f2c-f027dd5e0a91" ]
[ [ [ 1, 428 ] ] ]
0511df616db79e62054d580c7857ea59693fe0f6
3cfa229d1d57ce69e0e83bc99c3ca1d005ae38ad
/glome/common/DefaultFile.cpp
896b54bcb6267f460803bf7c990360f737202516
[]
no_license
chadaustin/sphere
33fc2fe65acf2eb56e35ade3619643faaced7021
0d74cfb268c16d07ebb7cb2540b7b0697c2a127a
refs/heads/master
2021-01-10T13:28:33.766988
2009-11-08T00:38:57
2009-11-08T00:38:57
36,419,098
2
1
null
null
null
null
UTF-8
C++
false
false
1,351
cpp
#include "DefaultFile.hpp" //////////////////////////////////////////////////////////////////////////////// void DefaultFile::Close() { fclose(m_file); delete this; } //////////////////////////////////////////////////////////////////////////////// int DefaultFile::Read(void* bytes, int size) { return fread(bytes, 1, size, m_file); } //////////////////////////////////////////////////////////////////////////////// int DefaultFile::Write(const void* bytes, int size) { return fwrite(bytes, 1, size, m_file); } //////////////////////////////////////////////////////////////////////////////// int DefaultFile::Size() { long pos = ftell(m_file); fseek(m_file, 0, SEEK_END); int end = ftell(m_file); fseek(m_file, pos, SEEK_SET); return end; } //////////////////////////////////////////////////////////////////////////////// int DefaultFile::Tell() { return ftell(m_file); } //////////////////////////////////////////////////////////////////////////////// void DefaultFile::Seek(int position) { fseek(m_file, position, SEEK_SET); } //////////////////////////////////////////////////////////////////////////////// DefaultFile::DefaultFile(FILE* file) { m_file = file; } ////////////////////////////////////////////////////////////////////////////////
[ "surreality@c0eb2ce6-7f40-480a-a1e0-6c4aea08c2c2" ]
[ [ [ 1, 64 ] ] ]
e147fd908a0282f2ad36460a1ead514e16c4e40a
5ff30d64df43c7438bbbcfda528b09bb8fec9e6b
/kgraphics/math/Lagrange.h
b41c74778efbcf11ae9dbffc67c42bae237cf508
[]
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
1,079
h
#pragma once #include <kgraphics/math/Writer.h> #include <kgraphics/math/Vector3.h> namespace gfx { /** * @class Lagrange * * Piecewise Lagrangely interpolated spline */ class Lagrange { public: // constructor/destructor Lagrange(); ~Lagrange(); // text output (for debugging) friend Writer& operator<<( Writer& out, const Lagrange& source ); // set up bool Initialize( const Vector3* samples, const float* times, unsigned int count ); // destroy void Clean(); // evaluate position Vector3 Evaluate( float t ); protected: Vector3* mPositions; // sample points float* mTimes; // time to arrive at each point float* mDenomRecip;// 1/lagrange denomenator for each point unsigned int mCount; // number of points and times private: // copy operations // made private so they can't be used Lagrange( const Lagrange& other ); Lagrange& operator=( const Lagrange& other ); }; } // namespace gfx
[ "keedongpark@keedongpark" ]
[ [ [ 1, 46 ] ] ]
3e7d599a40b0da73b5265a448d15633c872c921c
d752d83f8bd72d9b280a8c70e28e56e502ef096f
/Extensions/CUDA/EpochCUDA/CUDA Wrapper/Naming.h
8876c6966ef3d6d53c9055412fd4df8f0fd728b2
[]
no_license
apoch/epoch-language.old
f87b4512ec6bb5591bc1610e21210e0ed6a82104
b09701714d556442202fccb92405e6886064f4af
refs/heads/master
2021-01-10T20:17:56.774468
2010-03-07T09:19:02
2010-03-07T09:19:02
34,307,116
0
0
null
null
null
null
UTF-8
C++
false
false
294
h
// // The Epoch Language Project // CUDA Interoperability Library // // Helper routines for generating identifier names // #pragma once // Dependencies #include "Language Extensions/HandleTypes.h" std::string GenerateFunctionName(Extensions::OriginalCodeHandle handle);
[ [ [ 1, 17 ] ] ]
bc393a53a4cdb069870060e169cf86db88f870d2
ea12fed4c32e9c7992956419eb3e2bace91f063a
/zombie/code/zombie/nphysics/src/nphysics/ncphycharacter_cmds.cc
714fbbb546f503d160b914e56d6c670e4f8bdf56
[]
no_license
ugozapad/TheZombieEngine
832492930df28c28cd349673f79f3609b1fe7190
8e8c3e6225c2ed93e07287356def9fbdeacf3d6a
refs/heads/master
2020-04-30T11:35:36.258363
2011-02-24T14:18:43
2011-02-24T14:18:43
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,651
cc
//----------------------------------------------------------------------------- // ncphycharacter_cmds.cc // (C) 2005 Conjurer Services, S.A. //----------------------------------------------------------------------------- #include "precompiled/pchnphysics.h" #include "nphysics/ncphycharacter.h" //----------------------------------------------------------------------------- NSCRIPT_INITCMDS_BEGIN(ncPhyCharacter) NSCRIPT_ADDCMD_COMPOBJECT('DSEH', void, SetHeight, 1, (phyreal), 0, ()); NSCRIPT_ADDCMD_COMPOBJECT('DGEH', phyreal, GetHeight, 0, (), 0, ()); NSCRIPT_ADDCMD_COMPOBJECT('DSEW', void, SetWide, 1, (phyreal), 0, ()); NSCRIPT_ADDCMD_COMPOBJECT('DGEW', phyreal, GetWide, 0, (), 0, ()); NSCRIPT_INITCMDS_END() //------------------------------------------------------------------------------ /** Object persistency. */ bool ncPhyCharacter::SaveCmds(nPersistServer* ps) { if( !ncPhyCompositeObj::SaveCmds( ps ) ) { return false; } if( ps->GetSaveType() != nPersistServer::SAVETYPE_PERSIST ) { return true; } nCmd* cmd(ps->GetCmd( this->entityObject, 'DSEH')); n_assert2( cmd, "Error command not found" ); cmd->In()->SetF(this->height); ps->PutCmd(cmd); cmd = ps->GetCmd( this->entityObject, 'DSEW'); n_assert2( cmd, "Error command not found" ); cmd->In()->SetF(this->wideness); ps->PutCmd(cmd); return true; } //----------------------------------------------------------------------------- // EOF //-----------------------------------------------------------------------------
[ "magarcias@c1fa4281-9647-0410-8f2c-f027dd5e0a91" ]
[ [ [ 1, 55 ] ] ]
f8deef1d89b985debfb399b8c4cdfaf01970793b
1bb66b98419d712cfdb2b200bc7b8ae701f1927c
/branches/dependencies/Makefile.cpp
ba5a14258ce8f8f804cd7c9a9c03ae5acf03a426
[]
no_license
BackupTheBerlios/cbmakegen-svn
f9aadde316f8270296355106841666f346f7ff7a
6164cb69487932d5cd2101a9eca82f39a6703727
refs/heads/master
2021-01-10T18:26:41.642983
2010-06-21T11:53:04
2010-06-21T11:53:04
40,718,403
0
0
null
null
null
null
UTF-8
C++
false
false
16,388
cpp
#include <sdk.h> #include <wx/textfile.h> #include "Makefile.hpp" #include <globals.h> #include <messagemanager.h> #include <compiler.h> #include <compilerfactory.h> #include <macrosmanager.h> #include <wx/arrimpl.cpp> WX_DEFINE_OBJARRAY( cbMGArrayOfRules ); WX_DEFINE_OBJARRAY( cbMGSortFilesArray ); // keep our own copy, to sort it by file weight (priority) static wxString sHeader = _T( "# A simple makefile generator by KiSoft, 2007. mailto: [email protected]" ); const wxString cmdbefore = _T( "commandsbeforebuild" ); const wxString cmdafter = _T( "commandsafterbuild" ); const wxString cmdphony = _T( ".PHONY" ); const wxString objs = _T("$(OBJS)"); const wxString oobjs = _T("$$(OBJS)"); const wxString cmdclean = _T("clean"); cbMGMakefile::cbMGMakefile( cbProject* ppProject, const wxString& pFileName, bool pOverwrite,bool pSilence) : m_CommandPrefix( _T( '\t' ) ) , m_CommandPrefixRepeatCnt( 1 ) , m_pProj( ppProject ) , m_Filename( pFileName ) , m_Path( _T("") ) , m_IsSilence( pSilence ) , m_Overwrite( pOverwrite ) { //ctor m_Path = m_pProj->GetBasePath(); } cbMGMakefile::~cbMGMakefile() { //dtor } void cbMGMakefile::SetCommandPrefix( const wxChar& p_CommandPrefix ) { m_CommandPrefix = p_CommandPrefix; } void cbMGMakefile::SetCommandPrefixRepeatCnt( long p_CommandPrefixRepeatCnt ) { m_CommandPrefixRepeatCnt = p_CommandPrefixRepeatCnt; } int cbMGSortProjectFilesByWeight( ProjectFile*** p_ppOne, ProjectFile*** p_ppTwo ) { return ( *( *p_ppOne ) )->weight - ( *( *p_ppTwo ) )->weight; } cbMGSortFilesArray cbMGMakefile::GetProjectFilesSortedByWeight( ProjectBuildTarget* p_pTarget, bool p_Compile, bool p_Link ) { cbMGSortFilesArray files; for ( int i = 0; i < m_pProj->GetFilesCount(); ++i ) { ProjectFile* pf = m_pProj->GetFile( i ); // require compile if ( p_Compile && !pf->compile ) continue; // require link if ( p_Link && !pf->link ) continue; // if the file does not belong in this target (if we have a target), skip it if ( p_pTarget && ( pf->buildTargets.Index( p_pTarget->GetTitle() ) == wxNOT_FOUND ) ) continue; files.Add( pf ); } files.Sort( cbMGSortProjectFilesByWeight ); return files; } bool cbMGMakefile::reLoadDependecies(const wxString &p_DepsFileName,ProjectBuildTarget *p_pTarget,Compiler* p_pCompiler) { m_Deps.Clear(); if ( !wxFileExists( p_DepsFileName ) ) return false; wxString l_Buf; wxString l_VarName; wxTextFile l_DepFile; bool IsSkipThisFile = true; if (l_DepFile.Open( p_DepsFileName, wxConvFile )) { for ( unsigned long i = 0; i < l_DepFile.GetLineCount(); i++ ) { l_Buf = l_DepFile[i]; l_Buf.Trim(true); // Wrong! Don't uncomment it! Being deleted '\t' symbol! l_Buf.Trim(false); if ( l_Buf.IsEmpty() ) { l_VarName.Clear(); IsSkipThisFile = true; continue; } if ( _T('#') == l_Buf[0] ) continue; if ( _T('\t') == l_Buf[0] ) { if ( !IsSkipThisFile ) { if ( _T('"') == l_Buf[1] ) { wxString l_TmpName = l_Buf.AfterFirst( _T('\t') ); if (!l_TmpName.IsEmpty() && l_TmpName.GetChar(0) == _T('"') && l_TmpName.Last() == _T('"')) l_TmpName = l_TmpName.Mid(1, l_TmpName.Length() - 2); QuoteStringIfNeeded( l_TmpName ); m_Deps.AppendValue( l_VarName, l_TmpName ); } } } else { l_VarName = l_Buf.AfterFirst(_T(' ')); bool IsSource = l_VarName.Matches( _T("source:*") ); if ( IsSource ) { l_VarName = l_VarName.AfterFirst( _T(':') ); } /* * You would MUST found source file and get his filename from project * !!! .depend file content lowcase filenames */ wxFileName l_DepFileName = l_VarName; ProjectFile *pf = m_pProj->GetFileByFilename( l_DepFileName.GetFullPath(), l_DepFileName.IsRelative(), false ); if ( pf ) { const pfDetails& pfd = pf->GetFileDetails( p_pTarget ); if ( p_pCompiler->GetSwitches().UseFullSourcePaths ) { l_VarName = UnixFilename( pfd.source_file_absolute_native ); } else { l_VarName = pfd.source_file; } QuoteStringIfNeeded( l_VarName ); IsSkipThisFile = false; } else { IsSkipThisFile = true; } } } } /* FIXME (kisoftcb#1#): Next code for debug only! wxTextFile l_DebFile; l_DebFile.Create( _T("D:/DepsFile.log") ); m_Deps.SaveAllVars( l_DebFile ); l_DebFile.Write(); l_DebFile.Close(); */ } bool cbMGMakefile::getDependencies(ProjectBuildTarget *p_pTarget,Compiler* p_pCompiler) { wxFileName l_DepsFilename(m_pProj->GetFilename()); l_DepsFilename.SetExt(_T("depend")); if ( !wxFileExists( l_DepsFilename.GetFullPath() ) ) { wxString lMsg = _( "Dependencies file " ) + l_DepsFilename.GetFullPath() + _(" is not exists!\n" "Dependencies must being created before use MakefileGen plugin.\n" "Continue anyway?" ); return (wxID_YES == cbMessageBox(lMsg, _("Warning"), wxICON_EXCLAMATION | wxYES_NO, (wxWindow *)Manager::Get()->GetAppWindow())); } /* l_DepsFilename content filename for <project>.depend */ return reLoadDependecies(l_DepsFilename.GetFullPath(),p_pTarget,p_pCompiler); } bool cbMGMakefile::SaveMakefile() { bool l_Ret = false; wxString l_FullFilename = m_Path + m_Filename; if ( m_Overwrite && wxFileExists( l_FullFilename ) ) wxRemoveFile( l_FullFilename ); wxTextFile l_File; if ( !l_File.Create( l_FullFilename ) ) { wxString lMsg = _( "File " ) + l_FullFilename + _(" is exists!\nOverwrite?" ); if (wxID_YES == cbMessageBox(lMsg, _("Warning"), wxICON_EXCLAMATION | wxYES_NO, (wxWindow *)Manager::Get()->GetAppWindow())) { wxRemoveFile( l_FullFilename ); } else { return l_Ret; } } // for active target only! wxString l_ActiveTargetName = m_pProj->GetActiveBuildTarget(); ProjectBuildTarget* l_pTarget = m_pProj->GetBuildTarget( l_ActiveTargetName ); if ( !l_pTarget ) { wxString l_Msg = _( "Can't found an active target!\n" "C::B MakefileGen could not complete the operation." ); cbMessageBox( l_Msg, _( "Error" ), wxICON_ERROR | wxOK, (wxWindow *)Manager::Get()->GetAppWindow() ); Manager::Get()->GetMessageManager()->DebugLog( l_Msg ); return l_Ret; } const wxString& l_CompilerId = l_pTarget->GetCompilerID(); Compiler* l_pCompiler = CompilerFactory::GetCompiler( l_CompilerId ); if ( !getDependencies( l_pTarget, l_pCompiler ) ) return false; m_Variables.AddVariable(_T("CPP"),l_pCompiler->GetPrograms().CPP); m_Variables.AddVariable(_T("CC"),l_pCompiler->GetPrograms().C); m_Variables.AddVariable(_T("LD"),l_pCompiler->GetPrograms().LD); m_Variables.AddVariable(_T("LIB"),l_pCompiler->GetPrograms().LIB); m_Variables.AddVariable(_T("WINDRES"),l_pCompiler->GetPrograms().WINDRES); const wxArrayString& l_CommandsBeforeBuild = l_pTarget->GetCommandsBeforeBuild(); const wxArrayString& l_CommandsAfterBuild = l_pTarget->GetCommandsAfterBuild(); wxString l_TargetFileName = l_pTarget->GetOutputFilename(); Manager::Get()->GetMacrosManager()->ReplaceMacros(l_TargetFileName, l_pTarget); wxFileName l_OutFileName = UnixFilename(l_TargetFileName); cbMGRule l_Rule; if ( 0 == l_ActiveTargetName.CmpNoCase( _T( "default" ) ) ) { l_Rule.SetTarget( _T( "all" ) ); } else { l_Rule.SetTarget( l_ActiveTargetName ); } wxString l_Pre; if ( l_CommandsBeforeBuild.GetCount() > 0 ) { l_Pre = cmdbefore + _T(" "); } l_Pre += l_OutFileName.GetFullPath(); if ( l_CommandsAfterBuild.GetCount() > 0 ) { l_Pre += _T(" ") + cmdafter; } l_Rule.SetPrerequisites( l_Pre ); m_Rules.Add( l_Rule ); if ( l_CommandsBeforeBuild.GetCount() > 0 ) { l_Rule.Clear(); l_Rule.SetTarget( cmdphony ); l_Rule.SetPrerequisites( cmdbefore ); m_Rules.Add( l_Rule ); l_Rule.Clear(); l_Rule.SetTarget( cmdbefore ); for ( unsigned long idx = 0; idx < l_CommandsBeforeBuild.GetCount(); idx ++ ) { l_Rule.AddCommand( l_CommandsBeforeBuild[ idx ] ); } m_Rules.Add( l_Rule ); } if ( l_CommandsAfterBuild.GetCount() > 0 ) { l_Rule.Clear(); l_Rule.SetTarget( cmdphony ); l_Rule.SetPrerequisites( cmdafter ); m_Rules.Add( l_Rule ); l_Rule.Clear(); l_Rule.SetTarget( cmdafter ); for ( unsigned long idx = 0; idx < l_CommandsAfterBuild.GetCount(); idx ++ ) { l_Rule.AddCommand( l_CommandsAfterBuild[ idx ] ); } m_Rules.Add( l_Rule ); } l_Rule.Clear(); l_Rule.SetTarget( l_OutFileName.GetFullPath() ); l_Rule.SetPrerequisites( objs ); wxString kind_of_output = _T( "unknown" ); CommandType ct = ctInvalid; // get rid of compiler warning switch ( l_pTarget->GetTargetType() ) { case ttConsoleOnly: ct = ctLinkConsoleExeCmd; kind_of_output = _T( "console executable" ); break; case ttExecutable: ct = ctLinkExeCmd; kind_of_output = _T( "executable" ); break; case ttDynamicLib: ct = ctLinkDynamicCmd; kind_of_output = _T( "dynamic library" ); break; case ttStaticLib: ct = ctLinkStaticCmd; kind_of_output = _T( "static library" ); break; case ttNative: ct = ctLinkNativeCmd; kind_of_output = _T( "native" ); break; case ttCommandsOnly: ct = ctLinkConsoleExeCmd; kind_of_output = _T( "commands only" ); break; // case ttCommandsOnly: // // add target post-build commands // ret.Clear(); // AppendArray(GetPostBuildCommands(target), ret); // return ret; // break; break; } /*if(ttCommandsOnly == lTarget->GetTargetType()) { GetPostBuildCommands(lTarget); } else*/ { l_Rule.AddCommand( _T( "echo Building " ) + kind_of_output + _T( " " ) + l_OutFileName.GetFullPath() ); wxString l_LinkerCmd = l_pCompiler->GetCommand( ct ); l_pCompiler->GenerateCommandLine( l_LinkerCmd, l_pTarget, NULL, l_OutFileName.GetFullPath(), oobjs, wxEmptyString, wxEmptyString ); l_Rule.AddCommand( l_LinkerCmd ); } m_Rules.Add( l_Rule ); // Form rules wxString l_Tmp; unsigned long ii; wxString macro; wxString file; wxString object; wxString FlatObject; wxString deps; cbMGSortFilesArray files = GetProjectFilesSortedByWeight(l_pTarget,true,false); unsigned long lnb_files = files.GetCount(); for ( ii = 0; ii < lnb_files; ii++ ) { l_Rule.Clear(); ProjectFile* pf = files[ ii ]; const pfDetails& pfd = pf->GetFileDetails( l_pTarget ); wxString l_Object = ( l_pCompiler->GetSwitches().UseFlatObjects )?pfd.object_file_flat:pfd.object_file; wxString l_CompilerCmd; // lookup file's type FileType ft = FileTypeOf( pf->relativeFilename ); bool isResource = ft == ftResource; bool isHeader = ft == ftHeader; if ( !isHeader || l_pCompiler->GetSwitches().supportsPCH ) { pfCustomBuild& pcfb = pf->customBuild[l_pCompiler->GetID()]; l_CompilerCmd = pcfb.useCustomBuildCommand ? pcfb.buildCommand : l_pCompiler->GetCommand( isResource ? ctCompileResourceCmd : ctCompileObjectCmd ); wxString l_SourceFile; if ( l_pCompiler->GetSwitches().UseFullSourcePaths ) { l_SourceFile = UnixFilename( pfd.source_file_absolute_native ); // for resource files, use short from if path because if windres bug with spaces-in-paths if ( isResource ) { l_SourceFile = pf->file.GetShortPath(); } } else { l_SourceFile = pfd.source_file; } QuoteStringIfNeeded( l_SourceFile ); l_pCompiler->GenerateCommandLine( l_CompilerCmd, l_pTarget, pf, l_SourceFile, l_Object, pfd.object_file_flat, pfd.dep_file ); m_Variables.AppendValue( _T( "OBJS" ), l_Object ); l_Rule.SetTarget( l_Object ); l_Rule.SetPrerequisites( l_SourceFile ); l_Rule.AddCommand( _T( "echo Compiling: " ) + l_SourceFile ); l_Rule.AddCommand( l_CompilerCmd ); m_Rules.Add( l_Rule ); } } for ( unsigned long i=0; i < m_Deps.Count(); i++ ) { l_Rule.Clear(); l_Rule.SetTarget( m_Deps.GetVarName( i ) ); l_Rule.SetPrerequisites( m_Deps.GetVariable( i ) ); m_Rules.Add( l_Rule ); } l_Rule.Clear(); l_Rule.SetTarget( cmdphony ); l_Rule.SetPrerequisites( cmdclean ); m_Rules.Add( l_Rule ); l_Rule.Clear(); l_Rule.SetTarget( cmdclean ); l_Rule.AddCommand( _T( "echo Delete $(OBJS) " ) + l_OutFileName.GetFullPath() ); #ifdef __WXMSW__ l_Rule.AddCommand( _T( "del /f $(OBJS) " ) + l_OutFileName.GetFullPath() ); #else l_Rule.AddCommand( _T( "rm -f $(OBJS) " ) + l_OutFileName.GetFullPath() ); #endif m_Rules.Add( l_Rule ); // save header l_File.AddLine( sHeader ); l_File.AddLine( wxEmptyString ); m_Variables.SaveAllVars( l_File ); SaveAllRules( l_File ); l_File.Write(); l_File.Close(); l_Ret = true; return l_Ret; } bool cbMGMakefile::SaveAllRules( wxTextFile& pFile ) { bool lRet = false; size_t num = m_Rules.GetCount(); unsigned long i; unsigned long k; for ( i = 0; i < num; i++ ) { cbMGRule& lRule = m_Rules.Item( i ); pFile.AddLine( lRule.GetTarget() + _T( ": " ) + lRule.GetPrerequisites() ); for ( k = 0; k < lRule.GetCommands().GetCount(); k++ ) { if ( m_IsSilence ) { pFile.AddLine( GetCommandPrefix() + _T( "@" ) + lRule.GetCommands()[ k ] ); } else { pFile.AddLine( GetCommandPrefix() + lRule.GetCommands()[ k ] ); } } pFile.AddLine( wxEmptyString ); } lRet = true; return lRet; }
[ "kisoftcb@43f0282e-a136-0410-aefe-e816e2e1d084" ]
[ [ [ 1, 460 ] ] ]
4b2ecea631520eba308fabd0638b7c40bcd608ee
5a48b6a95f18598181ef75dba2930a9d1720deae
/LuaEngine/Core/Main.cpp
3beb76067ad9681a5b900be2448dfde0365db605
[]
no_license
CBE7F1F65/f980f016e8cbe587c9148f07b799438c
078950c80e3680880bc6b3751fcc345ebc8fe8e5
1aaed5baef10a5b9144f20603d672ea5ac76b3cc
refs/heads/master
2021-01-15T10:42:46.944415
2010-08-28T19:25:48
2010-08-28T19:25:48
32,192,651
0
0
null
null
null
null
UTF-8
C++
false
false
197
cpp
#include "vld.h" #include "../Header/Main.h" #include "../Header/Process.h" int WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR, int) { mp.ClientInitial(); mp.Release(); return 0; }
[ "CBE7F1F65@120521f8-859b-11de-8382-973a19579e60" ]
[ [ [ 1, 14 ] ] ]