Skip to main content

HD RPG 引擎框架(GDK) Python API

Project description

HD GDK Python API

这是一个用于调用 HD RPG 引擎框架(GDK)的 Python 库,提供了基础功能、登录验证、IP管理、插件安装扩展及环境初始化等功能的封装。

功能特点

  • 自动加载 HD 引擎 DLL 文件(支持调试版和非调试版)
  • 提供简洁易用的 Python 接口
  • 内置错误处理机制
  • 模块化设计,便于扩展更多功能

安装方法

从源码安装

# 进入项目目录
cd HD_python

# 安装包(开发模式)
pip install -e .

使用示例

下面是一个完整的示例,展示如何使用 HD GDK Python API 的基础模块:

#!/usr/bin/env python
# -*- coding: utf-8 -*-

from hdgdk import create_hd_basic

# 准备工作
# 1. 确保你有正确的 HD 引擎 DLL 文件
# 2. 将 DLL 文件放置在指定目录

# 设置 DLL 文件所在路径(根据实际情况修改)
DLL_PATH = "D:/HD/HD_python/dll"  # 替换为你的 DLL 文件路径
# 是否使用调试版 DLL
IS_DEBUG = False  # 正式环境设为 False,开发环境可设为 True

# 创建基础功能模块实例
try:
    hd_basic = create_hd_basic(DLL_PATH, IS_DEBUG)
    print("成功创建基础模块实例")

except Exception as e:
    print(f"创建基础模块实例失败: {str(e)}")
    exit(1)

# 使用基础模块功能

# 1. 获取当前插件版本号
try:
    version = hd_basic.get_version()
    print(f"HD 插件版本号: {version}")
except Exception as e:
    print(f"获取版本号失败: {str(e)}")

# 2. 设置插件信息(可选)
try:
    # 如果需要自定义 DLL 名称,可以在这里设置
    # result = hd_basic.set_plugin(release_dll="CustomHD.dll", debug_dll="CustomHDDebug.dll")
    # print(f"设置插件信息结果: {result}")
    pass
except Exception as e:
    print(f"设置插件信息失败: {str(e)}")

# 3. 获取最大窗口数
try:
    max_window_num = hd_basic.get_max_window_num()
    print(f"最大窗口数: {max_window_num}")
except Exception as e:
    print(f"获取最大窗口数失败: {str(e)}")

# 4. 获取执行环境信息(中控窗口)
try:
    env_info = hd_basic.get_execute_env_info(window_index=0)  # 0 表示中控窗口
    print(f"中控执行环境信息: {env_info}")
except Exception as e:
    print(f"获取执行环境信息失败: {str(e)}")

# 5. 错误处理示例
# 假设我们调用了一个可能失败的操作
try:
    # 这里仅作为示例,实际使用中替换为真实的操作
    # 假设某个操作返回了错误代码
    error_code = 0  # 示例值,实际使用中替换为真实的返回值
    if error_code != 1:
        error_str = hd_basic.get_error_str(error_code)
        print(f"操作失败,错误代码: {error_code}, 错误信息: {error_str}")

except Exception as e:
    print(f"错误处理示例失败: {str(e)}")

# 6. 获取最近的 WIN32 API 错误值
try:
    last_error = hd_basic.get_last_error()
    print(f"最近的 WIN32 API 错误值: {last_error}")
except Exception as e:
    print(f"获取 WIN32 API 错误值失败: {str(e)}")

print("HD GDK Python API 基础功能示例执行完毕")

注意事项

  1. 在使用前,请确保你已经获得了正确的 HD 引擎 DLL 文件
  2. 对于不同的功能模块,请使用对应的工厂函数创建实例
  3. 所有操作都应该包含适当的错误处理
  4. 更多高级功能和其他模块的使用方法,请参考源代码和相关文档

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

hdgdk-0.1.0.tar.gz (90.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

hdgdk-0.1.0-py3-none-any.whl (114.3 kB view details)

Uploaded Python 3

File details

Details for the file hdgdk-0.1.0.tar.gz.

File metadata

  • Download URL: hdgdk-0.1.0.tar.gz
  • Upload date:
  • Size: 90.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for hdgdk-0.1.0.tar.gz
Algorithm Hash digest
SHA256 9811484627aa97bf1661618a74fdc5c795859982f5c86c671ae5d21f480f0e02
MD5 9c9ab5aaecf63c5b225481228a0514d9
BLAKE2b-256 4e0c5c2cb20dd88dceebed65e61b520af29f7a5a4354e73c628a42f081f52dfb

See more details on using hashes here.

File details

Details for the file hdgdk-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: hdgdk-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 114.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for hdgdk-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 91100b6559ebda3be81714bd5c7d7b1c87e4e71267f2347e4048b3cdc5a07e70
MD5 f1ba821879390771b1cedd5c2521ff33
BLAKE2b-256 1be1962a10ba6b04f2c50cc87b0e3d11bcbf5742c370e8cee33858ab00fda4d0

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page