Skip to content

Instantly share code, notes, and snippets.

@hsienwei
hsienwei / ByteConverter.cs
Created March 20, 2018 09:54
一個用來將指定byte buff轉其他型態資料的類別.
class ByteConverter
{
/*public static byte[] BuffToBuildData(int data_id)
{
int Length = 0;
System.IntPtr ptr = GamePlayer_GetBattleReportBaseInfoBuf(data_id, ref Length);
if (ptr == System.IntPtr.Zero)
{
return null;
# coding=utf8
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.support.wait import WebDriverWait
ID = 'id' # your id.
PWD = 'password' # your password
@hsienwei
hsienwei / TableDataUtil.cs
Created March 6, 2018 09:03
對一instance取出所有public欄位資料並回傳字串.
public class TableDataUtil
{
public static string GetDataDetailStr<T>(T obj)
{
//
// 取出所有public欄位資料並回傳字串.
//
StringBuilder sb = new StringBuilder();
sb.AppendLine(obj.GetType().ToString());
@hsienwei
hsienwei / NGUIAtlasToStringConverter.cs
Created March 2, 2018 07:39
將NGUI UIAtlas的spriteList 轉成 UGUI可用的spritesheet SpriteMetaData
#if UNITY_EDITOR
using System.Collections.Generic;
using UnityEngine;
using UnityEditor;
#endif
public class NGUIAtlasToStringConverter {
#if UNITY_EDITOR
[MenuItem("Tools/NGUI Atlas to Sprites Tool/Convert")]
@hsienwei
hsienwei / 3.cpp
Created February 8, 2018 07:07
第三種作法, 只用IntPtr做參照, 要取值再個別呼叫
PLUGIN_DLL_API const Data* GamePlayer_GetBattleReportBaseInfo(const uint32 mail_id) { ... }
PLUGIN_DLL_API uint32 Repo_ReportID(Data *Dta) { return Dta->id; }
PLUGIN_DLL_API uint32 Repo_ReportTime(Data *Dta) { return Dta->time; }
PLUGIN_DLL_API uint16 Repo_Type(Data *Dta) { return Dta->type; }
@hsienwei
hsienwei / 2.cpp
Created February 8, 2018 07:00
第二種作法, 將結構傳入c++中memcpy填值, 該作法Data在c#中一定要是struct不能為class
PLUGIN_DLL_API bool GetDataRef(const int data_id,
Data* ref)
{
const go3::BuildDataPN* report = go3::BuildDataTable3::Instance().GetTableData(data_id);
if (NULL == report)
{
return NULL;
}
@hsienwei
hsienwei / 1.cpp
Created February 8, 2018 06:53
第一種作法, c++指標到c#從IntPtr轉換成byte後再依照自己的指定順序塞進結構中
PLUGIN_DLL_API const void* GetDataPtr(const int data_id, int &length)
{
length = sizeof(Data);
const Data* Dta = ... // 資料來源
if (NULL == Dta)
{
return NULL;
}
/*class TableDelegate
{
public:
int GetItemCount(){return 0;}
bool OnItemShow( Node *Item, int Index){};
};*/
template<class TableDelegateT>
class TableViewUtilEx
clock_t t1, t2;
t1 = clock();
DoSomething();
t2 = clock();
float diff = ((float)(t2 - t1) / 1000000.0F) * 1000;
printf("battle total time : %f \n ", diff);
@hsienwei
hsienwei / main.cpp
Created February 23, 2015 02:46
main.cpp in cocos2d-x + wxWidget
#include "main.h"
#include "AppDelegate.h"
#include "HelloWorldScene.h"
#include "cocos2d.h"
#include "wx/wx.h"
USING_NS_CC;
class MyApp : public wxApp
{
public: